作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在网站后端使用 Ionize cms,我想创建自己的标签 - 用于从我自己的表传递数据。我关注了This创建自定义标签的教程,然后将数据传递到 View ,但我不断收到错误:
标签缺失:演示,范围:.
这是我的观点:
<ul>
<ion:demo:details>
<li><ion:detail field="user_name" /></li>
</ion:demo:details>
</ul>
以下是我添加到 TagManager.php 的更改
public static $tag_definitions = array
(
// <ion:demo:authors /> calls the method “tag_details”
"demo:details" => "tag_details",
"demo:details:detail" => "tag_detail",
);
我还尝试创建一个简单的 codeigniter Controller 并使用 view() 传递数据并执行以下操作:
<ul>
<?php foreach($details as $detail): ?>
<li>
<?php echo $detail['name'] ?>
</li>
<?php endforeach ;?>
</ul>
但是我收到 $details
的未定义错误。
最佳答案
更改了标签,现在好了。
<?php
class TagManager_Data extends TagManager
{
public static $tag_definitions = array(
"authors" => "tag_authors",
"authors:author" => "tag_author",
);
public static function index(FTL_Binding $tag)
{
$str = $tag->expand();
return $str;
}
public static function tag_authors(FTL_Binding $tag)
{
$str = '';
$authors = [["name" => 'josh', "foo" => 'josh'], ["name" => 'joshjosh', "foo" => 'josh'], ["name" => 'josh', "foo" => 'josh']];
foreach($authors as $author) {
$tag->set('author', $author);
$str.= $tag->expand();
}
return $str;
}
public static function tag_author(FTL_Binding $tag)
{
$field = $tag->getAttribute('field');
if (!is_null($field)) {
$author = $tag->get('author');
if (!empty($author[$field])) {
return self::output_value($tag, $author[$field]);
}
return self::show_tag_error($tag, 'The attribute <b>"field"</b> is not set');
}
}
}
关于php - 如何使用 codeigniter 迭代 ionize-cms 中的数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44625105/
我是 Ionize CMS 领域的新手,我需要您的帮助。是否有可能使模块与第二个数据库一起使用?这个想法是创建两种类型的网站: 一个是数据库管理(有自己的数据库db1),其中添加/修改和删除内容。本站
我在网站后端使用 Ionize cms,我想创建自己的标签 - 用于从我自己的表传递数据。我关注了This创建自定义标签的教程,然后将数据传递到 View ,但我不断收到错误: 标签缺失:演示,范围:
我是一名优秀的程序员,十分优秀!