Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 767f7b1

Browse files
committed
some better styling on the news and page pages / forms
1 parent 08138dd commit 767f7b1

File tree

10 files changed

+80
-46
lines changed

10 files changed

+80
-46
lines changed

src/GoGreat/CMSBaseBundle/Controller/NewsController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function indexAction()
2121
{
2222
$newsArticles = $this->getEntityManager()
2323
->getRepository('GoGreat\CMSBaseBundle\Entity\NewsArticle')
24-
->findAll();
24+
->findAllNews();
2525

2626
if (!$newsArticles)
2727
throw new Exception\NotFoundHttpException('No news articles found.');
@@ -108,7 +108,7 @@ public function deleteAction($slug)
108108
->remove($newsArticle);
109109
$this->getEntityManager()->flush();
110110

111-
$this->get('session')->setFlash('Deleted news article');
111+
$this->get('session')->setFlash('success', 'Deleted news article');
112112

113113
return $this->redirect($this->generateUrl('news'));
114114
}

src/GoGreat/CMSBaseBundle/Controller/PageController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function editAction($slug)
6262
}
6363
}
6464

65-
return $this->render('CMSBaseBundle:News:edit.html.twig', array(
65+
return $this->render('CMSBaseBundle:Page:edit.html.twig', array(
6666
'form' => $form->createView(),
6767
));
6868
}
@@ -87,7 +87,7 @@ public function deleteAction($slug)
8787
->remove($page);
8888
$this->getEntityManager()->flush();
8989

90-
$this->get('session')->flash('Deleted news article');
90+
$this->get('session')->setFlash('success', 'Deleted page');
9191

9292
return $this->redirect($this->generateUrl('homepage'));
9393
}

src/GoGreat/CMSBaseBundle/DataFixtures/ORM/news.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ public function load($manager)
1818
$news = new Entity\NewsArticle();
1919
$news->setTitle("lôrém news #{$p}");
2020
$news->setContent("lorem news ipsum #{$p}");
21+
$inThePast = rand(0, 100);
22+
$date = strtotime("-{$inThePast}days");
23+
24+
$news->setPublishedDate(new \DateTime(date('Y-m-d', $date)));
2125

2226
$manager->getRepository('GoGreat\CMSBaseBundle\Entity\NewsArticle')->persist($news);
2327
}

