- Posts: 22
COMMUNITY FORUM
rss author
- politicaldoubts
-
Topic Author
- Offline
- Junior Member
Less
More
8 years 1 month ago #160998
by politicaldoubts
rss author was created by politicaldoubts
Hallo everybody
I want to add the author (or the author alias) of an item to rss feed , cause i need it for facebook instant articles.
How i can do it? Which file i must override?
I want to add the author (or the author alias) of an item to rss feed , cause i need it for facebook instant articles.
How i can do it? Which file i must override?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 1 month ago #161021
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic rss author
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 1 month ago #161022
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic rss author
Another approach would be to use the JSON feed instead
www.joomlaworks.net/blog/item/264-tabs-sliders-has-a-new-home?format=json
www.joomlaworks.net/blog/item/264-tabs-sliders-has-a-new-home?format=json
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- politicaldoubts
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 22
8 years 1 month ago #161024
by politicaldoubts
Replied by politicaldoubts on topic rss author
I found a solution for making k2 rss feed more compatible with facebooks instant articles.
All you need to do is to configure some elements in the file com_k2/models/item
For the author you must find this part and add the lines
$item->description .= '<address>'.$item->author->name.'</address>';
and
$item->description .= '<address>'.$item->author->name.'</address>';
i add the <address> cause thats what FB need to grab the autor.
So the authors part will look like
//Author
if (!empty($item->created_by_alias))
{
if(!isset($item->author))
{
$item->author = new stdClass;
}
$item->author->name = $item->created_by_alias;
$item->author->email = '';
$item->description .= '<address>'.$item->created_by_alias.'</address>';
}
else
{
$author = JFactory::getUser($item->created_by);
$item->author = $author;
$item->author->link = JRoute::_(K2HelperRoute::getUserRoute($item->created_by));
$item->author->profile = $this->getUserProfile($item->created_by);
$item->description .= '<address>'.$item->author->name.'</address>';
}
All you need to do is to configure some elements in the file com_k2/models/item
For the author you must find this part and add the lines
$item->description .= '<address>'.$item->author->name.'</address>';
and
$item->description .= '<address>'.$item->author->name.'</address>';
i add the <address> cause thats what FB need to grab the autor.
So the authors part will look like
//Author
if (!empty($item->created_by_alias))
{
if(!isset($item->author))
{
$item->author = new stdClass;
}
$item->author->name = $item->created_by_alias;
$item->author->email = '';
$item->description .= '<address>'.$item->created_by_alias.'</address>';
}
else
{
$author = JFactory::getUser($item->created_by);
$item->author = $author;
$item->author->link = JRoute::_(K2HelperRoute::getUserRoute($item->created_by));
$item->author->profile = $this->getUserProfile($item->created_by);
$item->description .= '<address>'.$item->author->name.'</address>';
}
Please Log in or Create an account to join the conversation.
- politicaldoubts
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 22
8 years 1 month ago #161025
by politicaldoubts
Replied by politicaldoubts on topic rss author
i also made some changes to other elemens. for example i created a <header> and an <article> element.
i grab introtext in my new <header> with an <h2> so the facebook can grab it as a subtitle.
now the part i need for instant articles look like this and it works perfect!!!
IMPORTANT! your fulltext must have <p> elements, not <div>, otherwise facebook will not grab your fulltext!
//Item image
if ($params->get('feedItemImage') && JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_'.$params->get('feedImgSize').'.jpg'))
{
$altText = $item->image_caption ? $item->image_caption : $item->title;
$item->description .= '<article><header><div class="K2FeedImage"><img src="'.JURI::root().'media/k2/items/cache/'.md5('Image'.$item->id).'_'.$params->get('feedImgSize').'.jpg" alt="'.$altText.'" /></div>';
}
//Item Introtext
if ($params->get('feedItemIntroText'))
{
//Introtext word limit
if ($params->get('feedTextWordLimit') && $item->introtext)
{
$item->introtext = K2HelperUtilities::wordLimit($item->introtext, $params->get('feedTextWordLimit'));
}
$item->description .= '<h2>'.$item->introtext.'</h2>';
}
//Author
if (!empty($item->created_by_alias))
{
if(!isset($item->author))
{
$item->author = new stdClass;
}
$item->author->name = $item->created_by_alias;
$item->author->email = '';
$item->description .= '<address>'.$item->created_by_alias.'</address></header>';
}
else
{
$author = JFactory::getUser($item->created_by);
$item->author = $author;
$item->author->link = JRoute::_(K2HelperRoute::getUserRoute($item->created_by));
$item->author->profile = $this->getUserProfile($item->created_by);
$item->description .= '<address>'.$item->author->name.'</address></header>';
}
//Item Fulltext
if ($params->get('feedItemFullText') && $item->fulltext)
{
$item->description .= ''.$item->fulltext.'</article>';
}
i grab introtext in my new <header> with an <h2> so the facebook can grab it as a subtitle.
now the part i need for instant articles look like this and it works perfect!!!
IMPORTANT! your fulltext must have <p> elements, not <div>, otherwise facebook will not grab your fulltext!
//Item image
if ($params->get('feedItemImage') && JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_'.$params->get('feedImgSize').'.jpg'))
{
$altText = $item->image_caption ? $item->image_caption : $item->title;
$item->description .= '<article><header><div class="K2FeedImage"><img src="'.JURI::root().'media/k2/items/cache/'.md5('Image'.$item->id).'_'.$params->get('feedImgSize').'.jpg" alt="'.$altText.'" /></div>';
}
//Item Introtext
if ($params->get('feedItemIntroText'))
{
//Introtext word limit
if ($params->get('feedTextWordLimit') && $item->introtext)
{
$item->introtext = K2HelperUtilities::wordLimit($item->introtext, $params->get('feedTextWordLimit'));
}
$item->description .= '<h2>'.$item->introtext.'</h2>';
}
//Author
if (!empty($item->created_by_alias))
{
if(!isset($item->author))
{
$item->author = new stdClass;
}
$item->author->name = $item->created_by_alias;
$item->author->email = '';
$item->description .= '<address>'.$item->created_by_alias.'</address></header>';
}
else
{
$author = JFactory::getUser($item->created_by);
$item->author = $author;
$item->author->link = JRoute::_(K2HelperRoute::getUserRoute($item->created_by));
$item->author->profile = $this->getUserProfile($item->created_by);
$item->description .= '<address>'.$item->author->name.'</address></header>';
}
//Item Fulltext
if ($params->get('feedItemFullText') && $item->fulltext)
{
$item->description .= ''.$item->fulltext.'</article>';
}
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 1 month ago #161036
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic rss author
Nice one, although my two cents on this would be to develop this into a separate plugin ;)
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.