[Solved] - Current URL variable?

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
Silvertiger
Regular
Posts: 6
Joined: Thu Nov 20, 2008 7:57 pm

[Solved] - Current URL variable?

Post 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
Last edited by Silvertiger on Thu Nov 20, 2008 11:50 pm, edited 1 time in total.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Current URL variable?

Post by garvinhicking »

Hi!

You can put it inside your entries.tpl place and use {$entry.link} where you need the URL?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Silvertiger
Regular
Posts: 6
Joined: Thu Nov 20, 2008 7:57 pm

Post 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
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post 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?
=Don=
Silvertiger
Regular
Posts: 6
Joined: Thu Nov 20, 2008 7:57 pm

Post 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
Post Reply