简体   繁体   English

如何在标签Joomla中获取属性

[英]how to get attribs in tags Joomla

For extra data fields used in Joomla: 对于Joomla中使用的其他数据字段:

<?php
    $attribs = new JRegistry($this->item->attribs);
    echo $attribs->get('extrafield_name');
?>

or 要么

<?php echo $params->get('extrafield_name'); ?>

I tried the same thing, to display extra fields of com_content in com_tags . 我尝试了同样的事情,以在com_tags显示com_contentcom_tags字段。 as I can fix that. 我可以解决这个问题。 Thank you for your help. 谢谢您的帮助。

Situation before this change: I have a couple of custom fields added to my article using the same technique as described here: https://zunostudios.com/blog/development/203-how-to-add-custom-fields-to-articles-in-joomla I then made a menu item of the type "tagged items" and tried to override the joomla default template for the tagged items list, which I found under components/com_tags/views/tag/tmpl/default_items.php However the attribs are not available in $item (line 35 and ongoing) 更改之前的情况:我使用与此处所述相同的技术将一些自定义字段添加到我的文章中: https : //zunostudios.com/blog/development/203-how-to-add-custom-fields-to-然后,我在joomla中创建了一个菜单类型为“标签项”的菜单项,并尝试覆盖标签项列表的joomla默认模板,该模板在components / com_tags / views / tag / tmpl / default_items.php下找到。 attrib在$ item中不可用(第35行,正在进行中)

Situation after this change: The query which returns the items of the "tagged items" now also returns the attribs. 更改后的情况:返回“已标记项目”的项目的查询现在也返回属性。 And one can use something like this to use the attribs in the tagged items list: $attrb = json_decode($item->attribs); 可以使用类似的方式在已标记项目列表中使用属性:$ attrb = json_decode($ item-> attribs); echo $attrb->foo; echo $ attrb-> foo;

I hope I didn't break anything - this is my first patch to the joomla project, so I'm happy to hear your feedback and improve my solution. 我希望我什么都没破坏-这是我对joomla项目的第一个补丁,因此,我很高兴听到您的反馈并改善我的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM