Page 1 of 1

Help with using a variable in 2 pages at once

Posted: Sat Jul 16, 2005 4:14 pm
by karan13
I have a question and i can't figure it out. I have a web page that i use basically as my template, which consists of include commands to use other pages. So that way if i change the banner page and since it is included in all my templates, it will automatically update on all those pages.

Now i have a send page to friends function on my banner page. And it works, however it is based of using $PHP_SELF; However since it is on the banner page, it uses the link for the banner as the link to be sent out. I was wondering if anyone had ideas oh how to get it to work and use the templates link.

I was thinking of having a global variable in the template page, which would be assigned $PHP_SELF; and thus have the value of the template, which is what i want. However since the banner page in included into the template page, i am not sure how to pass that link over. Does anyone have any ideas. Sorry if it is not explained well.

Posted: Sat Jul 16, 2005 4:19 pm
by djot
-
If you set a global variable in your template file, you may use it in the banner file as URL for your "send to friends" feature.

I don't see why PHP_SELF should return the URL to the banner file. As far as I know it returns the initial script, that should be your template file!?

How many pages do you have? Savest way would be to use hardcoded URLs. You should have the files/pages already to create full URL like
$url.$page."htm";

Anyway, why is the "tell a friend" feature inside the banner file?

djot
-

How do i do the global thing

Posted: Sat Jul 16, 2005 5:47 pm
by karan13
If you set a global variable in your template file, you may use it in the banner file as URL for your "send to friends" feature.
Could you please tell me how to do that. I can't figure it out. Here is what the code sorta looks like but it is more sample.

Code: Select all

Main Template (ex. index.php)
....
<?php include banner.php ?>
....

Banner File (banner.php)
....
<a href=&quote;...sendpage?<?php echo $PHP_SELF ?>&quote;>Send Page</a>
....
Please tell me what i should do to make changes to the banner and template, so that it works. I have about 35 pages, and that is why i don't want to hardcode it. Plus i am setting it up for an education site, and they need to be able to add new pages in the future without hassle. Also i include it in the banner file because of the layout. I guess i could change it but i wanted to see if it was possible to fix the problem.

Thank You