Menu Content

Support

> Forums, FAQs & Paid Support
Welcome, Guest
Username Password: Remember me

How to convert links in ajax page with JoomSEF?
(1 viewing) (1) Guest
Support forum for users using free edition of JoomSEF 3 (Joomla 1.5 compatible). These forums are mainly for mutual help between users.

Please note that due to our capacity limitations, we do not monitor these forums regularly.
  • Page:
  • 1

TOPIC: How to convert links in ajax page with JoomSEF?

How to convert links in ajax page with JoomSEF? 14 years, 1 month ago #15203

I'm using Joomla 1.5.20 and JoomSEF 3.7.4.

Below are the codes for the ajax page layout in my custom component:

 
<php>
ob_clean();
</php>
<php>
foreach ($this->List as $record) {
</php>
<tr>
<td valign="top">
<a href="index.php?option=com_custominfo&view=record&id=
<php>
echo $record->id;
</php>
&Itemid=53"
class="recordHyperLink">
<php>
echo $record->firstname.' '.$record->lastname;
</php>
</a>
</td>
</tr>
<php>
}
</php>
<php>
exit();
</php>
 


The links in this page haven't converted by JoomSEF because of "exit()" at the end.

Could anyone tell me how to convert the links shown in this page with JoomSEF before "exit()"?

Thanks a lot ~~~

Best Regards,
Michael Wai
Last Edit: 14 years, 1 month ago by michaelw.

Re:How to convert links in ajax page with JoomSEF? 14 years, 1 month ago #15269

I've solved my problem myself, although it may not be the best solution.

In my ajax page (default.php inside tmpl), first create JoomSEF router object:

 
// create JRouterJoomsef object if JoomSEF is installed
if (class_exists('JRouterJoomsef')) {
$jRouterJoomsef = new JRouterJoomsef();
} else {
// no JoomSef installed
$jRouterJoomsef = null;
}
 


Then before you paste the link to HTML A tag,

 
$link = 'index.php?option=com_custominfo&view=record&id='.$record->id;
if (null != $jRouterJoomsef) {
// JoomSEF installed and published
$link = $jRouterJoomsef->build($link)->getPath();
}
 


If you installed and published the JoomSEF, the JRouterJoomsef object should be created. Then you can use its function build() to return JURI object, then use JURI's getPath() function to paste the sef'ed path.

Hope this help, thanks.

Best Regards,
Michael Wai
Last Edit: 14 years, 1 month ago by michaelw.

Re:How to convert links in ajax page with JoomSEF? 14 years, 1 month ago #15285

  • dajo
  • OFFLINE
  • Posts: 5069
Hello,

You can use the Joomla's JRoute::_() function like this:
$link = JRoute::_('index.php?option=com_custominfo&view=record&id='.$record->id);

It will handle the SEF properly depending on your configuration.

Best regards,
ARTIO Support Team
ARTIO Support Team

Re:How to convert links in ajax page with JoomSEF? 14 years, 1 month ago #15312

Thanks David.

It's really simple (just one function call) to let JRoute take care about SEF.

Thanks again for David your great help ~

Best Regards,
Michael Wai
www.waimichael.idv.hk
  • Page:
  • 1
User Login Empty