Nested Asset Listing


#1

I'm trying print HTML required for tabbed content, but am struggling to get this to work. (5.1.9)

 

I'm trying to do this via a parent/child nested asset listing setup and using list_current_asset_id to access a parent's variable.

 

I've successfully used list_current_asset_id in the past when nesting within a parent'sType Formats Bodycopy, but in this instance I need to nest within the parent's Page Contents Bodycopy.

 

My end result is to print the following HTML:

<div class="tabs">
  <ul class="nav">
    <!-- asset listing one -->
    <li><a href="#tab1">Tab one link (from asset name)</a></li>
    <li><a href="#tab2">Tab two link</a></li>
    ...
  </ul>
</div>
<div class="tab-content">
  <!-- asset listing two -->
  <div id="tab1">Tab one contents (from asset contents)</div>
  <div id="tab2">Tab two contents</div>
  ...
</div>
</div>

 

I hope that translates, let me know if I need to make anything clearer.

 

Cheers in advance for any advice.


(Tim Davison) #2

I don't think you can pass the list_current_asset_id around that way, or you can but it's not as intuitive as you might like.  Once list_current_asset_id gets iterated over it remains at that new value.  It doesn't switch back based on context closure of the containing page (e.g. in javascript it would, based on closure rules).  Treat it as a true global.  

 

To do what you suggest I would create 2 asset listings, as you have done, but both would be configured the same way to generate the same list of assets.  Everything the same except for page and type format bodycopies.  I wouldn't link them using list_current_asset_id.  Way I suggest seems like duplication (and it is, really) but it works.  You're basically looping through the same list twice, and outputting slightly different HTML.  Just remember if you update the settings for one of the listings you have to update both.


#3

Cheers for the information Tim

 

I should've mentioned that I'm trying to set this up with variables for portability. I hope to nest this in multiple places across the site.

 

If it's too tricky I'll have to go with the dual configured asset listings but would prefer maintaining the one component for this.


(Tim Davison) #4

Yep - understood.  Ways I've worked around this are using replacement root nodes, either 'Current Asset' and I get a listing of all the children of the page nested the listing into, or use the nested GET variables if I need to specify roots in other parts of the asset map.  Still means you have to set the GET variable twice, once in each of the nested div's, but at least you can re-use the listings again and again.  However this may not be an option for your case.