1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.5 Includes and HTML for some special pages only

Discussion in 'Styling and Customization Questions' started by Robert9, Sep 21, 2016.

  1. Robert9

    Robert9 Active Member

    Coming from VB it was easy for me to do the following:

    Include some HTML to home and to single cat-pages.
    (Home i put into the home template, for the cat-pages i add a field for different html-code to insert it in some cats)
    The same it was easy to include some html with an include-file like: inlude inc_home or include inc_forumid_xy, in the cats just with a trigger yes/no.

    After spending many hours with xf i just understand that i still have no idea how to add something only at home or only at the forum with id 7.
    Is there any information about this? (I dont want to use any addons, i just want to understand it.)

    Maybe i should check the templates first now.
  2. Brogan

    Brogan XenForo Moderator Staff Member

    You can add it directly to the template and/or use conditional statements to target specific pages which have IDs (forums, categories, etc.).

    There are links in my signature which should help.
  3. Robert9

    Robert9 Active Member

  4. Brogan

    Brogan XenForo Moderator Staff Member

    To add something on forum 15 only, wrap the content in:
    <xen:if is="{$forum.node_id} == 15">
    That will only work for the forum_view template, so I'm not sure why you're mentioning the index, or even what it is you're trying to do.
  5. Robert9

    Robert9 Active Member

    Yes, i have seen this. Thank you.
    With index i mean "forum home" :)

    Probably i will need a new field to "forum" with html-code and then something like: if field isnot empty show code for the forums or a trigger yes/no and something like if trigger is yes, include inc_forumid_xy.php

    and i need an include to the index/home only.
  6. Brogan

    Brogan XenForo Moderator Staff Member

    It's still not clear what you are trying to do so I can't really offer any more advice.
  7. Robert9

    Robert9 Active Member


    On forum/home i want to have some information for my users. Because this information changes every day i want to include some html-code coming from a file inc_home.php that is written from another database application.

    The information is not in forum-list, it is on top. So i have to put it in PAGE CONTAINER, but here i need to ask:
    if ? is home, then include the file inc_home.php and insert the html code

    How i decide in PAGE CONTAINER if i am at forum home?

    2. To show different information to every subforum i can do:

    2.1 a new field to table forum (vb - maybe node in xf) and fill it with HTML.
    Then if field not empty include html from field
    2.2 include an external file with name inc_node_id

    I can do this with your if-statements written above, ok.

    So next i have to try my best with xen:callback to get an include-file, right?

    I should learn how to include a php to use some code also.
    But at the moment i need only some html-code to be included. maybe the callback-function is the wrong one if i only need html and not php-code?

    Example: callback for

    echo "<p>Nice day</p>";

    but the html would be enough for now.

    include a inc_home.php with just
    <p>Nice day</p>
    Last edited: Sep 21, 2016
  8. Brogan

    Brogan XenForo Moderator Staff Member

    At the simplest level you would add your custom content to the forum_list template for the main index, and to the forum_view template (using conditional statements) for the forums.

    You could use a Notice but that would require updating them every day if the content changes daily.
  9. Robert9

    Robert9 Active Member

    I have now:


    class Robert_Home_Wand {
        public static function getWand() {
            $output = 'Test';
            return $output;
    and in forum-list

    <xen:callback class="Robert_Home_Wand" method="getWand"></xen:callback>

    Next step: How to use PAGE CONTAINER and know that we are at forum home.
    Last edited: Sep 21, 2016
  10. Robert9

    Robert9 Active Member

    To make it easy for myself i will update this file from another application to fill

    $output = " ..."; with new data every day.

    But i could us also:
    as i read now.

    Hmm. But much better would be to pass the file_name like:

    public static function getWand($input) { ...


    require $input;


    <xen:callback class="Robert_Home_Wand" method="getWand">path/content_file.php</xen:callback>

    I will try this, then im free.

    Next i need your conditionals in PAGE CONTAINER


    if forum home (how to ask this?)
    else if node = 17
    <xen:callback class="Robert_Home_Wand" method="getWand">path/inc_17.php</xen:callback>
    else nothing

    For shure i need simething different to ask
    else if node = 17

    so i should have a trigger for every sub_forum "Use external file yes/no",
    if node, if trigger=yes
    <xen:callback ... $nodid

    But step by step ...
  11. Brogan

    Brogan XenForo Moderator Staff Member

    You can do it a number of ways - using conditional statements in the template, in the php code, and even having two different scripts - one for the forum index, another for the forums.
  12. Robert9

    Robert9 Active Member

    Yes, i have somehow an idea how this could be done, but at the moment i stuck here:

    <xen:if is="{$contentTemplate} == forum_list">
    <xen:callback class="Robert_Home_Wand" method="getWand"></xen:callback>

    Got it with:
    <xen:if is="{$contentTemplate} == 'forum_list'">
    Last edited: Sep 22, 2016
  13. Robert9

    Robert9 Active Member

    Thank you very much, i have solved it. Now i have six wonderful pictures with a link for the last news in another area of the page at the forum home.


Share This Page