News sidebar is now ajax-based, and hidden by default
Signed-off-by: Gergely Polonkai <polesz@w00d5t0ck.info>master
parent
3701840045
commit
feda5d7d57
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace KekRozsak\FrontBundle\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
|
||||
/**
|
||||
* Description of NewsController
|
||||
*
|
||||
* @author polesz
|
||||
*/
|
||||
class NewsController extends Controller
|
||||
{
|
||||
/**
|
||||
* @Route("/newsSideList.html", name="KekRozsakFrontBundle_newsSideList", options={"expose": true})
|
||||
* @Template()
|
||||
*/
|
||||
public function sideListAction()
|
||||
{
|
||||
$newsRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:News');
|
||||
$searchCriteria = array();
|
||||
if (
|
||||
!is_object($this->get('security.context')->getToken())
|
||||
|| !is_object($this->get('security.context')->getToken()->getUser())
|
||||
) {
|
||||
$searchCriteria['public'] = true;
|
||||
}
|
||||
|
||||
$news = $newsRepo->findBy($searchCriteria, array('createdAt' => 'DESC'), 4);
|
||||
|
||||
return array(
|
||||
'news' => $news,
|
||||
);
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 888 B |
@ -0,0 +1,10 @@
|
||||
{% for news in recentNews %}
|
||||
<div class="hir">
|
||||
<p class="hir-cim">{{ news.title }}</p>
|
||||
<p class="hir-szoveg">{{ news.text|raw }}</p>
|
||||
{% if app.user %}
|
||||
<p class="hir-szerzo">{{ news.createdBy|userdataspan }}</p>
|
||||
{% endif %}
|
||||
<p class="hir-datum">{{ news.createdAt|date('Y-m-d H:i') }}</p>
|
||||
</div>
|
||||
{% endfor %}
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace KekRozsak\FrontBundle\Twig;
|
||||
|
||||
use Symfony\Bridge\Doctrine\RegistryInterface;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
|
||||
class NewsExtension extends \Twig_Extension
|
||||
{
|
||||
protected $_doctrine;
|
||||
protected $_securityContext;
|
||||
|
||||
public function __construct(RegistryInterface $doctrine, SecurityContextInterface $securityContext)
|
||||
{
|
||||
$this->_doctrine = $doctrine;
|
||||
$this->_securityContext = $securityContext;
|
||||
}
|
||||
|
||||
public function getGlobals()
|
||||
{
|
||||
$newsRepo = $this->_doctrine->getRepository('KekRozsakFrontBundle:News');
|
||||
$searchCriteria = array();
|
||||
if (!is_object($this->_securityContext->getToken()) || !is_object($this->_securityContext->getToken()->getUser()))
|
||||
$searchCriteria['public'] = true;
|
||||
|
||||
$news = $newsRepo->findBy($searchCriteria, array('createdAt' => 'DESC'), 4);
|
||||
|
||||
return array(
|
||||
'recentNews' => $news,
|
||||
);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'News';
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue