twig 相关问题

Twig是一款适用于PHP的现代,快速,灵活且安全的模板引擎。为Symfony创建并由Drupal 8采用。

树枝中选定无线电的总和值

我想在 Drupal Webform 表单中总结所选无线电的所有值(所有 q_ 键选中的值)。现在我这样做 data.q_1 + data.q_2 + data.q_3 + data.q_4 + data.q_5 但我想要 ...

回答 1 投票 0

如何只获取树枝中有多少个特定键(开头)的数字

我正在努力寻找一种方法来计算数组中的某些键,因此我不需要在 computed_twig 元素中键入所有键来进行某些计算。 我正在尝试获取 ...

回答 2 投票 0

如何在 Symfony 模板中为单选按钮(性别)和复选框(语言)做 Bootstrap

index.twig.html 尝试更正 twig 文件中的性别和语言引导程序。 {% extends 'base.html.twig'%} {% block title %}你好 StudentRegistrationController!{% endblock %} {% 块体 %...

回答 0 投票 0

Twig now|date('U') Deprecated error in PHP8.1

在 twig 模板中渲染日期时出错 {{现在|日期('U')}} 在呈现模板期间抛出异常(“strtotime(): 将 null 传递给参数 #1 ($date...

回答 0 投票 0

在 Twig 中立即检查变量是否已定义且为真

用 PHP 我能做到 这将检查一个变量是否存在,以及它的值是否不同于 0、null、'' 等类似零的值。 有没有办法在 Twig 中这样做...

回答 3 投票 0

for 循环中的 twig 语法使用子数组 $array[$index] 作为“in”子句

这部分代码来自经典视图 [...] id] 作为 $tag): ?> 我想在树枝视图中转置它 知道...

回答 0 投票 0

Twig 模板数组按日期/时间排序

{% 如果 userNotifications 和 userNotifications|length > 0 %} {% 用于 userNotifications %} 中的通知 {% if userNotifications and userNotifications|length > 0 %} {% for notification in userNotifications %} <a href="#!" class="list-group-item list-group-item-action"> <div class="row align-items-center"> <div class="col ml--2"> <div class="d-flex justify-content-between align-items-center"> <div> <h4 class="mb-0 text-sm" style="color:#000;">{{ notification.type}}</h4> </div> <div class="text-right text-muted"> <small>{{ hours_ago(notification.notificationDate) }}</small> </div> </div> <p class="text-sm mb-0">{{ notification.message}}</p> </div> </div> </a> {% endfor %} {% endif %} 我想按最新排序这些通知,目前它首先显示最旧的通知。 例子: 通知;- 11 小时前 4小时前 2小时前 我想展示喜欢 通知;- 2小时前 4小时前 11 小时前 我曾尝试使用 Twig 文档中的排序功能,但失败了。 $asColumns = array(); $select = "SELECT"; $from = "FROM `notification` n"; $joins = ""; $groupBy = ""; $sqlWhere = $sqlWhere; $orderBy = ""; $limit = ""; foreach($columns as $key => $column) { $select .= ($key > 0 ? ', ' : ' ') . $column[1] . (isset($column[2]) ? ' AS ' . $column[2] : ''); } /* * Ordering */ foreach($get['columns'] as $key => $column) { if($column['orderable']=='true') { if(isSet($get['order'])) { foreach($get['order'] as $order) { if($order['column']==$key) { $orderBy .= (!empty($orderBy) ? ', ' : 'ORDER BY ') . $columns[$key][0] . (!empty($order['dir']) ? ' ' . $order['dir'] : ''); } } } } }

回答 0 投票 0

Shopware 6 中的类别描述是如何呈现的

这个问题可能看起来很模糊,但我知道如何使用 TWIG。目前,我正在尝试扩展 Shopware 6 店面中的类别页面,特别是类别描述部分。但是...

回答 0 投票 0

PHP 我可以使用可变变量访问数组键吗?

我有一个包含一些信息的数组,但我正在尝试实现一种使用可变变量动态访问数组的方法,但我不知道如何,因为 php 解释整个字符串是一个变量...

回答 0 投票 0

Symfony 6:如何定义第三方包 twig ux 组件

