php - Whats the easiest way to use global variables in twig templates -


i need inject html file website base.html.twig file.

one solution use php function 'file_get_contents' within controller , make available template so:

$globalfooter = file_get_contents('http://mysite.co.uk/footer/footer.html.twig');  return $this->render('imaginegdmbundle:default:product.html.twig', array('globalfooter' => $globalfooter)); 

but mean having implement code above every controller function uses footer. there better way?

im sure there must way create global variable , make them available base.html.twig template...but new symfony , unsure how it. suggestions??

question explained in documentation twig global variables. situation requires create twig extension. simlpe function can call anywhere in templates.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -