How to get parameters from article's custom field?

ぃ、小莉子 提交于 2019-12-12 02:17:03

问题


I have some custom field for artciles. For example this is text field named "MyText".

I tryin' to write simple plugin, wich will be display text from this field on article's page (frontend). So how can I get value from this field and transfer it to plugin?

Joomla version is 2.5

Thanks in advance for everybody.

This is field in XML:

<field name="MyText" type="inputbox"
            label="MyText"
            description=""
            class="inputbox" size="25"
        />

回答1:


Ok! Finally I wrote it by myself. So here is solution:

 public function onContentAfterDisplay($context, &$row, &$params, $page = 0)
{
    $articleId = (JRequest::getVar('option')==='com_content' && JRequest::getVar('view')==='article')? JRequest::getInt('id') : 0;
    $article =& JTable::getInstance('content');
    $article->load($articleId);

    $art_attribs = new JParameter($article->attribs);
    $mytext = $art_attribs->get('MyText');

    echo $mytext;
}


来源:https://stackoverflow.com/questions/36162049/how-to-get-parameters-from-articles-custom-field

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!