Joomla JURI examples

I usually need to use methods of Joomla’s JURI class. And I always switch JURI::base() with JURI::root() and I always have the problem how to get current URL. So I wrote this post to make clear which method does what. I hope I save time to myself in the future, maybe someone else ass well. And maybe, I finally memorize it but I don’t give much hope to this one. I explain it at this website URL to make it clear.

JURI::base()

JURI::base() returns string ‘http://themevina.com/’ at frontend and ‘http://themevina.com/administrator/’ at backend.

JURI::base(true) returns empty string ” at frontend and string ‘/administrator’ at backend.

Documentation: http://docs.joomla.org/JURI/base

 

JURI::root()

This is the right answer to often asked question “how to get the domain?”.

JURI::root() returns string ‘http://themevina.com/’ at frontend and ‘http://themevina.com/’ at backend as well.

Documentation: http://docs.joomla.org/JURI/root

 

JURI::current()

This is tricky method. At documentation is written “returns the current request URI without the query or fragment parts”. Example:

If you are at https://www.themevina.com/en/blog:

JURI::current() returns string ‘https://www.themevina.com/en/blog’

If you are at https://www.themevina.com/administrator/index.php?option=com_content&view=article&layout=edit&id=106

JURI::current() returns string ‘https://www.themevina.com/administrator/index.php’.

Documentation: http://docs.joomla.org/JURI/current
If you want to get the real current URL……with the query and fragment, use this:

JURI::getInstance()->toString();

that returns string ‘https://www.themevina.com/administrator/index.php?option=com_content&view=article&layout=edit&id=106’ for the example above.

Documentation: http://docs.joomla.org/JURI/toString

Share this :

Comments are closed.

Related post

Free Responsive Website templates

ThemeVina is Best site for free sharing and download Wordpress themes, Joomla templates, Responsive website templates and more HTML templates.

All template in Site are free. You can download and install for your site.

Contact us

  • Brand: Theme Vina
  • Email: admin@themevina.com
  • Website: www.themevina.com
  • Address: 367 Tran Hung Dao Street
  • Location: Thai Binh City, Thai Binh, Viet Nam

Newsletter