Jump to content
CrisTany

Symfony2 Problem

Recommended Posts

Posted (edited)

Nu gasesc in documentatie chestia asta, deci eu am un Bundle creat pe care imi incep proiectul (invat inca framework-ul) si un controller care imi introduce niste date in db de fiecare data cand accesez route-ul lui si imi afiseaza ce introduce.

Cum fac style la pagini ?

Am cautat pe net si am gasit ceva legat de assets, dar nu imi pot da seama inca. Ceva ajutor sa imi mearga mai repede treaba ?

Sau sa am un header comun la toate template-urile (views, html.twig de la fecare controller), chestia e ca am gasit base.html.twig care are partea de head, dar tot nu reusesc sa fac cum vreau.

Multumesc

Edited by CrisTany
Posted (edited)

Vezi: The Templating Helpers (The Symfony Components)

La tine in header:


PHP: <link href="<?php echo $view['assets']->getUrl('css/style.css') ?>" rel="stylesheet" type="text/css" />
TWIG: <link href="{{ asset('css/style.css') }}" rel="stylesheet" type="text/css" />

sau daca ai template-ul tau deja creat si vrei sa-l folosesti


use Symfony\Component\HttpFoundation\Response;
.....
.....
$loader = new \Twig_Loader_Filesystem('/locatie/template/');
$twig = new \Twig_Environment($loader, array(
'cache' => __DIR__.'/../../../../app/cache/custom',
));
$tmpl = $twig->loadTemplate('base.twig.html');
$response = new Response();
$response->setContent($tmpl);
return $response;

Edited by darkking

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...