Announcement

Collapse
No announcement yet.

Echoing file in template

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

  • Echoing file in template

    Is there a way I can make it so a text file is outputted into my template?

    I tried <?php @include('http://newccn.familyteen.net/rules.txt'); ?> in my template, and it did not work.

    Not sure if this goes here, feel free to delete, lock, or move it as you see fit .


  • #2
    Originally posted by Andrew111888
    Is there a way I can make it so a text file is outputted into my template?

    I tried <?php @include('http://newccn.familyteen.net/rules.txt'); ?> in my template, and it did not work.

    Not sure if this goes here, feel free to delete, lock, or move it as you see fit .

    Look at fopen and read the file into a buffer and display the buffer in your template.
    Computer Help Forum
    An informed rider makes their first destination the motorcycle forum at rider info.

    Comment


    • #3
      I should have specified it's a remote file. My bad.

      Comment


      • #4
        Originally posted by Andrew111888
        I should have specified it's a remote file. My bad.
        Bummer, your host probably don't allow you to fopen remote files.
        Computer Help Forum
        An informed rider makes their first destination the motorcycle forum at rider info.

        Comment


        • #5
          Yeah, I could just post the file contents into my template, but the people who's file it is would prefer I echo it so I have instant updates (it's a set of rules).

          Comment


          • #6
            try using include instead of echo.
            ManagerJosh, Owner of 4 XenForo Licenses, 1 vBulletin Legacy License, 1 Internet Brands Suite License
            Director, WorldSims.org | Gaming Hosting Administrator, SimGames.net, Urban Online Entertainment

            Comment


            • #7
              You need to put PHP code into the PHPINCLUDE templates.

              PHP Code:
              if(THIS_SCRIPT == 'name_of_script_that_needs_rules_txt'//defined in the start of the script
              {
                @
              ob_start();
                @
              readfile('http://url/file');
                
              $rulestxt ob_get_contents();
                @
              ob_clean();

              You can then use $rulestxt in your template.

              Your host shouldnt have disabled the use of remote files unless you're running in a safemode kind of enviroment. Try using require_once('url') if readfile doesnt work

              Also note that fopen() wont work without a fread() or a loop to print the file.
              Last edited by merk; Thu 8 Jul '04, 12:31am. Reason: readfile instead of fopen

              Comment


              • #8
                The above didn't work, but this did:

                PHP Code:
                ob_start();
                require(
                "http://newccn.familyteen.net/rules.txt");
                $rulestxt ob_get_contents();
                ob_end_clean(); 
                in phpincludestart

                However, I thank you for pointing my in the right direction .

                Comment


                • #9
                  ID be curious if you pasted exactly what you put into the template, as the code above should work if you filled out the THIS_SCRIPT variable correctly. (Unless of course you wanted it in ALL pages where you didnt need it.)

                  Comment

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