我正在编辑blog_item.php的布局,我想用以下内容包装图像:
<a href="<?php echo $this->params->get('link_A'); ?>"><img...
但我似乎无法找到正确的语法来访问文章选项的值。我搜索了无用的Joomla文档,并通过谷歌,但没有aveil。有人能指出我正确的方向吗?
我试过了:
<?php echo $this->params->get('link_a'); ?>
<?php echo $this->params->get('link_A'); ?>
<?php echo $images->link_a; ?>
<?php echo $images->link_A; ?>
<?php echo $links->link_a; ?>
...etc, etc
答案 0 :(得分:3)
首先,我希望您使用a template override而不是修改核心文件。
blog_item.php
中访问的项目存储在数组$this->items
中,每次调用tmpl
文件blog_item.php
时,当前项$this->item
包含当前的文章对象。
您要查找的网址在$this->urls
中,其中包含JSON格式的数据,图片数据包含在$this->images
中(也是JSON格式)。
例如,图片和网址中的数据可能如下所示:
$this->images =
{"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
$this->urls =
{"urla":"http:\/\/example.com","urlatext":"CPPL","targeta":"","urlb":"http:\/\/example2.com","urlbtext":"Home of Fine Joomla! Products","targetb":"","urlc":null,"urlctext":"","targetc":""}
要使用它们,只需使用json_decode()
就像这样:
$urls = json_decode($this->item->urls);
echo $urls->urla;
echo $urls->urlatext;