Page 1 of 1
[Solved] - Current URL variable?
Posted: Thu Nov 20, 2008 9:04 pm
by Silvertiger
I am trying to add an external (google) translator to the BLOG, but in order for it to work i would have to be able to capture the "current url" and use that varilable in a form in the TPL to submit the translation.
I will delve back into the FAQ to see if I can find anything about that, but if anyone has a short answer i would appreciate teh help.
Thanks,
Silvertiger
Re: Current URL variable?
Posted: Thu Nov 20, 2008 9:59 pm
by garvinhicking
Hi!
You can put it inside your entries.tpl place and use {$entry.link} where you need the URL?
Regards,
Garvin
Posted: Thu Nov 20, 2008 10:17 pm
by Silvertiger
It's not a static url so I can't place it in a file and have it addressed like that. I am wanting to put the URL that was navigaed to (i.e. the current page on the blog) into a variable. I believe it is already in a variable, which is what I'm looking for.
Once I know that variable I can place the "{current url variable}" or whatever it is called into the .TPL page so that as the page is generated the current URL is included in the form to submit the current page for translation.
I've worked with PHP and know that there is a way to get the current URL with a script, but I am not sure I can add a whole PHP block and run it in line inside the .TPL file.
I hope that my explanation make sense.
Silver
Posted: Thu Nov 20, 2008 11:41 pm
by Don Chambers
I believe Abdussamad was the first to come up with this, but we have just the solution you are looking for in the template bulletproof, but it will require that your template have a config.inc.php file.
In that file, you will need (at minimum) this:
Code: Select all
<?php
if (IN_serendipity !== true) {
die ("Don't hack!");
}
$serendipity['smarty']->assign(array('currpage'=> "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']));
Inside of any tpl, you now have access to the current url as {$currpage}
Is that what you wanted?
Posted: Thu Nov 20, 2008 11:42 pm
by Silvertiger
Worked like a charm!!!!.. It does exactly what I was hoping.
Much thanks, now to see if it works globaly

hopefully i edited teh template corerctly.
Thanks,
Silver