Get custom advanced parameter from article in my module in Joomla
I have a small news module on the home page in my website. It shows the news articles added from the Joomla admin.
It shows the article title in the module section.
But I do not want to show article title in the news module on the home page. I need to show some other text in the news module instead of the news title.
For this I have added a new custom parameter called "News title" in the article manager.
This new custom parameter is getting saved and updated properly with the other article content.
But I am having problems while retrieving the value of this custom parameter in the news module.
Below is the code which is used to get the title of the article in the module.
// getting content
$this->content = $newsClass->getNewsStandardMode($categories, $sql_where, $this->config, $this->config['news_amount']);
//
$this->SIDTab = $this->content['SID'];
$this->titleTab = $this->content['title'];
$this->textTab = $this->content['text'];
$this->idTab = $this->content['ID'];
$this->cidTab = $this->content['CID'];
Below is my code used to show article title.
function render(&$params)
{
$content = array();
//
for($i = 0; $i < count($this->idTab); $i++)
{
$content[$i] = '';
//
if($this->config['links'] == 1)
{
$url = $this->idTab[$i].'&Itemid='.$this->config['item_id'];
if ($this->config['url'] != ""){
$content开发者_开发技巧[$i] .= '<a href="'.$this->config['url'] .'">';
} else {
$content[$i] .= '<a href="'.JRoute::_(ContentHelperRoute::getArticleRoute($url, $this->cidTab[$i], $this->SIDTab[$i])).'">';
}
}
// some more code }
Please help.
Thanks.
When the module is getting the parameters, it is pull the module parameters, not the parameters from the article. The parameters for the article are stored in the attributes fields in the jos_content table. You'll need to get your text from there.
There is an easier way to do this without hacking the core. I noticed that you do not have any intro text in your article. It would be much easier to put the text you want to use at the beginning of the article content and insert a read more break after it. Now the text you want will be processed as intro text by Joomla. You can set it to display in the module and to be hidden in the article view. This prevents you from having to hack the core so you can update easily and should make it easier to display the content you want.
精彩评论