irislines web design
irislines web design

display current url (for print stylesheet?)

I needed to create a print-only header  that would include the full url of the current page, so that we could be sure that users would print the full url of the page (and not depend on browser settings)

 

This solution found at forum.joomla.org in a post by

Kevin Florida
Project Manager
Florida Host Web, Inc.
www.floridahostweb.com

Thanks, Kevin!

Create a variable for the current page.

the baseurl() only finds the base url, you want the current() function.

Let’s say you are on a page: http://www.mysite.com/widgits/red_widgits

You can get the Web site url with JURI::baseurl() like so:
Create a variable, then set it equal to the Joomla function:
$baseurl = JURI::base();

Now when you:
echo $baseurl;

It will display this:
http://www.mysite.com/

——————————————————
But you want the current absolute path url, correct? So do this instead:

Get the current absolute url with JURI::current() like so:
Create a variable, then set it equal to the Joomla function:
$currenturl = JURI::current();

Now when you:
echo $currenturl;

It will display this:
http://www.mysite.com/widgits/red_widgits

 

Tags: ,

IrisLines LLC
101 Washington Street
Brattleboro, VT 05301

802 257 7391

info@irislines.com