我需要在我自己的供应商包中制作一个 symfony UX 组件。 有组件,在应用程序级别按需要工作: 我需要在我自己的供应商包中制作一个 symfony UX 组件。 有组件,在应用程序级别按需要工作: <?php namespace App\Components; use Knp\Component\Pager\PaginatorInterface; use Mysterty\CoreBundle\Repository\PostRepository; use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; #[AsTwigComponent('latest_posts', template: '@MystertyCore/Core/_latest_posts.html.twig')] class LatestPostComponent { private PostRepository $postRepository; private PaginatorInterface $paginator; public function __construct(PostRepository $postRepository, PaginatorInterface $paginator) { $this->postRepository = $postRepository; $this->paginator = $paginator; } public function getPaginatedPosts() { $query = $this->postRepository->getOrdered(); $pagination = $this->paginator->paginate($query, 1, 3); return $pagination; } } 如果我按如下方式在My/Bundle/src/Components中移动它,它会崩溃,除非我设置服务并将我的组件定义为AbstractController: #My/CoreBundle/config/services.yaml services: My\CoreBundle\Components\LatestPostComponent: public: true autowire: true autoconfigure: true tags: - "controller.service_arguments" - "container.service_subscriber" <?php namespace Mysterty\CoreBundle\Components; // […] #[AsTwigComponent('mty_latest_posts', template: '@MystertyCore/Core/_latest_posts.html.twig')] class LatestPostComponent extends AbstractController { // […] } 但是,它看起来很乱。这真的是正确的做法吗?

回答 0 投票 0

致命错误:未捕获的类型错误:传递给 Blog\Database::__construct() 的参数 1 必须是字符串类型,给定的布尔值,调用了

致命错误:未捕获的类型错误:传递给 Blog\Database::__construct() 的参数 1 必须是字符串类型,给定的布尔值,在 C:\OSPanel\domains\Php-blog-project endor\php-di 中调用\php-di\src\

回答 0 投票 0

Twig - 动态替换 GET 参数的值

有没有办法从树枝中替换 GET 参数值? 例如,我在这个地址有一个页面: http://localhost/app_dev.php/test/?param1=40&sort=name 在我的树枝上,我想建造 3

回答 3 投票 0

shopware 6 twig 在另一个块子 div 内添加块

我想知道shopware 6中是否有解决这个问题的方法。许多块都有一些子元素。例如。如果我想在结帐时添加一个复选框,我需要替换整个块。 ...

回答 1 投票 0

为什么我的表单在使用 render_esi Symfony 6 时没有被提交

我正在 symfony 6 中为搜索功能制作一个控制器,然后使用“render_esi”方法从我的模板中调用它。 模板正在渲染表单,但是当我点击 ...

回答 1 投票 0

我可以使用 Github Codespaces 进行外部登录吗?

我正在与一个使用 Salla 平台的客户一起开发一个项目,基本上就像 Shopify 使用 twig 模板引擎来运行服务器我需要安装 SallaCli,但我无法安装 loc...

回答 0 投票 0

在电子邮件模板 TWIG 中获取完整的 url

我正在使用 Symfony 6 开发一个应用程序,我安装了重置密码包。除了我收到要求更改密码的电子邮件外,一切都运行良好。 TWIG 中的重定向 v...

回答 1 投票 0

如何在 CraftCMS 中的嵌套条目的 URI 之前包含不同的段

我正在使用 CraftCMS 制作网络漫画。我有一个带有两个类型句柄(系列、单个)的结构部分,我想在嵌套条目的 URI 之前包含一个不同的段,如下所示: T...

回答 0 投票 0

php symfony 展示分类及相关产品

我正在使用 Symfony 6 和 PHP 构建网站。我有 2 个实体:与 ManyToOne 相关的产品和类别(每个类别都有很多产品)。 我想获取所有类别并显示每个类别...

回答 2 投票 0

Shopware 6 override twig block 插件

我安装了一些插件。我想覆盖文件 vendor/store.shopware.com/netinextstorelocator/src/Resources/views/storefront/

回答 0 投票 0

带排序的循环中的动态字段?

例如,我有一个实体 Cup(来自 Doctrine),其属性为:name、nameBis 我想按名称或 nameBis 对这个列表进行排序: {% for cup in cups|sort((a, b) => a.name <=> b.n...

回答 0 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.