function getArticleRoute

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
User avatar
THE_AI
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Sat Jun 03, 2006 4:33 pm
Contact:

function getArticleRoute

Post by THE_AI » Tue Feb 26, 2008 9:25 pm

Hey there!
I'm trying to use the getArticleRoute function (com_content/helpers/route.php) to make SEF urls.

I have some success, but not really what I want to do.

For example on front page you have a link like this:
xxxx/the-news/1-latest-news/6-we-are-volunteers.html

My link looks like this:
xxxx/the-news/1/6.html

Why is that? I'm giving the right catid and section id to getArticleRoute. Is there something else that should be done?

Code: Select all

JLoader::import('components.com_content.helpers.route',$mosConfig_absolute_path);

$url = JRoute::_(ContentHelperRoute::getArticleRoute($contentId, $this->catid, $this->sectionid)

Well, now I will try to develop extensions :)

User avatar
THE_AI
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Sat Jun 03, 2006 4:33 pm
Contact:

Re: function getArticleRoute

Post by THE_AI » Sun Mar 23, 2008 4:18 pm

I have the feeling I'm too stupid to make this.

I'm writing a search plugin and I want to make the url SEO friendly.

I looked how the content search plugin is made and there we have:

Code: Select all

 require_once(JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
and later

Code: Select all

$list[$key]->href = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid);
So I decided to make the same:

Code: Select all

 require_once(JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
and later:

Code: Select all

$rows[$key]->href = ContentHelperRoute::getArticleRoute($row->contentid, $row->catid, $row->sectionid);
where:
$row->catid is the categoryid from jos_content and sectionid is the sectionid from jos_content.

I thought that I will get a nice url, but that is not the case.
My URL looks like:
/index.php/the-news/1/6.html
and joomla's one look like:
/index.php/about-joomla/31-general/25-what-are-the-requirements-to-run-joomla-15.html

Why are my category and section not changed to text, but stay numbers????
Please anyone!
Well, now I will try to develop extensions :)


Post Reply