ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Help: How to grab the URL of the current displayed page

March 10, 2008 4:15am

Subscribe [4]
  • #1 / Mar 10, 2008 4:15am

    An Aussie

    18 posts

    Hi Gang,

    Just a quick little question. Is there a tag that grabs the full URL of the current displayed page and then prints it out in the footer of site?

    I have looked through globals in the docs and it seems there isn’t…or, I am missing it somewhere…

    Thanks guys.

  • #2 / Mar 10, 2008 5:08am

    Mark Bowen

    12637 posts

    Hiya,

    There are a couple of ways you could do this. The first being you could use the {homepage} variable combined with {segment} variables to get what you need. That might be a bit messy in your template though but would probably work.

    Another way would be using the fetch_current_uri() function from the functions class. You would need to make a simple plugin that would do this for you and it would just fetch the page URI and then spit it out to the page.

    fetch_current_uri()

    Returns uri for current page.
    Class: Functions (FNS)
    Description: Returns the full URI for the current page. Occassionally, used in forms when a return location is not set by default.

    There is also the tracker array in the session class which would do what you need but only once the person has been to at least one page.

    If you can wait until a little later today then I can create a plugin for you if you like unless you know how to create your own?

    Hope some of that helps?

    Best wishes,

    Mark

  • #3 / Mar 10, 2008 5:29am

    An Aussie

    18 posts

    Hi Mark,

    Thanks for your replay mate. Hmm, I cant program a rats tail so your offer to create a plugin is much appreciated!

  • #4 / Mar 10, 2008 5:33am

    Mark Bowen

    12637 posts

    Here you go! As promised a plugin that will simply retrieve the URI of the current page and then spit out the text for you.

    Hope it’s what you need?

    Usage :

    Simply place the following plugin tag in to your template where you would like to display the URI :

    {exp:fetch_current_uri}

    This will then output the text showing the current page URI.

    Hope that helps?

    Best wishes,

    Mark

  • #5 / Mar 10, 2008 5:42am

    Mark Bowen

    12637 posts

    Just in case you need it - the plugin page in the forum is here.

    Best wishes,

    Mark

  • #6 / Mar 10, 2008 5:48am

    An Aussie

    18 posts

    You…have…got…to…be…kidding…me!  😊

    Good lord I thought you would be flat out and may not have time to do this but its like 20 minutes and you have very kindly done it already. Thanks again Mark, it is very much appreciated! The site is almost complete now on my local machine and this is the icing on the cake. Works perfectly!

  • #7 / Mar 10, 2008 5:53am

    Mark Bowen

    12637 posts

    You…have…got…to…be…kidding…me!  😊

    We try out best to please around here 😉

    Actually it was a bit quicker than 20 minutes. The plugin was written in literally 3 minutes but I had to feed the cats and do a few other things etc 😉

    Let us all see your site when it is finished with if you are able to?

    Best wishes,

    Mark

  • #8 / Mar 10, 2008 6:03am

    An Aussie

    18 posts

    “We try our best o please around here 😊”—heh, will you sure as done that mate. Will do re my site, it isn’t flash or anything, just a place to call home online. Will let you know when it goes live in a few days. Thanks again…

  • #9 / Mar 10, 2008 6:19am

    Mark Bowen

    12637 posts

    No problems. I might add in a few more features to the plugin when I get a chance so maybe keep an eye on the plugin thread referenced above.

    Best wishes,

    Mark

  • #10 / Mar 10, 2008 6:41am

    Mark Bowen

    12637 posts

    Well I have fed the cats now and got everything else pretty much out of the way for the day so thought I would go ahead and add in the extra features as promised 😉

    If you check out the Fetch Current URI plugin page then you should see what I have done 😉

    Hope it helps.

    Best wishes,

    Mark

  • #11 / Jan 19, 2010 11:02am

    The EE community strikes once again. I’ve been wracking my brains with how to have the URL of the current page in the page’s source/head section.

    Downloaded the plugin. Uploaded. Added the tag to my header template.

    Sorted! Thank you very much Mark, really appreciate it. :D

  • #12 / Jan 19, 2010 11:27am

    Mark Bowen

    12637 posts

    Hiya,

    The EE community strikes once again. I’ve been wracking my brains with how to have the URL of the current page in the page’s source/head section.

    Downloaded the plugin. Uploaded. Added the tag to my header template.

    Sorted! Thank you very much Mark, really appreciate it. :D

    Absolutely no problem at all. Glad it was of help to you.

    Best wishes,

    Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases