I have a question, is there a way to list all the multimedia (video, audio and pictures) so I can be able to merge them into something like the screenshot below where audio, video and pictures are mixed together ordered by date and not separated between media type?
This does it. I commented the code. The logic: first list a larger number of articles for media. Put a limited number in an array. Then you can use this array to list the articles with the list_article statement, which is needed to get access to the image renditions.
{{* assign counter and maximum count for collecting multimedia files *}} {{assign var=multimediacounter value=0}} {{assign var=multimediacountermax value=10}} {{ list_articles length="100" ignore_issue="true" ignore_section="true" order="bypublishdate desc" }} {{* check if we have to do anything => not yet hit maximum *}} {{if $multimediacounter lt $multimediacountermax}} {{* assign variable for current article. 1 => has multimedia *}} {{assign var=multimediacurrent value=0}} {{ foreach $gimme->article->slideshows as $slideshow }} {{assign var=multimediacurrent value=1}} {{ /foreach }} {{ if $gimme->article->has_attachments }} {{ list_article_attachments }} {{ if $gimme->attachment->extension == oga }} {{assign var=multimediacurrent value=1}} {{ elseif $gimme->attachment->extension == ogv || $gimme->attachment->extension == ogg || $gimme->attachment->extension == mp4 || $gimme->attachment->extension == webm }} {{assign var=multimediacurrent value=1}} {{ /if }} {{ /list_article_attachments }} {{ /if }} {{* check now if multimedia found *}} {{if $multimediacurrent == 1}} {{* add to array with multimedia articles *}} {{append var=multimedia value="yes" index="`$gimme->article->number`"}} {{* increase counter to check for max number *}} {{$multimediacounter++}} {{/if}} {{/if}} {{ /list_articles }} {{* spit out what we found *}} {{$multimedia|@print_r}} {{* this is the resulting article list *}} {{foreach from=$multimedia key=articleID item=articleName}} {{ list_articles ignore_issue="true" ignore_section="true" length="1" constraints="number is `$articleID`"}} <li>Section:{{ $gimme->section->name }} | ID:{{$articleID}}: {{ $gimme->article->name }}</li> {{ /list_articles }} {{/foreach}}
I usually do it with switch. So any article with switch set to on is visible in multimedia list. That way You can easily choose what You want to show even if there is youtube embed in article body.
Code for listing will look like:
{{list_articles ignore_section="true" constraints="multimedia is on"}}
I believe it should be possible to write a little smarty magic with assigning vars running through these loops and collect what is a multimedia article. I have no time to do it right now. Possibly in the afternoon.
A quick update, I've made it work but there is one issue with the code in the line:
{{$multimediacounter++}}
that will print out the counter into the template generating numbers like 0 1 2 3 4 .. on the top of the multimedia slider, is there a way to use the ++ increment and not print it out?
Yes, Ljuba is right and this is the resulting code:
{{* assign counter and maximum count for collecting multimedia files *}} {{assign var=multimediacounter value=0}} {{assign var=multimediacountermax value=10}} <h3>Alle Artikel</h3> {{ list_articles length="100" ignore_issue="true" ignore_section="true" order="bypublishdate desc" }} {{* check if we have to do anything => not yet hit maximum *}} {{if $multimediacounter lt $multimediacountermax}} {{* assign variable for current article. 1 => has multimedia *}} {{assign var=multimediacurrent value=0}} {{ foreach $gimme->article->slideshows as $slideshow }} {{assign var=multimediacurrent value=1}} {{ /foreach }} {{ if $gimme->article->has_attachments }} {{ list_article_attachments }} {{ if $gimme->attachment->extension == oga }} {{assign var=multimediacurrent value=1}} {{ elseif $gimme->attachment->extension == ogv || $gimme->attachment->extension == ogg || $gimme->attachment->extension == mp4 || $gimme->attachment->extension == webm }} {{assign var=multimediacurrent value=1}} {{ /if }} {{ /list_article_attachments }} {{ /if }} {{* check now if multimedia found *}} {{if $multimediacurrent == 1}} {{* add to array with multimedia articles *}} {{append var=multimedia value="yes" index="`$gimme->article->number`"}} {{* increase counter to check for max number *}} {{ assign "multimediacounter" $multimediacounter+1 }} {{/if}} {{/if}} {{ /list_articles }}
{{* spit out what we found *}} {{$multimedia|@print_r}} {{* this is the resulting article list *}} {{foreach from=$multimedia key=articleID item=articleName}} {{ list_articles ignore_issue="true" ignore_section="true" length="1" constraints="number is `$articleID`"}} <li>Section:{{ $gimme->section->name }} | ID:{{$articleID}}: {{ $gimme->article->name }}</li> {{ /list_articles }} {{/foreach}}