Jump to content

Conditions based on which html page is used...


mkosmosports

Recommended Posts

Hey Everyone,

Im trying to write a condition based on what html termplate is being used at that moment. I have 6 different templates though and I want to avoid needing to rewrite the condition six times just to accomodate these six html templates. Here is an example of code for one of the conditions...
    if ($groupid == "9" || $groupid == "11")
    {    echo("<div style=\"background: #70A2D7 url(images/pastyears.jpg) no-repeat top\">
          <form name=\"CommonDrop\">
            <select name=\"DropSelect\" onchange=\"go()\" style=\"font-size: 14px; margin-top: 30px\">
                  <option selected value=\"#\">--Select--</option>
                  <option value=\"ghome.html?group=9&season=2006\">2006</option>
                  <option value=\"ghome.html?group=11&season=2002\">2002</option>
            </select>
          </form>
    </div>");}
Now, I want the same condition for when the user visits "teams.html" as opposed to "ghome.html" but I dont want to have to rewrite the above condition again to just replace the html template name. Is there some way I can use a variable there which would define the html template that the user is currently visiting, such as <option value=\"$currenthtml?group=9&season=2006\">...but what would that variable have to be defined as?

Any help is much appreciated...

mkosmosports
Link to comment
Share on other sites

Wait, just noticed something. How are you planning on passing parameters on a .html file? I didn't know that could be done.
[code]
ghome.html?group=9&season=2006
[/code]
?

Anyways, if you set your url parameters to include what template is being viewed, for e.g:
[code]
template.php?template=templatename
[/code]

Create your switch statement on a php file that sets your variables based on the template from the url parameters:
[code]
$templates = array (
'template_one',
'template_two',
);
$template = $_GET['template'];
if (in_array($template, $templates))
{
switch ($template)
{
case"template_one":
$blah = blah;
break;
case"template_two":
$blah = blah;
break;
}
}
else
{
echo "Error: That template doesn't exist!";
}
[/code]

Then include that on your template pages, or include the template page in the switch statement based on the template.
Link to comment
Share on other sites

"Wait, just noticed something. How are you planning on passing parameters on a .html file? I didn't know that could be done."

All my templates are html files and passing parameters work flawlessly. I always thought it didnt matter whether the extension is .php or .html....

I see your solution to my problem though, using a template variable, this sound like what I need to do. Thanks hostfreak. I will try this as soon as I get home again later today....

mkosmosports
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.