How to dynamically include file?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Hewitt
    Senior Member
    • Apr 2000
    • 1195
    • 4.1.x

    How to dynamically include file?

    Sorry if this should be in code hacking or something but I thought this was the best forum.

    I need to include an external file in the pages outputted by vBulletin.

    I know I can parse for php code in the headers and footers but can't I set it to parse for php code in all the include variables as well as the templates?

    I have tried SSI i.e.
    <!--#include virtual="/include.html" -->
    and PHP

    <?php virtual("include.html") ?>

    Neither of which parses the text is just passed to my browser in unparsed form.

    e.g. I would like to use it to call title.html which when normally called from a browser simply returns the name of an image file (depending on certain environment varaibles), this works file when I use a plain .php file and call it using the php above e.g.

    <img src="<?php virtual("title.html") ?>">

    I am wanting to put this into the $titleimage variable (as set from the control panel), but it doesn't want to know :( what to do??

    Any ideas on how to make it work?

    [Edited by Mark Hewitt on 05-22-2000 at 04:45 PM]
    Motorsport Forums
  • John
    Senior Member
    • Apr 2000
    • 4042

    #2
    What exactly are you trying to achieve here?

    You cannot use php code in the templates like that, but if you post some more details, we may be able to sort out some sort of workaround.

    John
    John Percival

    Artificial intelligence usually beats real stupidity ;)

    Comment

    • Mark Hewitt
      Senior Member
      • Apr 2000
      • 1195
      • 4.1.x

      #3
      Cheers John

      OK, I'll tell you more about what I am trying to do.

      Basically I have two versions of my website which are virtually identical except one is 'international' and one is for the UK. They use .com and .co.uk respectively.

      I use SSI to differentiate between the two sites and display different graphics and text depending on which site is being accessed. I need to be able to carry this through into the forums.

      I have a SSI file which returns the file name e.g. image1 if it is called from .co.uk and image2 if called from .com, if I write a .php file and stick in what I mentioned above i.e.
      <img src="<?php virtual("title.html") ?>"> it displays the appropriate image for if it is or is not the uk site - with me so far?

      Ideally what I would like to do is in the control panel where it asks for the image filename just type
      <?php virtual("title.html") ?>.

      Alternatively just put php or indeed SSI code directly into the templates.

      [Probably not relevant to this but in the UBB I did it by putting if statements in Styles.file]

      Thanks again. Mark.
      Motorsport Forums

      Comment

      • John
        Senior Member
        • Apr 2000
        • 4042

        #4
        Well, to do that, I would recommend either doing a quick code hack, or by putting some php code in your header. Change the references back to $titleimage in the templates.

        If you decide to go down the code hack route, you would just want to add a few lines of code at the end of the global.php file:

        [code]
        if (domain is com) {
        $titleimage="dotcom.gif";
        } else {
        $titleimage="dotcodotuk.gif";
        }
        [/code]

        If you want to do it in the header template, then set the header template up to be parsed as PHP code in options, and then edit the header template to include something like this:

        [code]
        $header="<p>My header text</p>";

        if (domain is com) {
        $titleimage="dotcom.gif";
        } else {
        $titleimage="dotcodotuk.gif";
        }
        [/code]

        The code hack option is probably the easiest to do, but it would have to be done every time you upgrade. The template hack is fine as long as you have a simple header - if it is more complicated, you may start running into problems.

        John
        John Percival

        Artificial intelligence usually beats real stupidity ;)

        Comment

        • Aldreis
          Member
          • Apr 2000
          • 77

          #5
          Thank you, John, for answering my just-about-to-be-asked question...

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...
          😀
          😂
          🥰
          😘
          🤢
          😎
          😞
          😡
          👍
          👎