$ this ->enablePlugins( 'sfDoctrinePlugin' , 'sfTwigPlugin' ); <br><br> * This source code was highlighted with Source Code Highlighter .
all:<br> view_class: sfTwig<br> partial_view_class: sfTwig<br> <br> * This source code was highlighted with Source Code Highlighter .
function executeIndex() {<br> // Symfony <br> require_once 'path_to_symfony_project/lib/vendor/symfony/lib/helper/AssetHelper.php' ;<br> require_once 'path_to_symfony_project /lib/vendor/symfony/lib/helper/TagHelper.php' ;<br> <br> $loader = new Twig_Loader_Filesystem( '/var/www/symfony-test/html/apps/blahg/modules/posts/templates' );<br> <br> $twig = new Twig_Environment($loader, array( 'cache' => false ));<br> <br> // <br> $lexer = new Twig_Lexer($twig, array(<br> 'tag_comment' => array( '/*' , '*/' ),<br> 'tag_block' => array( '[' , ']' ),<br> 'tag_variable' => array( '{' , '}' ),<br> ));<br> $twig->setLexer($lexer);<br> <br> // Symfony <br> $twig->addExtension( new Asset_Twig_Extension());<br> $twig->addExtension( new Tag_Twig_Extension());<br> <br> // <br> $ this ->postss = Doctrine::getTable( 'Posts' )<br> ->createQuery( 'a' )<br> ->leftJoin( 'a.Comments c' )<br> ->execute();<br> <br> // <br> $template = $twig->loadTemplate( 'indexSuccess.html' );<br> <br> // HTTP <br> $ this ->getResponse()->setContent($template->render(array( 'postss' => $ this ->postss->getData())));<br> <br> // <br> return sfView::NONE;<br>} <br><br> * This source code was highlighted with Source Code Highlighter .
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > <br> < html xmlns ="http://www.w3.org/1999/xhtml" xml:lang ="en" lang ="en" > <br> < head > <br> { 'main'|use_stylesheet('first') }<br> { ''|include_stylesheets }<br> </ head > <br> < body > <br> [ block content ][ endblock ]<br> </ body > <br> </ html > <br><br> * This source code was highlighted with Source Code Highlighter .
[ extends "layout.html" ]<br><br>[ block content ]<br><br> < h1 > Postss List </ h1 > <br> < table class ="posts-list" > <br> < thead > <br> < tr > <br> < th > Id </ th > <br> < th > Title </ th > <br> < th > Text </ th > <br> < th > Modified </ th > <br> < th > Comments count </ th > <br> </ tr > <br> </ thead > <br> < tbody > <br> [ for posts in postss ]<br> < tr > <br> < td > { posts.id } </ td > <br> < td >< a href ="" > { posts.title } </ a ></ td > <br> < td > { posts.text } </ td > <br> < td > { posts.modified_ } </ td > <br> < td > { posts.Comments.count } </ td > <br> </ tr > <br> [ endfor ]<br> </ tbody > <br> </ table > <br><br>[ endblock ] <br><br> * This source code was highlighted with Source Code Highlighter .
{ 'main'|use_stylesheet('first') }
{ ''|include_stylesheets }
{ ''|include_stylesheets }
Source: https://habr.com/ru/post/88634/
All Articles