Sunday, 15 February 2015

php - Joomla obtain SEF Frontend URL from a model in backend -



php - Joomla obtain SEF Frontend URL from a model in backend -

i making custom component in joomla needs send mail service user. utilize model send mail service backend admin section. model uses code :

$btn_link = juri::root().substr(jroute::_("index.php?option=com_mymailer&view=messages&email={$mymsg->email}&tid={$mymsg->ticket_id}");

then utilize above link anchor on button on email body , send through jmail. link arrives non-sef 1 (as sef not applicable on backend). link :

http://testsite.com/index.php?option=com_mymailer&view=messages&email=mytestmail@gmail.com&tid=27

whereas result want (a menu nowadays named mails):

http://testsite.com/mails/messages/index.php?email=mytestmail@gmail.com&tid=27

do body have thought how sef frontend urls backend code. in advance.

i know it's quite outdated it's first (relevant) result on google. need site (frontend) router , itemid. that's all. j!2.5

//get frontend application create total object chain $siteapp = japplication::getinstance('site'); //now can utilize router frontend $siterouter = $siteapp->getrouter(); //get itemid wish //you can utilize frontend menu object $sitemenu = $siteapp->getmenu(); //you need right itemid in $youruri route correctly /* there's little glitch, maybe juri::root still uses admin subdir anyways, remove it. maybe improve check if it's @ origin of string it's business */ $sefuri = str_replace('/administrator',null,$siterouter->build($youruri));

php joomla

No comments:

Post a Comment