Forum

How do I include a ...
 
Notifications
Clear all

How do I include a new tpl file (block) on viewstory?

kali
 kali
(@kali)
Reputable Member

Couldn't tell if this was skinning or modding, so I'm posting this here.

I'm tacking on a conditional ad section into the viewstory page. Or rather, I'm attempting to and failing miserably.

In viewstory.php, I've got


if ($stories['rid'] == 2) {
}

which does work because I can do a tpl -> assign and have the text show up if the rating is correct, but I can't seem to  include a tpl file (I have to because the ads are javascript) properly.

Unfortunately, the TemplatePower manual is kinda...lacking and when I tried the alternate include method, all I get is a "TemplatePower Error: Template isn't prepared!" instead of the block I wanted.

Could I have the wrong path to the file (./$skindir/adblock.tpl)?

The contents of the adblock.tpl (currently) are:

<!-- START BLOCK : adblock -->
Work damn you
<!-- END BLOCK : adblock -->

Skins made by Kali are no longer supported!

Quote
Topic starter Posted : 10/03/2014 4:01 am
SJP
 SJP
(@sjp)
Trusted Member

I'm just guessing at this, so feel free to ignore it if I'm not making sense, but why do you need to add a new tpl file? Can't you just add to the existing viewstory.tpl?

In viewstory.php, add

if ($stories['rid'] == 2) {
$tpl->newBlock("adspace");
$tpl->gotoBlock("_ROOT");
}

before this:

if(!empty($storyinfo['storynotes'])) {
$tpl->gotoBlock("_ROOT");
$tpl->newBlock("storynotes");
$tpl->assign( "storynotes", stripslashes($storyinfo['storynotes']));
$tpl->gotoBlock("_ROOT");
}

and then in viewstory.tpl, add

<!-- START BLOCK : adspace-->
Whatever javascript you need
<!-- END BLOCK : adspace-->

ReplyQuote
Posted : 10/03/2014 5:53 am
kali
 kali
(@kali)
Reputable Member

I tried that, didn't work. I'll try your code though, mine probably wasn't written properly.

ETA: I think it's working. Or at least my pages haven't exploded spectacularly. Thank you for your help.

Skins made by Kali are no longer supported!

ReplyQuote
Topic starter Posted : 10/03/2014 4:03 pm
Share: