TemplatePower Forum Forum Index TemplatePower Forum
Ask your question about TemplatePower here!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Emergent] Strange problem with newBlock ! Disappearing !

 
Post new topic   Reply to topic    TemplatePower Forum Forum Index -> Coding Help
View previous topic :: View next topic  
Author Message
RainMaker



Joined: 14 May 2006
Posts: 1

PostPosted: Sun May 14, 2006 5:54 am    Post subject: [Emergent] Strange problem with newBlock ! Disappearing ! Reply with quote

Hello,

First, I'd like to say that I really like TemplatePower ..

I've been using It for more than 1 year, and I've created more than 7 applications with it ..

I like it because of its simplicity .. however It doesn't support " IF " statment in templates .. but It's ok . . ^_^


SO, Iam kinda expert in dealing with TemplatePower ..

But :
Code:

$rand_last = mysql_query("select ptitle,poid from poems where uid='$randpoet[uid]' order by pdate desc limit 5");
while($rndlast=mysql_fetch_array($rand_last)){
   $tpl->newBlock("LastRand");
   $tpl->assign("RNDST_Title",$rndlast['ptitle']);
   $tpl->assign("RNDST_ID",$rndlast['poid']);


This is a loop to show the latest 5 poems .. It's working so well !

Code:

<!-- START BLOCK : LastRand -->
<a href="?action=show_poem&id={RNDST_ID}" title="{RNDST_Title}">{RNDST_Title}</a><br />
<!-- END BLOCK : LastRand -->


Yes .. It's so ok till now .. the latest 5 appear correctly with everything ..


but after few lines .. I add :
Code:

$GetQQ = mysql_query("select * from voting order by votid desc limit 1");
$GetQ = mysql_fetch_array($GetQQ);

$tpl->assign("Voting_Queston",$GetQ['question']);
$tpl->assign("VotingID",$GetQ['votid']);


and :
Code:

<form method="post" action="?action=voting&id={VotingID}">
{Voting_Queston}


But .. It doesn't appear completely ..Just empty !


SO I tried to play here and there .. and I removed the part of newBlock of the first code .. like :
Code:

$rand_last = mysql_query("select ptitle,poid from poems where uid='$randpoet[uid]' order by pdate desc limit 5");
while($rndlast=mysql_fetch_array($rand_last)){
   // $tpl->newBlock("LastRand");
   $tpl->assign("RNDST_Title",$rndlast['ptitle']);
   $tpl->assign("RNDST_ID",$rndlast['poid']);


and guess what ?
The second code .. the question appeared correctly and 100% !

So, Simply ..

I remove the newBlock from the first code .. the second appears ok ..
I put the second code before the first one .. the question appears ok and the poems not ..

on other words, the first I define, the Only It's showed and the other not !


I don't know really . . have anyone met something like that ?

Is there any way .. to clear the newBlock of values after It's finished or something ?

Thanks,
Back to top
View user's profile Send private message
Donny_nl



Joined: 11 Jan 2006
Posts: 14

PostPosted: Sun May 21, 2006 1:49 pm    Post subject: Reply with quote

You assigned a Block, Lastrand. After which you define a couple of vars into that block. Underneath you parse another 2 vars, but those vars are not in that block. But templatepower doesn't know that. So you have to make sure that these vars are not a part of the block, but a part of the ROOT of the template.

So before assigning those vars, you need to tell templatepower to go to the root.

Code:
<?php

$rand_last = mysql_query("select ptitle,poid from poems where uid='$randpoet[uid]' order by pdate desc limit 5");
while($rndlast=mysql_fetch_array($rand_last)){
   $tpl->newBlock("LastRand");
   $tpl->assign("RNDST_Title",$rndlast['ptitle']);
   $tpl->assign("RNDST_ID",$rndlast['poid']);

$tpl->gotoBlock( "_ROOT" );
$GetQQ = mysql_query("select * from voting order by votid desc limit 1");
$GetQ = mysql_fetch_array($GetQQ);

$tpl->assign("Voting_Queston",$GetQ['question']);
$tpl->assign("VotingID",$GetQ['votid']);

?>


See if that works.
Another way of telling TP that the vars need to be parsed in the root is :

Code:
<?php

$rand_last = mysql_query("select ptitle,poid from poems where uid='$randpoet[uid]' order by pdate desc limit 5");
while($rndlast=mysql_fetch_array($rand_last)){
   $tpl->newBlock("LastRand");
   $tpl->assign("RNDST_Title",$rndlast['ptitle']);
   $tpl->assign("RNDST_ID",$rndlast['poid']);

$GetQQ = mysql_query("select * from voting order by votid desc limit 1");
$GetQ = mysql_fetch_array($GetQQ);

$tpl->assign("_ROOT.Voting_Queston",$GetQ['question']);
$tpl->assign("_ROOT.VotingID",$GetQ['votid']);

?>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    TemplatePower Forum Forum Index -> Coding Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group