PDA

View Full Version : How to include HTML file


snowname
06-27-2011, 04:17 PM
In 3.x version, I can add a plugin. $test=implode (file, dir).

Then add $test in a template.

How to do this in 4.x version?

kh99
06-27-2011, 04:29 PM
You can pre-register the variable in the template where you will use it, like this:

vB_Template::preRegister('template_name', array('test' => $test));


and then of course you'd use one of

{vb:raw test} or
{vb:var test}

in the template.

snowname
06-28-2011, 12:40 AM
I pre-registered:


$include_defaultpage = implode('', file('/bbs/CCED/float/default.html'));

vB_Template::preRegister('footer',array('include_d efaultpage' => $include_defaultpage));


and hooked it at global start


I put {vb:raw include_defaultpage} into the footer template.

However, it does not work.

kh99
06-28-2011, 01:10 AM
I tried what you posted above, except that I just used $include_defaultpage = "Foo"; as a test, and it showed up in my footer. Are you sure you're looking at the style with the edited footer? Otherwise, maybe it's not finding your html file?

Edit: also, are you sure you set the plugin to active? I've been known to forget that occasionally.

snowname
06-28-2011, 01:51 AM
I also tried $include_defaultpage = "Foo";, It still does not show up.

--------------- Added 1309229656 at 1309229656 ---------------

Here is how I write:



Plugin PHP Code
$include_defaultpage = implode('', file('/bbs/CCED/float/default.html'));
$include_defaultpage = "test";
vB_Template::preRegister('FOOTER',array('include_d efaultpage' => $include_defaultpage));

kh99
06-28-2011, 01:58 AM
'footer' needs to be lower case. You had it that way before so I guess you probably were trying things.

snowname
06-28-2011, 01:59 AM
I just did a test. If I put this plugin in header template. It works.

vB_Template::preRegister('header',array('include_d efaultpage' => $include_defaultpage));

--------------- Added 1309230334 at 1309230334 ---------------

it works now.

I changed /bbs/CCED/float/default.html to CCED/float/default.html

You are right. It did not find the file.

Thanks.