Dynamic Asset List by Asset Position


(James Porich) #1

Hi guys,

 

I've come in on the tail end of a website project and am looking to make some improvements around the current infrastructure, but am somewhat restricted in my access with more base-level customizations. With that in mind I am trying to do the following and wondering if there is a handy solution anyone has to the problem:
Too Long Didn't Read:

 

Dynamic Asset listings are great, is there a way to embed a dynamic asset list to only show the top (X) items of the list? Basically the "Assets Per Page" but as a dynamic variable?

Background:

 

We have a large-ish website with several areas dedicated to news posts (different areas of the organisation have different news. One area lists all news). These news pages list the latest (X) News Items (some maybe only 3 items, some 5, some more. Depends on the size of that particular departments area and their needs). Each of these areas also has their own "News Archives" area, where it will list all News Items of that area.

In both cases the formatting of the list is the same for all areas, Current or Archived.

The Goal:

Currently each of these areas has their own asset list, one for Archive, one for Current. This has gotten out of hand as there are a fair few departments, so obviously I want to tidy these up by allowing departments to use a shared Dynamic Asset List and just set the root node as I see fit.

The Problem:

The only variable besides the root node I want to adjust for my Dynamic Asset List to effectively cover every single department of my site with the same Asset List is the "Assets Per Page" variable.

I would be able to set it across the site and adjust the number of items shown depending on the frequency of News Items being put up by each department (this place is busy? Give them 10 'current news' items on their front page. This other place is quiet? Give them 2 'current news' items on their front page).

I don't really want departments who only get one or two news-worthy stories every half year having content from years ago on their front page. Always looks like they're inactive, when truthfully they just don't do much content generation of news

Unfortunately I'm having trouble implementing this effectively. I can't seem to find any preset variables as part of the Dynamic Asset List. I currently have tried things in the Type Format such as:
 

%begin_globals_asset_url^contains:archive%
    <li>"I'm in the archive with all news items"
    </li>
%else_asset_position^eq:(1|2|3|4|5)%
    <li>"Only me and the other top 5 news items are here on the front page"
    </li>
%end_asset_position^eq:(1|2|3|4|5)%

My idea being that I tell the Asset List "hey, is this an Archive page? If so just print it all, otherwise only print the top 5". (I would ideally want less than 5 in some cases, but starting out with this "cover all" amount to begin with).

Even if this worked though, it is going to have undesirable load times with all these queries at the item level. Surely it would speed up loading to do the "how much am I listing?" query once at the Asset List level rather than checking the items position every time (?)

 

Actual output:

Asset lister is printing all items with the above conditional query. Both in the Archive area (as intended) and on the front pages (unintended). 

Solutions?

Anyone tried this? I know that I could do two asset lists, one for the Archives page to list all News Items and one for "only 5" for the Front Pages, but as stated earlier, myself and some departments want a more suitable amount on their front pages that reflects the frequency of their content creation.

I can get the "contains:archive" part working, just not the "only show top (X)" part. Would it slow down the Asset List type too much to add this as an embedded feature?

Steps to Recreate:

Standard Dynamic Asset Listing, apart from the example used above. See the actual code below as it contains some more keywords I'm using to assign attributes to each item, however I've tried both the "basic" version above and the one below though and the results are the same:
 

%begin_globals_asset_url^contains:archive%
    <li class="news-wrap mix" data-filter="%asset_metadata_OpinionOrNews_key% %asset_metadata_TypeOfMedia_key^replace:;: %">
        <p>
            <span class="time-stamp">%asset_metadata_PublishedDate%</span><br /> %begin_link_url% <a href="%link_url%">%asset_name%</a> %else_asset% <a href="%asset_url%">%asset_name%</a> %end_asset%
        </p>
    </li>
%else_asset_position^eq:(1|2|3|4|5)%
    <li class="news-wrap mix" data-filter="%asset_metadata_OpinionOrNews_key% %asset_metadata_TypeOfMedia_key^replace:;: %">
        <p>
            <span class="time-stamp">%asset_metadata_PublishedDate%</span><br /> %begin_link_url% <a href="%link_url%">%asset_name%</a> %else_asset% <a href="%asset_url%">%asset_name%</a> %end_asset%
        </p>
    </li>
%end_asset_position^eq:(1|2|3|4|5)%

 

Misc info:

Squiz v5.4.3.0

MAC OSX El Capitan v10.11.6
Chrome Version 52.0.2743.116 (64-bit)

  • Let me know if I should provide anything else to help understand the issue :)

(Peter McLeod) #2
Hi 
 
You could play around with using keyword in the List Formatting > Assets per page section of the listing.
 
Eg if you were nested a single listing in various place, changing the root node, then pass through a get var to it (eg total=3 etc)
 
In the listing set Assets per page to get this value or use a default:
%globals_get_total^empty:10%
Thanks
Peter

(James Porich) #3

Thanks PeterM!
That's actually spot on what I needed (and actually made me realise some more potential power of Dynamic Asset Lists!)

For those playing at home see my set up in the screenshots below.

Note for newbs in the same spot: In my Asset List settings I'm only passing it "rootnode", but in the actual nested content, I'm also passing in a variable that I haven't set anywhere else.

(I thought I had to tell the Asset List in advance what variables I would be using when I embedded it, turns out you can pass it any old thing in the extra GET parameters and then call that value using the "%globals_get_(xyz)%" keyword, only thing you need to set in the list in advance is the Root Node it seems).

This is gonna be so slick now :)

Thanks again!
  Screen Shot 2016-08-15 at 4.09.47 PM.png (226 KB) Screen Shot 2016-08-15 at 4.13.12 PM.png (166 KB) Screen Shot 2016-08-15 at 4.14.00 PM.png (134 KB)