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

pentaho - Carte Status / Kettle Slave Server Status page shows status for random runs instead of the latest run -

R summary function in ddply (plyr) in a simple way -

c# - Are delegates created via lambda expressions guaranteed to be cached? -