Page 1 of 1

if 'this' URL then 'run', else 'die' ...how can i do this?

Posted: Thu Feb 09, 2012 1:22 pm
by dced
Hello

I bet this is a really easy script, but even this seems to be out of my league, its a bit embarrassing really.

I have looked everywhere for an easy copy and paste solution for this code requirement. I hope someone can help.

My site is a template, then of coarse development is limited by its design.

I want to run a popover window script (2x javascripts and 1x css) that i have bought, it works nicely and i have already payed for it so this one would suit me best.

In the template i can create custom pages through its admin. But for my custom pages the template creates a 'on the fly' html. In other words, for 'this' URL and 'that' URL the custom page is writes from the database and other pages that are .tpl, .inc.php, and .js pages, but all 'on the fly' - there is no custom source code that i can edit for each unique URL except the one and only default .tpl that is used for all custom pages (all URL's).

Then the problem i have is that if i include the javascripts and css for the popover window in to the default custom page that is the .tpl page, then it will automatically run for every custom URL, and that is limiting the design of the site. I prefer to be able to control what custom URL does run the popover window script, and what custom URL does not.

So i figure i can achieve what i want with a php code in the .tpl page. Alternatively, i could do the same code creation but place it in the .inc.php page, but that placement is a lot more critical for effectiveness.

The php can be something like the following (please excuse my bad syntax, i am a self taught newbie):

Code: Select all

<?php 
if header ('Location: http://www.this_site.com/this_unique_URL.php);
    echo header ('Location: this_popover_window.js');
    and echo header ('Location: this_script_also.js');
    and echo header ('Location: this_css_script.css');

else die
?>
So if you didn't get what i am trying to do with the code in the php form above... I am trying to create a if statement that asks what is the URL that is open in the browser, and if that is true then the popover window javascripts and css should run.

And when the if statement is false, the else is a die, thus stopping the php script from running any further. The if and else in effect work together to either run the popover window script or not to run it.

During a false call and subsequent die I would want the rest of the .tpl script to run as normal. If the entire script stops, i could place the php snippet at the bottom of the page.

Can anyone help?

Thank you
sc

Re: if 'this' URL then 'run', else 'die' ...how can i do thi

Posted: Fri Feb 10, 2012 9:12 am
by artofwork
Self taught newbie eh?

How can you be self taught and not even know how to write a conditional statement?

Wtf, go read a php manual or atleast the 1st 5 chapters of any php beginners guide... you don't have the time.. thats your problem... put some effort into learning rather then copy and pasting code you can't even understand...