1
tzvook
include a php file in the template + a ver
  • 2008/1/26 0:39

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


Hi all
I has a little problem regarding passing php vars to the smarty templates (adding google pagerank to webkinks module):

I need to include a php file in the template and pass him a ver, so I tried the folowing:
<{php}>
include 
"pagerank1.php"
uri="<{$link.url}>"
<{/php}>

in the template file, but it's giving a blank page ....
so it's definatly not the way to pass the $uri

<{php}>
include 
"pagerank1.php?uri=<{$link.url}>"
<{/php}>

is not working either ....

I now use the folowing code instead ..... (calling the php file via iframe which works well - but is a louzy way to do it when you think of the end code))

this one on the template file
<iframe frameborder="0" hspace="0" vspace="0" height="16" scrolling="No" style="vertical-align: top; vertical-align: baseline;margin:0px;padding:0px;border:0px;height:16px; width:66px;" src="pagerank1.php?uri=<{$link.url}>&uri=<{$link.url}>">iframe>


and this one in the php file
if (isset($_REQUEST['uri'])) $url=trim($_REQUEST['uri']); else $uri="http://www.domain.com";

echo 
"line-height10px;font-weightboldfont-size13px;">page rank: ".get_page_rank($url). "";


Help is definately needed here ...

2
kaotik
Re: include a php file in the template + a ver
  • 2008/1/26 13:14

  • kaotik

  • Just can't stay away

  • Posts: 861

  • Since: 2004/2/19


<{php}>
include 
'pagerank1.php?uri='.$link["url"];
<{/
php}>


You only use <{}> when inside a smarty template, since you called <{php}> all code inside should be php.

You could also do this without calling php:
<{include file='pagerank1.php?uri='$link.url}>

3
tzvook
Re: include a php file in the template + var
  • 2008/1/26 20:12

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


10X Kaotik
the code doesn't work ... i simply tryed to "echo" the var like this :
<{php}>
echo 
'$link["url"]';
<{/
php}>


tried also

<{php}>
echo 
"$link[url]";
echo 
$link["url"];
<{/
php}>


none worked ....

4
kaotik
Re: include a php file in the template + a ver
  • 2008/1/27 15:24

  • kaotik

  • Just can't stay away

  • Posts: 861

  • Since: 2004/2/19


try this:
<{php}>
global 
$link;
print_r ($link);

//include 'pagerank1.php?uri='.$link["url"];
<{/php}>

Login

Who's Online

287 user(s) are online (192 user(s) are browsing Support Forums)


Members: 0


Guests: 287


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits