+1
Answered

Block template that only brings in assets that have a child image asset.

Craig V 4 years ago in BLOX CMS • updated by Christine Masters (Director of Product Management) 4 years ago 9
Is there a way to set a block to only include assets that have a child image asset? If not, can this be written in utl? Does anyone have an example?
You could write it in UTL if you're creating your own block pretty easily. 

foreach this.block.assets as asset;
   thumb = core_base_library_assetThumb(asset); /* or however you want to assign the thumbnail to a variable */
   if thumb.url;
       /* do stuff */
   end;
end;

However, since there is a limit to the number of assets a block can pull in a given query, 45 or something like that, you'd be limiting the number of "viable" assets that would qualify to display in your block. 

This is a bit inefficient, of course. For example, say you told the block to pull in 20 assets per your query rules, but only 6 of them have child images. You've asked Blox to make that big query and examine all those assets from the database, but you're only using 6 of them. A bit wasteful, but not too bad. 
+2
Under review
Hey guys, this is good timing! We are actually working on a great way to do this in the software, and will be officially announcing it soon. (So if you don't want to be spoiled, stop reading! :)

In our next big software release, we are adding two new query rules that are really awesome:

1. Has Preview: This rule will specifically grab the assets that have previews associated to them as part of the query rules. Now, in order to do this, we had to change some of the logic behind the "preview" module. Basically, stories will now be considered to have a preview image if their first child has a preview image. That will then return if you ask a story for asset.preview. Note that we only go one "relationship" deep - so if the story's first child is a collection, and that collection doesn't have a preview, we do NOT go to the collection's children to get one.

You will be able to choose items that have a preview image or do not. This "does not have" rule might be useful in a situation where you want to show the items that have a preview asset in a slideshow block, and the items that DO NOT have a preview image in a headline block.



2. Has Parent: I'm really excited about this one, too. For years, we've artificially restricted most blocks to only allow stories. Mostly, this was because many papers will add section tags to photos and videos and other child elements, causing them to display inside normal story blocks, right next to their parent story. This leads to the appearance of duplicate thumbnails occurring side by side - one from the story showing its child image, and one of the child image showing a thumbnail of itself.

This new "has parent" rule means that you can specifically exclude child assets (no matter what type) from showing up in your main story blocks. Then, you can remove the "type = article" restriction of your story blocks and allow standalone videos and photos to flow naturally within your news blocks.



So, if you had a great video of the bridge demolition, you could file that as breaking news, without having to first associate it with an article.

To me, this means videos, images and even things like table assets now have the capacity to become first-class citizens who can stand on their own alongside stories in any block.
Wasn't this one of my feature suggestions? ;)
When will this be released?
Hi Craig... It is still in QA, so I can't tell you a specific time because it is still in flux, etc. But, it is our next major software release.
Great to hear... Keep up the good work!
Find only assets that are not children.... Just watched webinar... Woohoo... doing a dance...
So exciting, right? I went through my dev site first thing in the morning after this release went out and changed all my slideshows to "has preview" and then changed all my story list blocks to "not children" and removed the "asset: article" restriction.

Also, consider a layout where you have several assets at the top that have images in a big display, and then a list of headlines below that for the ones that don't have previews. (i.e. split up the news between items with a preview and those without). For a Calendar page or something, this would be awesome.