How do I include a ...
 
Notifications
Clear all

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

3 Posts
2 Users
0 Reactions
2,687 Views
 kali
(@kali)
Posts: 307
Reputable Member
Topic starter
 

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!

 
Posted : 09/03/2014 11:01 pm
 SJP
(@sjp)
Posts: 66
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-->


 
Posted : 10/03/2014 12:53 am
 kali
(@kali)
Posts: 307
Reputable Member
Topic starter
 

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!

 
Posted : 10/03/2014 11:03 am
Share: