Jump to content

Theme customization: how to show categories with videos on index page


Tech Support

Recommended Posts

The following can be done with just few steps in KVS:

example.thumb.png.dfcde456b4cb100018a014c971d32594.png

 

Step 1. Go to Website UI -> Pages -> Index page editor and insert list_categories block into the desired place in page template:

{{insert name="getBlock" block_id="list_categories" block_name="Categories And Videos"}}

Save.

 

Step 2. Now you should see Categories And Videos block in the list of blocks on Index page. Open it for editing and configure the following settings:

  • Cache lifetime (s): 3600
  • items_per_page (Integer): set 0 if you want to display all categories; otherwise set the max number of categories
  • sort_by (Sorting): configure sorting as needed
  • pull_videos (On/Off): enable
  • pull_videos_count (Integer): set the number of videos for each category (in our example it is 3)
  • pull_videos_sort_by (Sorting): set sorting for videos under each category

NOTE: if you want that only certain subset of categories are displayed, you may need to enable some filters under Static filters parameters.

In Template code specify this code (the code is given for KVS default theme and 5.2.0 version, it may not work in earlier versions):

{{foreach item="item_category" from=$data}}
    <div class="headline">
        <h2>{{$item_category.title}}</h2>
    </div>

    <div class="box">
        <div class="list-videos">
            <div class="margin-fix" id="{{$block_uid}}_items">
                {{if count($item_category.videos)>0}}
                    {{foreach item="item" from=$item_category.videos}}
                        <div class="item {{if $item.is_private==1}}private{{elseif $item.is_private==2}}premium{{/if}} {{if $item.status_id==0}}disabled{{elseif $item.status_id==2}}error{{elseif $item.status_id!=1}}processing{{/if}}">
                            <a {{if $item.view_page_url!=''}}href="{{$item.view_page_url}}"{{/if}} title="{{$item.title}}" {{if $item.rotator_params!=''}}data-rt="{{$item.rotator_params|replace:"pqr=":""}}"{{/if}}>
                                <div class="img">
                                    {{if $item.status_id==0 || $item.status_id==1}}
                                        <img class="thumb {{if $lang.enable_thumb_lazyload=='true'}}lazy-load{{/if}}" {{if $lang.enable_thumb_lazyload=='true'}}src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-original{{else}}src{{/if}}="{{$item.screen_url}}/{{$lang.videos.thumb_size}}/{{$item.screen_main}}.jpg" {{if $lang.videos.thumb_size_webp}}data-webp="{{$item.screen_url}}/{{$lang.videos.thumb_size_webp}}/{{$item.screen_main}}.jpg"{{/if}} alt="{{$item.title}}" {{if $lang.enable_thumb_scrolling=='true'}}data-cnt="{{$item.screen_amount}}"{{/if}} {{if $item.is_private==0 && $item.formats[$lang.videos.preview_video_format_standard].file_path!=''}}data-preview="{{$config.project_url}}/get_file/{{$item.server_group_id}}/{{$item.formats[$lang.videos.preview_video_format_standard].file_path}}/"{{/if}} {{if $item.is_private==2 && $item.formats[$lang.videos.preview_video_format_premium].file_path!=''}}data-preview="{{$config.project_url}}/get_file/{{$item.server_group_id}}/{{$item.formats[$lang.videos.preview_video_format_premium].file_path}}/"{{/if}} width="{{$lang.videos.thumb_size|geomsize:'width'}}" height="{{$lang.videos.thumb_size|geomsize:'height'}}"/>
                                    {{/if}}
                                    {{if $item.is_private==1}}
                                        <span class="line-private"><span class="ico-private">{{$lang.videos.list_label_private}}</span></span>
                                    {{elseif $item.is_private==2}}
                                        <span class="line-premium"><span class="ico-premium">{{$lang.videos.list_label_premium}}</span></span>
                                    {{/if}}
                                    {{if $item.status_id==1}}
                                        {{if $lang.enable_memberzone=='true'}}
                                            {{foreach item="fav_index" from=$lang.videos.predefined_favourites}}
                                                <span class="ico-fav-{{$fav_index}}" title="{{$lang.videos.list_action_add_to_favourites[$fav_index]}}" data-fav-video-id="{{$item.video_id}}" data-fav-type="{{$fav_index}}"></span>
                                            {{/foreach}}
                                        {{/if}}
                                    {{/if}}
                                    {{if $item.is_hd==1}}<span class="is-hd">HD</span>{{/if}}
                                </div>
                                <strong class="title">
                                    {{if $lang.videos.truncate_title_to>0}}
                                        {{$item.title|truncate:$lang.videos.truncate_title_to:"...":true}}
                                    {{else}}
                                        {{$item.title}}
                                    {{/if}}
                                </strong>
                                <div class="wrap">
                                    <div class="duration">{{$item.duration_array.text}}</div>

                                    {{assign var="object_rating" value="`$item.rating/5*100`"}}
                                    {{if $object_rating>100}}{{assign var="object_rating" value="100"}}{{/if}}
                                    <div class="rating {{if $object_rating>=50 || $object_rating==0}}positive{{else}}negative{{/if}}">
                                        {{$object_rating|string_format:"%d"}}%
                                    </div>
                                </div>
                                <div class="wrap">
                                    {{assign var="added_date" value=$item.post_date}}
                                    {{if $mode_favourites==1}}
                                        {{assign var="added_date" value=$item.added2fav_date}}
                                    {{elseif $mode_purchased==1}}
                                        {{assign var="added_date" value=$item.purchase_date}}
                                    {{/if}}
                                    <div class="added"><em>{{$added_date|date_format:$lang.global.date_format}}</em></div>
                                    <div class="views">{{$item.video_viewed|traffic_format}}</div>
                                </div>
                            </a>
                        </div>
                    {{/foreach}}
                {{else}}
                    <div class="empty-content">{{$list_videos_empty_message|default:$lang.common_list.no_data}}</div>
                {{/if}}
            </div>
        </div>
        {{if count($item_category.videos)>0}}
            <div class="load-more">
                <a href="{{$lang.urls.videos_by_category|replace:"%DIR%":$item_category.dir|replace:"%ID%":$item_category.category_id}}">{{$lang.common_list.load_more}}</a>
            </div>
        {{/if}}
    </div>
{{/foreach}}

 

 

  • Like 1
Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...