src/GoGreat/CMSBaseBundle/Entity/NewsArticleRepository.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
*/
1313
class NewsArticleRepository extends EntityRepository
1414
{
15+
public function findAllNews()
16+
{
17+
$query = $this->createQueryBuilder('n')
18+
->orderBy('n.published_date', 'DESC')
19+
->getQuery();
20+
21+
return $query->execute();
22+
}
23+
1524
/**
1625
* persist an instance of NewsArticle with the entity_manager
1726
*

src/GoGreat/CMSBaseBundle/Resources/views/News/edit.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
{{ form_errors(form) }}
2020
{{ form_rest(form) }}
2121

22-
<br />
23-
<br />
24-
<input type="submit" />
22+
<div class="row submit">
23+
<input class="button" type="submit" value="save" />
24+
</div>
2525
</form>
2626
</div>
2727
</div>

src/GoGreat/CMSBaseBundle/Resources/views/News/index.html.twig

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,24 @@
66

77
{% block _content %}
88
{% for newsArticle in newsArticles %}
9-
<div class="editables_container block {{ cycle(['right', 'left'], loop.index) }}">
10-
<a href="{{ path('show_news', { 'slug': newsArticle.slug }) }}" >
11-
<h2 class="header">{{ newsArticle.title }}</h2>
9+
<div class="block {{ cycle(['right', 'left'], loop.index) }}">
10+
<a href="{{ path('show_news', { 'slug': newsArticle.slug }) }}">
11+
<h2 class="header">
12+
{{ newsArticle.title }}
13+
{% if admin %}
14+
<div class="admin">
15+
<a href="{{ path('edit_news', { 'slug': newsArticle.slug }) }}"
16+
class="edit">
17+
<img src="{{ asset('images/icons/page_edit.png') }}" />
18+
</a>
19+
<a href="{{ path('delete_news', { 'slug': newsArticle.slug }) }}"
20+
class="delete">
21+
<img src="{{ asset('images/icons/page_delete.png') }}" />
22+
</a>
23+
</div>
24+
{% endif %}
25+
<div class="subheader">{{ newsArticle.getPublishedDate | date('l d-m-Y') }}</div>
26+
</h2>
1227
</a>
1328

1429
<div class="content" style="height: 70px;">

src/GoGreat/CMSBaseBundle/Resources/views/News/show.html.twig

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
{% extends 'CMSBaseBundle::layout.html.twig' %}
22

33
{% block _content %}
4-
<div class="editables_container block two-col">
5-
{% if admin %}
6-
<div class="editables_admin">
7-
<a href="{{ path('edit_news', { 'slug': newsArticle.slug }) }}"
8-
class="editables_button editables_edit">
9-
<img src="{{ asset('images/icons/page_edit.png') }}" />
10-
</a>
11-
<a href="{{ path('delete_news', { 'slug': newsArticle.slug }) }}"
12-
class="editables_button editables_delete">
13-
<img src="{{ asset('images/icons/page_delete.png') }}" />
14-
</a>
15-
</div>
16-
{% endif %}
17-
<h2 class="header">{% block _title %} {{ newsArticle.title | raw }} {% endblock %}</h2>
4+
<div class="block two-col">
5+
<h2 class="header">
6+
{% block _title %} {{ newsArticle.title | raw }} {% endblock %}
7+
{% if admin %}
8+
<div class="admin">
9+
<a href="{{ path('edit_news', { 'slug': newsArticle.slug }) }}"
10+
class="edit">
11+
<img src="{{ asset('images/icons/page_edit.png') }}" />
12+
</a>
13+
<a href="{{ path('delete_news', { 'slug': newsArticle.slug }) }}"
14+
class="delete">
15+
<img src="{{ asset('images/icons/page_delete.png') }}" />
16+
</a>
17+
</div>
18+
{% endif %}
19+
<div class="subheader">{{ newsArticle.getPublishedDate | date('l d-m-Y') }}</div>
20+
</h2>
1821

1922
<div class="content" style="min-height: 300px;">
20-
<div>{{ newsArticle.getPublishedDate | date('l d-m-Y') }}</div>
2123
<div style="float: left;">{{ newsArticle.content | raw }}</div>
2224
<div style="float: right;">
2325
{% if newsArticle.image %}

src/GoGreat/CMSBaseBundle/Resources/views/Page/edit.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
{{ form_errors(form) }}
2020
{{ form_rest(form) }}
2121

22-
<br />
23-
<br />
24-
<input type="submit" />
22+
<div class="row submit">
23+
<input class="button" type="submit" value="save" />
24+
</div>
2525
</form>
2626
</div>
2727
</div>

src/GoGreat/CMSBaseBundle/Resources/views/Page/show.html.twig

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
{% extends 'CMSBaseBundle::layout.html.twig' %}
22

33
{% block _content %}
4-
<div class="editables_container block two-col">
5-
{% if admin %}
6-
<div class="editables_admin">
7-
<a href="{{ path('edit_page', { 'slug': page.slug }) }}"
8-
class="editables_button editables_edit">
9-
<img src="{{ asset('images/icons/page_edit.png') }}" />
10-
</a>
11-
<a href="{{ path('delete_page', { 'slug': page.slug }) }}"
12-
class="editables_button editables_delete">
13-
<img src="{{ asset('images/icons/page_delete.png') }}" />
14-
</a>
15-
</div>
16-
{% endif %}
17-
<h2 class="header">{% block _title %} {{ page.title | raw }} {% endblock %}</h2>
4+
<div class="block two-col">
5+
<h2 class="header">
6+
{% block _title %} {{ page.title | raw }} {% endblock %}
7+
{% if admin %}
8+
<div class="admin">
9+
<a href="{{ path('edit_page', { 'slug': page.slug }) }}"
10+
class="edit">
11+
<img src="{{ asset('images/icons/page_edit.png') }}" />
12+
</a>
13+
<a href="{{ path('delete_page', { 'slug': page.slug }) }}"
14+
class="delete">
15+
<img src="{{ asset('images/icons/page_delete.png') }}" />
16+
</a>
17+
</div>
18+
{% endif %}
19+
</h2>
1820

1921
<div class="content" style="min-height: 300px;">
2022
{{ page.content | raw }}

web/css/style.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ h3 { font-size: 150% }
9898
.site_content-sidebar .menu ul { list-style: dotted; margin: 10px 0px 0px 0px; }
9999
.site_content-sidebar .menu ul li{ margin: 0px 0px 0px 15px; }
100100

101-
.editables_container { position: relative }
102-
.editables_container .editables_admin { position: absolute; top: 5px; right: 5px; }
103-
.editables_container .editables_admin a { text-decoration: none; }
104-
105101
/*
106102
* block styling
107103
*/
@@ -112,7 +108,11 @@ h3 { font-size: 150% }
112108
.site_content-sidebar .block { width: 295px; clear: both; }
113109
.block.two-col { width: 670px; clear: both; }
114110
.block .header { padding: 5px; background-color: #6BBA70; border-bottom: 1px solid #36393D; font-family: 'MEgalopolisExtra'; font-size: 14px; height: 16px; }
111+
.block .header a { text-decoration: none; }
112+
.block .header .subheader { font-size: 9px; float: right; }
115113
.block .content { padding: 5px; }
114+
.block .admin { float: right; margin-left: 5px; }
115+
.block .admin a { text-decoration: none; }
116116

117117
/*
118118
* form styling
@@ -122,9 +122,11 @@ form .row.submit { margin-top: 50px; text-align: right; }
122122
form .row label { font-weight: bold; font-size: 14px; margin: 5px 0px 5px 3px; font-family: 'MEgalopolisExtra'; }
123123
form .row input,
124124
form .row textarea,
125+
form .row select,
125126
.button { -moz-border-radius: 5px; -webkit-border-radius: 5px;border: 1px solid #36393D; background-color: #36393D; color: gray;
126127
width: 650px; padding: 4px; }
127128
form .row textarea { min-height: 200px; }
129+
form .row select { width: auto; margin: 0px 5px; }
128130
.button { display: inline-block; text-align: center; width: auto !important; padding: 4px 10px !important;
129131
cursor: pointer; color: #36393D !important; background-color: gray !important; font-family: 'MEgalopolisExtra'; font-size: 16px; }
130132

0 commit comments

Comments
 (0)