I'm trying to lopp through two different blocks, but I think I'm geting clobbered by the way the templating engine interprets namespace.
I'm iterating through rows,
<!-- BEGIN character_row -->
and then I iterate through a column array that just sets the column type, then the template branches based on that.
<!-- BEGIN character_column -->
<!-- IF character_row.character_column.S_COLTYPE eq 'a' -->
I'd like to then iterate through another array at the same level as character_column (e.g. "character_row.alt_list"), but I think the namespace is fixed in character_row.character_column. So if I ask to
<!-- BEGIN alt_list -->
it's looking for something of the structure "character_row.character_column.alt_list", which would be a sub array of a particular character_column element, which isn't what I want at all (the alt_list isn't really specific to a particular column, it should be able to appear anywhere in the template.
Is there any way to explicitly set the scope of the templating loop so I can do this? I looked at the source, and I didn't see any indication I could.
I also don't think I can do an "END" immediately after each IF branch, as I imagine the blocks are parsed in a way that wouldn't allow that.
Am I missing some critical aspect? I could just get rid of the column iterator and have users explicitly template the columns in the order and format they want, but I kind of wanted to offer some pre-rendered options that could be selected quickly, in any order, and just have it work.
It is pitch black. You are likely to be eaten by a grue.
Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Ubuntu 12.04, Atom D525/Apache 2.2.22/MySQL 5.5.38/PHP 5.3.10/Dragonfly 9.4.0.0 CVS
NanoCaiordoOffline
Joined: Jun 29, 2004
Posts: 4291
Location: Italy
Try with two different "handle" files and then use <!-- INCLUDE filename --> inside the loop.
I'm not sure I understand the suggestion entirely, though I think it won't need to do what I need to do. I suspect it might at best give me a top-level namespace again, which would break me out of the row namespace I still require?
This is what each row looks like. Note that "character_alts" and "character_column" are at the same level and are children of "character_row":
This is what the snippet of the template should look like to do what I want:
<!-- BEGIN character_row -->
[somestuff...]
<!-- BEGIN character_column -->
[somestuff...]
<!-- ELSEIF character_row.character_column.S_COLTYPE eq 'n' -->
<!-- IF (character_row.U_EDIT_CLAIM eq '') -->
<td class="{character_row.S_ROWCLASS}" style="white-space:normal">
<!-- IF (character_row.U_CHAR_PROFILE ne '') -->
<a href="{character_row.U_CHAR_PROFILE}"{S_TARGET}>
<!-- ENDIF -->
{character_row.S_CHAR_NAME_FIRST}
<!-- IF (character_row.S_CHAR_NAME_LAST ne '') -->
{character_row.S_CHAR_NAME_LAST}
<!-- ENDIF -->
<!-- IF (character_row.U_CHAR_PROFILE ne '') -->
</a>
<!-- ENDIF -->
</td>
<!-- ELSE -->
<td class="{character_row.S_ROWCLASS}">
<table style="border-style:none" border="0" cellspacing="0" cellpadding="0" width="100%">
<tr style="vertical-align:middle">
<td style="text-align:left;white-space:normal">
<!-- IF (character_row.U_CHAR_PROFILE ne '') -->
<a href="{character_row.U_CHAR_PROFILE}"{S_TARGET}>
<!-- ENDIF -->
{character_row.S_CHAR_NAME_FIRST}
<!-- IF (character_row.S_CHAR_NAME_LAST ne '') -->
{character_row.S_CHAR_NAME_LAST}
<!-- ENDIF -->
<!-- IF (character_row.U_CHAR_PROFILE ne '') -->
</a>
<!-- ENDIF -->
<!-- IF (character_row.S_ACCOUNT_LINK_ID ne '0') -->
<!-- BEGIN character_alts -->
[Can't iterate here, because already in the "character_row.character_column" namespace, need to be in "character_row.character_alts" namespace]
<!-- END character_alts -->
<!-- ENDIF -->
</td>
It's an odd situation. I want to be able to iterate in the template over "character_row.character_alts" from any element in the loop through "character_row.character_column" WITHOUT having to have a copy of character_alts in each element of "character_row.character_column". =/
One possibility I condsidered is seeing if I can copy a pointer into each element of "character_row.character_column" and access the list from there, but I'd probably have to abuse the object to point it back to itself, and that'd be kind of dodgy.
The other is just to copy "character_alts" into the column I currently have templated for it, but that makes the template less flexible.
What I really need is a "BEGIN ../character_alts", ya know?
It is pitch black. You are likely to be eaten by a grue.
Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Ubuntu 12.04, Atom D525/Apache 2.2.22/MySQL 5.5.38/PHP 5.3.10/Dragonfly 9.4.0.0 CVS
NanoCaiordoOffline
Joined: Jun 29, 2004
Posts: 4291
Location: Italy
Oh. True. It's there, I just abbreviated too much.
NanoCaiordo wrote
but have you tried <!-- BEGIN character_row.character_alts -->
Yeah, that didn't work either. I think it's not really possible to do what I have in mind. I can work around it using Javascript, which I'll probably have to do anyway, considering what style of tooltips I have in mind (I'd like to have clickable links in the tooltips).
If it's a project you really want to take on, I've attached the relevant templates and the file driving it. You can see the loop for the alts at 712-723 and the column type at 725-734.
From looking at the code, I don't think what I have will work. Both loops are siblings in the template variables, and if I'm reading it right, once you down downwards in the namespace, you have to work at that level or below, and you can't go up and access a sibling without exiting the loop. So I can iterate over alts, or columns, but not both at the same time.
In any case, the help is appreciated!
Attachment:
roster_master.zip
Description
Filename
roster_master.zip
Filesize
14.63 KiB
Downloaded
11 Time(s)
You are not allowed to view/download this attachment
It is pitch black. You are likely to be eaten by a grue.
Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Ubuntu 12.04, Atom D525/Apache 2.2.22/MySQL 5.5.38/PHP 5.3.10/Dragonfly 9.4.0.0 CVS