any chance for if-statement-like-stuff?

This forum is now closed. Please ask all styles-related questions in the phpBB 3.0 Styles Support & Discussion Forum.
Locked
cmi
Registered User
Posts: 7
Joined: Sat Oct 12, 2002 8:01 pm
Location: germany

any chance for if-statement-like-stuff?

Post by cmi » Fri Jun 04, 2004 9:10 pm

Hi there,

sorry for this question (maybe it was asked some dozens time in the past but i didn't found anything :(), but is there a chance to do the following in phpbb 2.0.x?

i define a block_var of servers which loop through in the template. for some of the servers i want to display specials informations (which aren't available for other servers). but in the case this informations are NOT available, how can i prevent the parser from parsing this stuff from the template anyway? i know the switch-method, but (how) can i put this into another blockvar?

this way:

$template->assign_block_vars('switch_display_informations', array());
$template->assign_block_vars('servers', array('VAR'=>'VALUE','INFO'=>'xyz'));

is static and not per server. but i need it for every server. (how) can i do this in phpbb 2.0.x? i hope there is any way :(

and another question: (how) can i handle arrays in a block_var?

lets say:
$template->assign_block_vars('servers', array('serverdata'=>array('ip'=>'127.0.0.1')));
no error, but how can i access the ip in the template? {servers.serverdata.ip} doesn't work :(

thanks for any help. i'm familar with smarty but not with phpbb-templating ;)

User avatar
Arty
Former Team Member
Posts: 16654
Joined: Wed Mar 06, 2002 2:36 pm
Name: Vjacheslav Trushkin
Contact:

Post by Arty » Fri Jun 04, 2004 10:20 pm

Use something like this:

Code: Select all

$template->assign_block_vars('servers', array(
 ... here are all server variables
 ));
if($somevar)
{
 $template->assign_block_vars('servers.somevar', array());
}
else
{
 $template->assign_block_vars('servers.nosomevar', array());
}
and then in tpl file use something like this:

Code: Select all

<!-- BEGIN servers -->

<!-- BEGIN somevar -->
somevar is set for current server
<!-- END somevar -->
<!-- BEGIN nosomevar -->
somevar isn't set for current server
<!-- END nosomevar -->

<!-- END servers -->
Vjacheslav Trushkin / Arty.
Free phpBB 3.1 styles | New project: Iconify - modern SVG framework

cmi
Registered User
Posts: 7
Joined: Sat Oct 12, 2002 8:01 pm
Location: germany

Post by cmi » Sat Jun 05, 2004 11:40 am

cool 8) thanks alot, works perfect :)

(can you help me with my second question too please? :oops: )

User avatar
Arty
Former Team Member
Posts: 16654
Joined: Wed Mar 06, 2002 2:36 pm
Name: Vjacheslav Trushkin
Contact:

Post by Arty » Sat Jun 05, 2004 11:45 am

use nested assign_block_vars() to add those variables.

like this:

Code: Select all

$template->assign_block_vars('servers', array(
  ... list of variables for "servers" ..
 ));
for($i=0; $i<count($ips); $i++)
{
 $template->assign_block_vars('servers.ips', array(
 'IP' => $ips[$i]
 ));
}
then in tpl use something like this:

Code: Select all

<!-- BEGIN servers -->

<!-- BEGIN ips -->
One more IP for current server: {servers.ips.IP}<br />
<!-- END ips -->

<!-- END servers -->
Vjacheslav Trushkin / Arty.
Free phpBB 3.1 styles | New project: Iconify - modern SVG framework

cmi
Registered User
Posts: 7
Joined: Sat Oct 12, 2002 8:01 pm
Location: germany

Post by cmi » Sat Jun 05, 2004 12:25 pm

ok thanks.. seems to be quite circumstantially... i guess i will choose the regular way in this case :roll: thanks for your help, your first hint couldn't be paid in gold ;)

Locked

Return to “[2.0.x] Styles Development & Discussion”