访问 smarty 变量的名称
您好,我需要一些基本问题的帮助。这是我的代码:
{foreach $sArticle.attributes.core->toArray() as $attribute}
<tr class="product--properties-row">
<td class="product--properties-label is--bold">{$sArticle.attributes.name}{$sArticle.attributesName}</td>
<td class="product--properties-label is--bold">{$attribute}</td>
</tr>
{/foreach}
1.问题:如何输入属性名称?我的意思是数据库中属性的列名? 2.问题:我只想用 foreach 循环遍历 name="artikelattr_" 的列,知道如何做到这一点吗?
谢谢
Hello i need some help with a basic question. This is my code:
{foreach $sArticle.attributes.core->toArray() as $attribute}
<tr class="product--properties-row">
<td class="product--properties-label is--bold">{$sArticle.attributes.name}{$sArticle.attributesName}</td>
<td class="product--properties-label is--bold">{$attribute}</td>
</tr>
{/foreach}
1.Question: How do I enter the attributes name? I mean the column name from the attribute in the database?
2.Question: I only want to loop with the foreach through columns with name="artikelattr_" any idea how this can be done?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在这里调整了我的答案:https://stackoverflow.com/a/71237355/7201069
如何获取属性的名称。
要仅考虑以特定字符串开头的某些属性,只需在循环中添加
if
:您可以简单地使用 Smarty 中的几乎所有 PHP 函数。
I adjusted my answer here: https://stackoverflow.com/a/71237355/7201069
How to get the name of the attribute.
To consider only certain attributes that starts with a specific string, just add an
if
in the loop:You can simply use nearly all PHP functions in Smarty.