twig

How to add n-days to twig date format within a for-loop?

半城伤御伤魂 提交于 2021-01-29 09:09:59
问题 I'm working with twig and got the date and format working. I have a start date (let's say todays day) and I'd like to print every day into a table cell. I have my date field in the var datum and I'm able to add 1 day with this. it's working. {% set datum = date(current_user.cwmon)|date_modify("+1 day")|date('D d.m.y') %} when I put this into a for loop, I get not the answer I'd like to. the code itself: {% for j in 0..6 %} {% set datum = date(current_user.cwmon)|date_modify("+1 day")|date('D

Rendered view is not displaying in my back office in PS 1.7

风格不统一 提交于 2021-01-29 07:27:21
问题 I am trying to create a view in the back office tab that I created in the installation of my Module. My Module adds the tab like this: protected function _installTabs() { if(!$tabId = \Tab::getIdFromClassName('IezonPortfolio')) { $tab = new \Tab(); $tab->class_name = 'IezonPortfolio'; $tab->module = $this->name; $tab->id_parent = \Tab::getIdFromClassName('ShopParameters'); $tab->active = 1; foreach (Language::getLanguages(false) as $lang): $tab->name[(int) $lang['id_lang']] = 'My Portfolio';

Working with Twig and PHPMailer

对着背影说爱祢 提交于 2021-01-28 18:24:58
问题 I am developing a web that work with Twig and PHPMailer. When the system send a email, I want that email's body to be in HTML. I must show data in email's body. I have the file personal.php that pass data to file personal.html by Twig $twig->display('Personal.html',array( "text" => $text, "lenguaje" => substr($lang, 0, 2) )); How I do to pass the HTML file with Twig?. When I pass data I do $body = '<div> <p>'.$this->text['pass_recov_body'].'</p> <p><strong>'.$this->text['date_user'].'</strong

truncate in twig on html content

自古美人都是妖i 提交于 2021-01-28 08:13:37
问题 I would like to truncate a long string, who content html tag. From my controller php. content="<div> <h1>my title</h1> <p>para 1 ...</p> </div>"; I would like to truncate this, so i did this in twig : {{ content|raw|truncate(15) }} But the html are broken, see bellow : <div> <h1>my ti... I want to keep the end of tag, like this : <div> <h1>my titl...</h1> </div> Anyone have an idea ? 回答1: You can use the Twig Truncation Extension. As you can read in the doc: {% set html %} <h1>Test heading!<

How to inject global variables into all templates?

≡放荡痞女 提交于 2021-01-28 04:58:53
问题 In my twig template there are some variables that are required on each page like userName , userId or userImage . What is the best way to inject them into the template? I already read the article How to Inject Variables into all Templates but how could I write a variable (e.g. current user) into the config/packages/twig.php file? Right now there is code like this in every controller: return $this->render('admin/users/index.html.twig', [ "allUsers" => $allUsers, "pageTitle" =>

Referencing a template in Twig / Symfony2

删除回忆录丶 提交于 2021-01-28 00:40:18
问题 A Twig template in one bundle calls another Twig template in another bundle, but I can't reference it. The file is in this folder: src/Company/Bundle/ActivityBundle/Resources/views/Default/index.html.twig And I am trying to reference it from a Twig file in another bundle like this: {% extends "Company/Bundle/ActivityBundle/index.html.twig" %} I've tried every possible combination, but it just doesn't pick it up and I get a "Twig_Error_Loader: Unable to find template" error 回答1: I think you've

delete form-control in form-row symfony/twig

你离开我真会死。 提交于 2021-01-27 19:08:45
问题 When i create this builder $builder ->add('categorie', EntityType::class, [ // This field shows all the categories 'class' => Categorie::class, 'mapped' => false, 'multiple' => true, 'attr' => ['class' => 'mdb-select'] ]) and when i do form_row(form.name) i see class has value 'form-control' automaticaly, but me i'm use MDBootstrap and i want to set only mdb-select 回答1: It is caused by one of the default form themes of Symfony, I think by default currently it's the bootstrap 4 theme. To get

Symfony set block content from controller

試著忘記壹切 提交于 2021-01-27 12:15:15
问题 Is there a way to set a template block content from within a controller in Symfony? Is there a way to do something like this from within a controller? $this->get('templating')->setBlockContent('page_title', $page_title); I need to set the page title dynamically and I want to avoid modifying every single action template. I know I can pass the $page_title variable to Controller:render but I don't want to add {% block title %} {{ page_title }} {% endblock %} to every single action template. 回答1:

'Twig_Error_Syntax' with message Unknown “form_start” function

蹲街弑〆低调 提交于 2021-01-27 11:44:53
问题 Is it possible to make a standalone form with symfony3 and twig? I can't get past this error: Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'Unknown "form_start" function in "new.html.twig" at line 1 The 3.1 documentation cites this example, which works fine, but it's actually using 2.7 My simple project is organized like this: . ├── composer.json ├── composer.lock ├── src │ └── form.php ├── vendor │ └── ... └── views └── new.html.twig form.php <?php require_once __DIR__.'/

'Twig_Error_Syntax' with message Unknown “form_start” function

僤鯓⒐⒋嵵緔 提交于 2021-01-27 11:42:43
问题 Is it possible to make a standalone form with symfony3 and twig? I can't get past this error: Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'Unknown "form_start" function in "new.html.twig" at line 1 The 3.1 documentation cites this example, which works fine, but it's actually using 2.7 My simple project is organized like this: . ├── composer.json ├── composer.lock ├── src │ └── form.php ├── vendor │ └── ... └── views └── new.html.twig form.php <?php require_once __DIR__.'/