问题
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