Jump to content

Symfony2 Problem

Recommended Posts

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.


Edited by CrisTany
Link to comment
Share on other sites

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();
return $response;

Edited by darkking
Link to comment
Share on other sites

Join the conversation

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

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...