The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
nested dependent vb:each - building headers for sorting
Hello,
I have tried numerous ways, but am beginning to think this not possible (or i'm just stuck looking at it from a single angle), so figured i'd try to get some outside opinions/help. In my php file, i create an array that looks like the following: Code:
while ($wp_alist = $vbulletin->db->fetch_array($wp_fulllist)) { $wp_list[$count] = array( 'id' => htmlspecialchars($wp_alist['id']), 'name' => htmlspecialchars($wp_alist['name']), 'locid' => htmlspecialchars($wp_alist['locid']), 'location' => htmlspecialchars($wp_alist['location']), 'url' => htmlspecialchars($wp_alist['url']) ); $count++; } $templater->register('wp_list', $wp_list); Code:
<vb:each from="wp_list" value="list"> <tr> <td>{vb:raw list.location}</td> <td><a href="{vb:raw list.url}">{vb:raw list.name}</a></td> </tr> </vb:each> Code:
<vb:each from="wp_list" value="location"> <h1>{vb:raw location.location}</h1> <vb:each from="wp_list" value="list"> <vb:if condition="{vb:raw loc.location} = {vb:raw scroll.location}"> <tr> <td>{vb:raw list.location}</td> <td><a href="{vb:raw list.url}">{vb:raw list.name}</a></td> </tr> </vb:if> </vb:each> </vb:each> |
#2
|
|||
|
|||
I think that appraoch will work but you might need to create your own array of locaitons and register it too. Maybe try something like this:
Code:
while ($wp_alist = $vbulletin->db->fetch_array($wp_fulllist)) { $locations[] = htmlspecialchars($wp_alist['location']); $wp_list[] = array( 'id' => htmlspecialchars($wp_alist['id']), 'name' => htmlspecialchars($wp_alist['name']), 'locid' => htmlspecialchars($wp_alist['locid']), 'location' => htmlspecialchars($wp_alist['location']), 'url' => htmlspecialchars($wp_alist['url']) ); } $locations = array_unique($locations); $templater->register('wp_list', $wp_list); $templater->register('wp_locations', $locations); and then in your template: Code:
<vb:each from="wp_locations" value="location"> <h1>{vb:raw location}</h1> <vb:each from="wp_list" value="list"> <vb:if condition="$list['location'] == $location"> <tr> <td>{vb:raw list.location}</td> <td><a href="{vb:raw list.url}">{vb:raw list.name}</a></td> </tr> </vb:if> </vb:each> </vb:each> I'm not sure of there's any way to use the value from the outer vb:each to specify the inner vb:each array. That would make things a little more efficient. |
Благодарность от: | ||
wpeloquin |
#3
|
|||
|
|||
That didn't work (for me, anyways). I think it still sees the objects in the IF statement as <vb:raw> statements...
|
#4
|
|||
|
|||
I did have one error in the code above, which I just fixed. It said location.location when it should just be location. Also I left out the htmlspecialchars when setting the locations array. But I did test it and it basically seemed to work. What happens when you try?
|
#5
|
|||
|
|||
I had to play with the <table> tag and it is working now (see below). Much thanks kh99! I was on the right track it seems, just off on the syntax. You saved me many hours of tedious hair pulling
Code:
<vb:each from="wp_locations" value="location"> <h1>{vb:raw location}</h1> <table> <vb:each from="wp_list" value="list"> <vb:if condition="$list['location'] == $location"> <tr> <td>{vb:raw list.location}</td> <td><a href="{vb:raw list.url}">{vb:raw list.name}</a></td> </tr> </vb:if> </vb:each> </table> </vb:each> |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|