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


I am creating a custom component in Joomla which requires the user to send mail. I use the model to send mail from Backend Admin. The model uses this code:

  $ btn_link = JURI :: root (). Substr (JRoute :: _ ("index.php? Option = com_mymailer and views = message & email = {$ MyMsg- & gt; email} & amp; tid = {$ myMsg- & gt; ticket_id}");   

Then I use the above link as an anchor on an email button and send JMAIL. However, the link that comes in is a non-CEF (as on backend SEF is not applicable). I get this link:

  http://testsite.com/index Php? Option = com_mymailer & view = message & amp; email = mytestmail @ Gmail.com & amp; tid = 27   

While I think the result (in one Is present, named as mail): http://testsite.com/mails/messages/index.php?email=mytestmail@gmail.com&tid=27 < / Code>

Any body has an idea how to get the SEF frontend url from backend code. Thanks in advance.

I know that this is quite old but this is the first (relevant) result on Google. So you need a site (frontend) ro uterus and an item id id just so much. J! 2.5

  // Obtain the foreground application to create the whole item series $ siteApp = JApplication :: getInstance ('site'); // Now you have the frontend $ siteRouter = $ siteApp-> Can use router for getRouter (); // Get the item you want // You can see the frontend menu object $ siteMenu = $ siteApp-> Can use getMenu (); // You need the right item in your URL $ correctly / * There is a little bit disturbing, maybe it is with Jammu :: Route, still it still uses the admin subdidder, It may be better to check whether it is at the beginning of the string but now it is your business / $ sefURI = str_replace ('/ administrator', NULL, $ siteRouter- & gt; Build ($ yourUri) );    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -