No announcement yet.

Getting PHP commands to work

  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting PHP commands to work

    I've been trying to display comprehensive descriptions of each forum when you enter them - intro welcome text when you enter a forum. My goal is to put the descriptions and perhaps an <img> command to show a graphic and the welcome text. Since forums each have a unique ID, I thought I'd set up a .txt file based on that unique ID (parameter is $forumid) and use a PHP "include" command to grab that text.

    The syntax of my command seems to work, but for some reason PHP isn't kicking in. I've basically used in "forumdisplay":

    <?php include("$forumid.txt"?>

    Let's say I'm currently in forum number 19. My line outputs:

    <?php include("19.txt"?>

    Now this is correct - when I view the Source - but the command for some reason doesn't actually work.

    Any suggestions?

  • #2
    The only template you can use PHP in is the phpinclude template and the forumid is not available for use in the phpinclude template because it is prepared before the rest of the page.



    • #3
      Okay, then let's reapproach the situation

      My goal is to provide unique descriptions and thumbnail intro graphics in each forum when a user clicks into it. So the General Forum has its welcome text and little image... the Classifieds has its own distinct welcome text and image... etc.

      What is the best way to do this?


      • #4
        Re: Getting PHP commands to work

        Originally posted by Adrian Ko
        <?php include("$forumid.txt"?>
        <?php include("19.txt"?>
        Any suggestions?

        I think the way is by using templates
        But.. your syntax doesn't seem to look right either!

        long version:

        PHP Code:

        PHP Code:
        <?php include("file.txt"); ?>

        But I think the best way to alter anything on the forum is by altering the templates!


        • #5
          Thanks... more...

          How can I edit the templates when each forum's welcome text is unique? Are you saying to edit the templates to use "include" statements to include files based on the forumID of the forum?


          • #6
            Adrian's syntax was not exactly correct (extra semi-colon) but that's not the problem. Again you cannot use PHP in any of the templates.

            Thus far the only thing I've thought up is a new template set for each forum but that's not feasible in the grand scheme of things.