Goog day!
I'm write custom RSS-channel that will use a mobile application for reading news from my site. As the data source I'm used K2 installed on Joomla 2.5.6.
At this moment I'm write a class that returns a link to an article without SEF, for example:
- index.php?option=com_k2&view=item&id=4774:poshlinu-na-kombayny-ppiostanovili&Itemid=354
But would like to have such a link:
- /economics/customs-union/4774-poshlinu-na-kombayny-ppiostanovili.html
Thanks for your help.
I'm write custom RSS-channel that will use a mobile application for reading news from my site. As the data source I'm used K2 installed on Joomla 2.5.6.
At this moment I'm write a class that returns a link to an article without SEF, for example:
- index.php?option=com_k2&view=item&id=4774:poshlinu-na-kombayny-ppiostanovili&Itemid=354
But would like to have such a link:
- /economics/customs-union/4774-poshlinu-na-kombayny-ppiostanovili.html
Thanks for your help.
class RssModel extends JApplicationWeb
{
public function __construct(JInput $input = null, JRegistry $config = null, JWebClient $client = null)
{
parent::__construct($input, $config, $client);
$this->execQuery();
}
public $ObjectList;
protected function execQuery()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('items.id, items.alias, items.created, items.introtext, items.fulltext, items.title')
->select('cat.id as catid, cat.alias as catalias, cat.name as catname', ', ')
->select('usr.name as username, usr.email as useremail', ', ');
$query->from('#__k2_items as items')
->leftJoin('#__k2_categories as cat on items.catid = cat.id')
->leftJoin('#__users as usr on items.created_by = usr.id');
$query->where('items.created_by != 55 AND items.created_by != 42')
->where('items.published = 1 AND items.trash = 0', 'AND')
->where('cat.published = 1 AND cat.trash = 0', 'AND')
->where('(TO_DAYS(NOW()) - TO_DAYS(items.created)) <= 2', 'AND');
$query->order('items.created desc');
$db->setQuery($query);
$this->ObjectList = $db->loadObjectList();
}
protected $domain;
public function getLink($item, $domain = 'http://localhost/')
{
$this->domain = $domain;
$article = (iconv_strlen($item->alias)) ? $item->id.':'.$item->alias : $item->id;
$category = (iconv_strlen($item->catalias)) ? $item->catid.':'.$item->catalias : $item->catid;
return htmlspecialchars(
$domain.K2HelperRoute::getItemRoute($article, $category), ENT_QUOTES, 'UTF-8');
}
}