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.
{exp:fetch_current_uri}
That’s it!
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
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.
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!
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.)
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?
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.
Just as a quick note. V1.0.2 has had a couple of very minor updates. I noticed something odd with the rendered output especially with the title element not being output and also updated the instructions a bit.
I’m working on a CSS “sliding doors” navigation menu. The “active” tab has an addition CSS class of “current”.
I would like this to work in a dynamic method by accessing the URI.
I had this working before, but without CSS navigation, rather old-school images as follows (only a sniplet of script):
=======================================================================
<?php
$full_path = getenv(“REQUEST_URI”);
$base = dirname($full_path);
switch ($base) {
case ‘/’:
include (”/home/globalhemp/www/includes/home.inc”);
break;
case ‘/About_Us’:
include (”/home/globalhemp/www/includes/home_about_us.inc”);
break;
case ‘/Contact_Us’:
include (”/home/globalhemp/www/includes/home_contact_us.inc”);
break;
default:
include (”/home/globalhemp/www/includes/home.inc”);
break;
}
?>
=======================================================================
I would like to know how to perform the same, but in a more dynamic mode since the new navigation menu is CSS enabled and the “active” tab is highlighted by the class “current” and being matched to relevant URI.
Plugin sounds interesting, but I’m trying to figure out exactly what the use of it would be. Would it be for something similar to just like a permalink you’re looking at, or did you develop this for some other purpose I’m totally clueless about.. Seems useful, but I can’t my head around properly utilizing it.