XF 1.5 Includes and HTML for some special pages only

Robert9

Well-known 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.
 
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.
 
To add something on forum 15 only, wrap the content in:
Code:
<xen:if is="{$forum.node_id} == 15">
Content
</xen:if>

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.
 
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.
 
Ok.

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
or
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:
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.
 
I have now:

library/Robert/Home/Wand.php

with
Code:
<?php

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:
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:
require('/path/content_file.php');
as i read now.

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

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

and

require $input;

and

<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

like

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",
then
if node, if trigger=yes
<xen:callback ... $nodid


But step by step ...
 
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.
 
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>
</xen:if>

Got it with:
<xen:if is="{$contentTemplate} == 'forum_list'">
 
Last edited:
Back
Top Bottom