× Warning! This forum is in archival status. New contributions may not work.
How to put a video on the frontpage? (Solved)
  • Hello, 

    I'm customizing the theme Rockstar for my own use. I would like to always provide the most recent video on frontpage. I saw the theme how to view the video in an article. But how to check an article list of any issue or session if there is a video available, and if more recenmte article, make it available?

    Check the code I try to use, but it's not working. I got them from GlobalNews and RockStar.
    <article>

    {{* assign counter and maximum count for collecting multimedia files *}}
    {{assign var=multimediacounter value=0}}
    {{assign var=multimediacountermax value=1}}
    {{ list_articles 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}}
          {{ if $gimme->article->has_attachments }} 
              {{ list_article_attachments }}
                  {{ if $gimme->attachment->extension == ogv || $gimme->attachment->extension == ogg || $gimme->attachment->extension == mp4 || $gimme->attachment->extension == webm }}             
                    {{assign var=multimediacurrent value=1}}
                    {{assign var=multimediatype value='video'}}
                  {{ /if }}  
              {{ /list_article_attachments }}   
          {{ /if }}  
          {{* check now if multimedia found *}}
          {{if $multimediacurrent == 1}}
            {{* add to array with multimedia articles *}}
            {{append var=multimedia value="`$multimediatype`" index="`$gimme->article->number`"}}
    {{append var=videosources value="{{ uri options="articleattachment" }}" index="`$gimme->attachment->extension`"}}
            {{* increase counter to check for max number *}}
            {{ assign "multimediacounter" $multimediacounter+1 }}
          {{/if}}
      {{/if}}
    {{ /list_articles }} 

    <div class="video-attachment aside-box">
       <h2>{{ #watchVideo# }}</h2>
        {{ foreach from=$multimedia key=articleID item=multimediaType name=multimediaLoop }}
    <div class="flowplayer" data-engine="flash" data-swf="{{ url static_file='assets/js/vendor/flowplayer/flowplayer.swf' }}" data-ratio="0.5625">
          <video>
    {{ list_articles ignore_issue="true" ignore_section="true" length="1" constraints="number is `$articleID`"}}
            {{foreach from=$videosources key=extension item=videoSource name=videoLoop}}
    <source src="{{ $videoSource }}" type='video/{{if $extension == flv }}flash{{ elseif $extension == ogv}}ogg{{ else }}{{ $extension }}{{ /if }}'>
    {{/foreach}}
         {{ /list_articles }}
          </video>
    </div>
    {{/foreach}}
    </div>
    </article> 
    Post edited by Augusto Moraes at 2016-04-07 09:06:26
  • 1 Comment sorted by
  • Hello, solved with this:

    At _tpl/_html_head.tpl must have this:

            <link href="{{ url static_file='assets/css/flowplayer_skin/minimalist.css' }}" rel="stylesheet">
        
            <script src="{{ url static_file='assets/js/vendor/flowplayer/flowplayer.min.js' }}"></script>

    At ftont.tpl put this

    <article>  
       
        {{ unset_topic }}
        
            <h2>{{ #watchVideo# }}</h2>
            
            {{ include file="_tpl/multimedia.tpl" }}
            
    </article>

    At _tpl/multimedia.tpl, I've put:

            {{* assign counter and maximum count for collecting multimedia files *}}
            {{assign var=multimediacounter value=0}}
            {{assign var=multimediacountermax value=1}}
            {{ 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=hasvideo value=0}}
                    {{* here we work with article attachments. .oga and .ogv/.ogg files are automatically shown with player in html5 enabled browsers (for video we are including videojs.com's HTML5 player which also plays mp4 and webm formats), all other cases just build the link for download *}}
                    {{ if $gimme->article->has_attachments }}
                        {{ list_article_attachments length="1" }}
                            {{ if $gimme->attachment->extension == ogv || $gimme->attachment->extension == ogg || $gimme->attachment->extension == flv || $gimme->attachment->extension == mp4 || $gimme->attachment->extension == webm }}
                                {{append var=videosources value="{{ uri options="articleattachment" }}" index="`$gimme->attachment->extension`"}}
                                {{assign var = hasvideo value = true}}
                            {{ /if }}
                            {{ if $hasvideo == true }}
                                <div class="video-attachment aside-box"><!-- read http://diveintohtml5.org/video.html -->
         <div class="flowplayer" data-engine="flash" data-swf="{{ url static_file='assets/js/vendor/flowplayer/flowplayer.swf' }}" data-ratio="0.5625">
          <video >
            {{foreach from=$videosources key=extension item=videoSource name=videoLoop}}
            <source src="{{ $videoSource }}" type='video/{{if $extension == flv }}flash{{ elseif $extension == ogv}}ogg{{ else }}{{ $extension }}{{ /if }}'>
            {{/foreach}}
          </video>
        </div>
    </div>
                            {{ /if }}
                    {{ /list_article_attachments }}
                            
                        
                    {{ /if }}
                    {{* check now if multimedia found *}}
                    {{ if $hasvideo == true }}
                        {{* add to array with multimedia articles *}}
                        {{* increase counter to check for max number *}}
                        {{ assign "multimediacounter" $multimediacounter+1 }}
                    {{/if}}
                {{/if}}
            {{ /list_articles }}

    So, that solved my question.