Announcement

Collapse
No announcement yet.

How do I use the PHP Parsed Header template?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I use the PHP Parsed Header template?

    hey folks ...

    I am setting up forums that are restricted to people who have logged into my system.

    I have a cookie that is set when they are logged in that I want to check for when in the forums ... i.e. if they have not logged in to the site propper, they get booted to the login page when trying to read the forums.

    In the rest of the site I can use the following code:


    if (!$cookieName) {
    header("location:login.php");
    }

    how can I insert this check into the forum templates? Does it go in the PHP Parsed Header Template? If so, how do you use that template ... right now there is a bunch of commented lines there but that is it.

    Thanks


    Gordon

  • #2
    Basically, just add that code in there, and they will have to login with your sites login stuff or no page will display.

    Any page within that styleset using that template set, at all, will get redirected if they aren't logged in.

    If you want to have their login information stored in this cookie that automatically logs them into the forum as well, that may take a bit of hacking, and a request in the hacks forum might be better.

    Comment


    • #3
      the stuff that is commented out ... do I leave that commented out?

      thanks

      Gordon

      Comment


      • #4
        The commented out stuff is there for an example.

        I assume you mean the
        PHP Code:
        // This code is PHP4 only:
        // ob_start(); 
        // require("yourheader.html");
        // $header = ob_get_contents(); 
        // ob_end_clean(); 
        Basically, what this is used for is, to store your header contents into a variable, and in this instance, you call yourheader.html, which isnt printed, until you call $header from a template. ob is basically Output Buffering.

        So in answer to your question, no, you dont have to leave it there, it can be removed.

        Comment


        • #5
          While you're at it. Is it possible to include php in the templates. If yes, how do I do that.

          Originally posted by merk
          The commented out stuff is there for an example.

          I assume you mean the
          PHP Code:
          // This code is PHP4 only:
          // ob_start(); 
          // require("yourheader.html");
          // $header = ob_get_contents(); 
          // ob_end_clean(); 
          Basically, what this is used for is, to store your header contents into a variable, and in this instance, you call yourheader.html, which isnt printed, until you call $header from a template. ob is basically Output Buffering.

          So in answer to your question, no, you dont have to leave it there, it can be removed.

          Comment


          • #6
            Originally posted by sduong
            While you're at it. Is it possible to include php in the templates. If yes, how do I do that.

            I take it from this you mean, that 'templates' as any template.

            No, it isnt posible to include any php in templates, unless you modify the files, or do it in phpinclude.

            For example, if i wanted to include a footer php file from my site, i would

            PHP Code:
            ob_start(); 
            require(
            "footer.php");
            $footer ob_get_contents(); 
            ob_end_clean(); 
            Then, because it is in phpinclude, in any template, i can call $footer .

            However, depending on what you want to do, its probably best, to actually ask what you want to do, because there are several methods of doing certain things.

            Comment


            • #7
              Thanks.

              This is what I was looking for. Thanks for the quick response.

              Originally posted by merk


              I take it from this you mean, that 'templates' as any template.

              No, it isnt posible to include any php in templates, unless you modify the files, or do it in phpinclude.

              For example, if i wanted to include a footer php file from my site, i would

              PHP Code:
              ob_start(); 
              require(
              "footer.php");
              $footer ob_get_contents(); 
              ob_end_clean(); 
              Then, because it is in phpinclude, in any template, i can call $footer .

              However, depending on what you want to do, its probably best, to actually ask what you want to do, because there are several methods of doing certain things.

              Comment

              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
              Working...
              X