Hiya,
Just another exceptionally quick plugin in case anyone needs the functionality.
I was asked over in this thread how to fetch the current page URI and I had said that you could either use the {homepage} variable mixed in with {segment} variables or you could use the fetch_current_uri function or the tracker array session although this last one would only work once a person had been to one page first.
I’m hoping there isn’t an easier way that I have just overlooked. There might be as I didn’t really get any sleep last night due to the 54Kt winds we experienced here!!
Anyway, plugin attached to do just what it says on the tin and nothing more!!
Usage : V1.0 Simply place the following plugin tag in to your template where you would like to display the current page URI.That’s it!{exp:fetch_current_uri}
Usage: V1.0.2 Fetch the current page URI and render it to the template. Just place the following plugin tag on the page where you would like the page URI to be displayed.uri-only=”yes” or uri-only=”no” - If this parameter isn’t supplied then the plugin will create links along with the other parameters shown below. If supplied however then there are two values, yes and no which can be used. Using no is the same as omitting the parameter whereas yes will allow you to just return the current uri without turning it into a link. text=”Link Text” - text that displays on the page instead of the URI If you leave the text=”” parameter blank then it will instead place the URI in place of any text that you would have wanted! title=”My Title” - text that gets set in the link title (check source code on page) class=”css-class” - sets the class of the link id=”my-id” - sets the id of the link rel=”internal” - sets the rel for the link{exp:fetch_current_uri text="Link Text" title="My Title" class="css-class" id="my-id" rel="internal" uri-only="yes"}
Hope it helps some people out somewhere.
Best wishes,
Mark
Plugin now updated to V1.0.1 😉
Usage :
Place the following plugin tag in to your template where you would like to display the current page URI :
{exp:fetch_current_uri text="Link Text" title="My Title" class="css-class" id="my-id" rel="internal"}
text=”Link Text” - text that displays on the page instead of the URI If you leave the text=”“ parameter blank then it will instead place the URI in place of any text that you would have wanted!
title=”My Title” - text that gets set in the link title (check source code on page) class=”css-class” - sets the class of the link id=”my-id” - sets the id of the link rel=”internal” - sets the rel for the link
Hope that helps out a bit 😉 Updated plugin at top of thread.
Best wishes,
Mark
Thanks very much for this! Just like seajay, it came along at exactly the right time for me as well. Am using it successfully where I have to simply spit out the current url and use it in a hidden input in a form. (Using your first version without the fancy schmancy stuff you added later). Again, thank you!
Mark,
thanks for the plugin, simple but effective.
Now I just wished there would be an option for a plain URI output without the HTML anchor tag around at all. (In case you’re wondering: Used for a no-brain “tell your fiend via E-Mail” JS snipplet on a site where the “HTLM variant” is used as well. Of course I can modify your plugin accordingly, but I don’t like the idea to make an internal branch here.)
.Markus
Hi Markus,
Thanks for the kind words. Did you try downloading the pi.fetch_current_uri.php.zip plugin from the top post. I’m pretty sure that one should do what you are after. The one with the version numbers has all the link options added in but the top one should do what you are after hopefully?
Best wishes,
Mark
Hi Markus,
Just for you 😉 A quick update to the plugin V1.0.2 in the top thread now allows you to have an optional uri-only=”yes” parameter which if included will just spit out the text instead of a link. Leave the parameter out to use the plugin in the standard way.
Hope that helps.
Best wishes,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.