|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
mzanier_XTC Smarty Regular
Joined: 04 May 2003 Posts: 38
|
Posted: Mon May 05, 2003 5:51 pm Post subject: |
|
|
ok here we go :=D
thats kinda confusing stuff.
here my index.php
Code: |
$smarty = new Smarty;
$smarty->cache_handler_func = 'xtcCacheHandler';
...
..
..
...
$smarty->assign('BOX_L', include(DIR_WS_INCLUDES . 'column_left.php'));
$smarty->assign('BOX_R', include(DIR_WS_INCLUDES . 'column_right.php'));
$smarty->display(CURRENT_TEMPLATE.'main_theme.html');
|
here my column_left.php
Code: |
$box_align_query = $db->Execute("SELECT box_name FROM " . $xtcDBTable['box_align'] . " WHERE box_align='left' AND box_visible='1'");
while ($box_align_values = $box_align_query->fields) {
require('includes/boxes/' . $box_align_values['box_name']);
$box_align_query->MoveNext();
}
return($outputL);
|
here my column_right.php
Code: |
$box_alignR_query = $db->Execute("SELECT box_name FROM " . $xtcDBTable['box_align'] . " WHERE box_align='right' AND box_visible='1'");
while ($box_alignR_values = $box_alignR_query->fields) {
require('includes/boxes/'. $box_alignR_values['box_name']);
$box_alignR_query->MoveNext();
}
return($output);
|
here an example for a box right
Code: |
$output.= $smarty->fetch(CURRENT_TEMPLATE.'box_'.$box_tpl_values['box_align'].'.html');
return($output); |
here an example for a box left
Code: |
$outputL.= $smarty->fetch(CURRENT_TEMPLATE.'box_'.$box_tpl_values['box_align'].'.html');
return($outputL)
|
hope you got an idea ?
yep have tried to use my first version with 1 smarty instance also, but dont work.
ya the world is cruel |
|
Back to top |
|
mzanier_XTC Smarty Regular
Joined: 04 May 2003 Posts: 38
|
Posted: Tue May 06, 2003 8:55 am Post subject: |
|
|
damn.. cant get it working ;// any idea why i lose the 2nd $output var ? |
|
Back to top |
|
mzanier_XTC Smarty Regular
Joined: 04 May 2003 Posts: 38
|
Posted: Tue May 06, 2003 9:16 am Post subject: |
|
|
the amusing thin is, i fetch now in 2 variables, but if i fetch more then 1 box in a variable, the other var is empty ? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue May 06, 2003 6:22 pm Post subject: |
|
|
Hi mzanier_XTC!
I haven't had time to look up much recently, so this has to be quick
Okay, your code is structured as includes/requires maintaing a single scope--global. The lack of scoping makes it difficult to follow what is happening. Try (mentally) replacing the includes with the actual code that gets included... Okay, that should give you a better idea of what is being set and where.
Lets look at index.php:
$smarty->assign('BOX_L', include(DIR_WS_INCLUDES . 'column_left.php'));
Here, {$BOX_L} will have the result of the included file. What is that result?
Well, lets see:
column_left.php
Code: | $box_align_query = $db->Execute("SELECT box_name FROM " . $xtcDBTable['box_align'] . " WHERE box_align='left' AND box_visible='1'");
while ($box_align_values = $box_align_query->fields) {
require('includes/boxes/' . $box_align_values['box_name']);
$box_align_query->MoveNext();
}
return($outputL); |
See the problem? Your return value is based on $outputL, which is set in the required files. As I suggested earlier, each file should be building output by concatenating the RESULTS (ie. the return values) of the requires/includes. Replace the code as so:
Code: | $box_align_query = $db->Execute("SELECT box_name FROM " . $xtcDBTable['box_align'] . " WHERE box_align='left' AND box_visible='1'");
$column_left = '';
while ($box_align_values = $box_align_query->fields) {
$column_left .= require('includes/boxes/' . $box_align_values['box_name']);
$box_align_query->MoveNext();
}
return($column_left); |
Use the same technique for column_right and all included boxes / files.
EDIT:
Take note of the line $column_left = ''; prior to the loop that fetch's results via the requires. This makes sure that $column_left is clean: otherwise the append ( .= ) in the loop may start with old data!! This pattern should be followed wherever you use this technique.
Hope that helps! |
|
Back to top |
|
mzanier_XTC Smarty Regular
Joined: 04 May 2003 Posts: 38
|
Posted: Tue May 06, 2003 6:39 pm Post subject: |
|
|
well ~~~
<- located the problem, and erased it (
i 4 got to delete 1 $smatrty= new Smarty;
in 1 of my boxes, now it works fine !
thx 4 support,
u can see our project soon on www.nextcommerce.de (oscommerce fork, with template engine,bmecat,etc)
cu soon |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue May 06, 2003 6:50 pm Post subject: |
|
|
Quote: | 4 got to delete 1 $smatrty= new Smarty; in 1 of my boxes |
Oh dude! Did you ever try getting it to work the original way with ALL of those removed .
I'll check it out, though I'm afraid I'll need a translator
I'm happy that you figured it all out--I hope you find Smarty to be a useful addition to your project. Good luck!! |
|
Back to top |
|
mzanier_XTC Smarty Regular
Joined: 04 May 2003 Posts: 38
|
Posted: Tue May 06, 2003 6:55 pm Post subject: |
|
|
Quote: |
Oh dude! Did you ever try getting it to work the original way with ALL of those removed .
I'll check it out, though I'm afraid I'll need a translator |
np, we will release multilingual
hehe... i dont want to try now my old version ;D that wont be good 4 my ego hehe, but now i think its a better solution then my original way
Quote: |
I'm happy that you figured it all out--I hope you find Smarty to be a useful addition to your project. Good luck!! |
we looked at many other template enginges, but we selected smarty as our favourit [/code] |
|
Back to top |
|
|
|
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
|