Templates

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • neur0maniak

    #16
    Re: Templates

    Yehia wrote:[color=blue]
    > ok, i did copy them EXACTLY and it kinda worked but still have some
    > questions:
    > 1.when using javascript in a php file should i write like this
    > <script language="javas cript> <!-- some function --> </script>
    > or like this <script language="javas cript"> some function </script>
    >
    > 2. somethings may vary from one page to another besides its content
    > like the page title, what is the simplest way to do this?
    > i read about sending arguments to the php file and then assign to the
    > page title, but this not really neat, what if i want to make it a long
    > title:
    > test.php?pageti tle=This a really long title, really long
    > one............
    > Anyother wahy to do this?
    >
    > my questions might look stupid but i'm just really a beginner in php,
    > Thanks
    >[/color]

    1. Either will work, the commented version is better for browsers though.

    2. Create another folder (like pages, but call this one 'headers' or
    such. Then add this code underneath where $strPage is assigned:

    if (file_exists("h eaders/{$strPage}.php" ))
    {include("heade rs/{$strPage}.php" );}

    The .php in the headers folder would need to be pure php (no out put, no
    empty spaces before/after the PHP tags).
    Inside the PHP, you could have
    <?php $strTitle = "Different Title"; ?>

    Then, in your template page where you set your title, you could have
    something like this:
    <TITLE><?php if (strlen(trim(@$ strTitle))>0) {print
    $strTitle;}else {print "Normal Title"; ?></TITLE>

    The file in the headers folder will need the same filename as the file
    in the pages folder. You don't need to put a file in the headers folder,
    for each one you have in your pages folder, just ones that change something.

    This way you can put anything that changes headers or adds cookies on a
    page using the file in the headers folder.


    Comment

    Working...