如何从文章的自定义字段获取参数? [英] How to get parameters from article's custom field?

查看:48
本文介绍了如何从文章的自定义字段获取参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对关节有一些定制领域.例如,这是一个名为"MyText"的文本字段.

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版本为2.5

Joomla version is 2.5

在此先感谢大家.

这是XML中的字段:

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

推荐答案

好!最后我自己写了.所以这是解决方案:

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;
}

这篇关于如何从文章的自定义字段获取参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