Fixed main page controller function

Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
Polonkai Gergely 2012-07-01 20:29:59 +02:00
parent 95152ca62b
commit 44c555bcb7
4 changed files with 49 additions and 6 deletions

View File

@ -6,10 +6,22 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
public function homepageAction()
{
$mainPageArticle = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Article')->findOneBy(array('main_page' => 1), true, array('created_at', 'DESC'), 1);
if (!$mainPageArticle)
throw $this->createNotFoundException('A keresett cikk nem létezik!');
return $this->forward('KekRozsakFrontBundle:Default:article', array('articleSlug' => $mainPageArticle->getSlug()));
}
public function articleAction($articleSlug)
{
$article = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Article')->findOneBySlug($articleSlug);
if (!$article)
throw $this->createNotFoundException('A keresett cikk nem létezik!');
return $this->render('KekRozsakFrontBundle:Default:article.html.twig', array(
'article' => $article
));

View File

@ -267,4 +267,31 @@ class Article
{
return $this->updated_by;
}
/**
* @var boolean $main_page
*/
private $main_page;
/**
* Set main_page
*
* @param boolean $mainPage
* @return Article
*/
public function setMainPage($mainPage)
{
$this->main_page = $mainPage;
return $this;
}
/**
* Get main_page
*
* @return boolean
*/
public function getMainPage()
{
return $this->main_page;
}
}

View File

@ -29,6 +29,10 @@ KekRozsak\FrontBundle\Entity\Article:
update_reason:
type: text
nullable: true
main_page:
type: boolean
nullable: true
default: false
manyToOne:
created_by:
targetEntity: User

View File

@ -8,18 +8,18 @@
<div id="wrapper">
<div id="menu">
<ul>
<li><a href="">Főoldal - Aktuális</a></li>
<li><a href="">Rólunk</a></li>
<li><a href="{{ path('KekRozsakFrontBundle_homepage') }}">Főoldal - Aktuális</a></li>
<li><a href="{{ path('KekRozsakFrontBundle_article', { articleSlug: 'rolunk' }) }}">Rólunk</a></li>
<li><a href="">Fórum</a></li>
<li><a href="">Mágiáról röviden</a></li>
<li><a href="">Rendek</a></li>
<li><a href="">A régiek</a></li>
<li><a href="{{ path('KekRozsakFrontBundle_article', { articleSlug: 'magiarol-roviden' }) }}">Mágiáról röviden</a></li>
<li><a href="{{ path('KekRozsakFrontBundle_article', { articleSlug: 'rendek' }) }}">Rendek</a></li>
<li><a href="{{ path('KekRozsakFrontBundle_article', { articleSlug: 'a-regiek' }) }}">A régiek</a></li>
<li><a href="">Archívum</a></li>
<li><a href="">Ajánlott oldalak</a></li>
</ul>
</div>
<div id="header">
<h1><img src="{{ asset('images/kek_rozsak_felirat.jpg') }}" alt="Kék Rózsák" /></h1>
<h1><a href="{{ path('KekRozsakFrontBundle_homepage') }}"><img src="{{ asset('images/kek_rozsak_felirat.jpg') }}" alt="Kék Rózsák" /></a></h1>
<h2><img src="{{ asset('images/okkultista_kor_felirat.jpg') }}" alt="A Kék Rózsa okkultista kör honlapja" /></h2>
</div>
<div id="content-wrapper">