At the moment I am creating the links like this:
<?php
$url = "index.php?option=com_content&view=article&id=38-
remortgage";
$sef_url = JRoute::_( $url, $xhtml = true, $ssl=null );
?>
<a href="<?php echo $sef_url; ?>">Remortgage</a>
The article does appear when I click on the link, but the URL in the
browser address shows as:
http://<my_domain>/component/content/article?id=38-remortgage
I would like to get it to appear something like:
http://<my_domain>/component/content/article/38-remortgage
Can anyone tell me what I'm doing wrong that is causing the ?id=38-
remortgage query string to appear instead of it being pushed into the
path?
Many thanks,
Nick
I filed two tracker items before 1.6 was released as stable, but they
were closed without a comment. I also proposed a rewrite of the routing
system which would have fixed this for 2.5, but it was also rejected.
Hannes
Nanda Kishore. M
PHP Developer
Ph: + 91 98499 71144 (Cell)
--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To post to this group, send an email to joomla-...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-cm...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.
Thanks for your explanation and for helping. I changed the code as you
advised:
<?php
$url = ContentHelperRoute::getArticleRoute('5', '7');
//$url = "index.php?option=com_content&view=article&id=5-about-
us";
$sef_url = JRoute::_( $url, $xhtml = true, $ssl=null );
?>
<a href="<?php echo $sef_url; ?>">about us</a>
This time I see the value of $url become "index.php?
option=com_content&view=article&id=5&catid=7"
and $sef_url becomes "/component/content/article/7-about-us/5-about-
us".
If I revert back to the hard coded html link, but this time include
the catid and use just the id for the article and not its "slug", (ie
the form returned by ContentHelperRoute::getArticleRoute('5', '7')),
it gets transformed correctly (perhaps not surprisingly) by JRoute::_
as follows:
<?php
//$url = ContentHelperRoute::getArticleRoute('5', '7');
$url = "index.php?option=com_content&view=article&id=5&catid=7";
$sef_url = JRoute::_( $url, $xhtml = true, $ssl=null );
?>
<a href="<?php echo $sef_url; ?>">about us</a>
Since all articles have a unique id (ie their primary index) why does
the com_content router not deal with just an article id or slug
correctly. Is this the bug you refer to?
Again, thanks.
Nick
Hannes
Many thanks for taking the time to give your suggestion, I really
appreciate it. I did try this as well, but ultimately I will be
building hundreds of these links for selection in a custom module (My
clients SEO company want this). I didn't want to complicate this post
with those details.
Regards,
Nick
Out of interest, can you tell me why the com_content router doesn't
allow just an article id to be given? The content parser seems to have
code in it that would suggest it was intended to handle this
situation.
// if there is only one segment, then it points to either an article
or a category
// we test it first to see if it is a category. If the id and alias
match a category
// then we assume it is a category. If they don't we assume it is an
article
I don't plan for there to be a menu item ever. The intention is that
articles links will appear on most/all pages via a module and I want
the URL to be as short an SEF URL as possible as the articles are
purely for SEO and as we know, if an article can be made to look like
it is a page in the root directory Google et-al will tend to give it
higher weighting than one apparently in a sub directory or below.
Thanks,
Nick