Announcement

Collapse
No announcement yet.

Theme customization: showing categories, tags, etc. for each video / album in list

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Theme customization: showing categories, tags, etc. for each video / album in list

    In KVS list_videos and list_albums blocks won't select categories, tags, models, user or content source information by default for each video / album. This is due to performance restrictions, since in most cases such data is not needed when rendering lists. However when needed it can be enabled and displayed.

    Each list_videos / list_albums (and some other list_xxx) block supports a set of show_xxx_info parameters to enable selecting any specific additional data you need: Click image for larger version  Name:	show_xxx_info.png Views:	1 Size:	15.8 KB ID:	319

    You should enable only the needed data loading, as it may significantly reduce your site performance.

    An issue here is that usually project contains multiple pages with list_videos / list_albums blocks. If you want this functionality to work consistently, you should enable the same options in almost all places. The most easy way to find pages with specific blocks is to search for block type, for example list_videos: Click image for larger version  Name:	search_for_list_videos.png Views:	1 Size:	19.0 KB ID:	320

    You can see a plenty of list_videos blocks in your theme (Index, Common Videos List, Community, RSS, Sitemap, View Video pages and etc).
    Here are 3 places where you DON'T need this:
    - RSS Videos (XML)
    - [System] Sitemap (XML)
    - [System] Player Related Videos

    In all other blocks you may need to enable the same set of options to load additional data. Or if you want this to be visible on specific pages only (e.g. Index), then enable only there.

    The next step is to update template code to render additional data for each video. This code should be normally put into Website UI -> Page Components -> include_list_videos_block_common.tpl, which renders all video lists in your theme. This component will have some template code on top with rendering list title / sortings / filters, and then 2nd part is the actual list rendering enclosed into the following {{foreach}} tag:

    HTML Code:
    {{foreach item="item" from=$data}}
    ... each iteration renders one item here ...
    {{/foreach}}
    You should put your rendering code inside this {{foreach}} if you want it to be rendered for every item.
    Here are ready codes you can copy-paste. However you should consider your own styling for this, as rendering such additional info is not supported by theme styling.

    NOTE: for categories, tags and models if you want to limit the max number of displayed items you should set this limit into {{assign var="max_limit" value="0"}} value. Using zero means no limit, e.g. the code will display even 10 or 20 tags if they are all attached to a video or album.

    1. Categories:
    HTML Code:
    Categories:
    {{assign var="max_limit" value="0"}}
    {{assign var="index_limit" value="0"}}
    {{assign var="limit_over" value="0"}}
    {{foreach from=$item.categories item="category" name="categories"}}
        {{if $max_limit>0}}
            {{assign var="index_limit" value=$index_limit+1}}
        {{/if}}
        {{if $index_limit<=$max_limit}}
            <a href="{{$lang.urls.videos_by_category|replace:"%DIR%":$category.dir|replace:"%ID%":$category.category_id}}">{{$category.title}}</a>{{if !$smarty.foreach.categories.last}}, {{/if}}
        {{elseif $limit_over==0}}
            ...
            {{assign var="limit_over" value="1"}}
        {{/if}}
    {{/foreach}}
    2. Tags:
    HTML Code:
    Tags:
    {{assign var="max_limit" value="0"}}
    {{assign var="index_limit" value="0"}}
    {{assign var="limit_over" value="0"}}
    {{foreach from=$item.tags item="tag" name="tags"}}
        {{if $max_limit>0}}
            {{assign var="index_limit" value=$index_limit+1}}
        {{/if}}
        {{if $index_limit<=$max_limit}}
            <a href="{{$lang.urls.videos_by_tag|replace:"%DIR%":$tag.tag_dir|replace:"%ID%":$tag.tag_id}}">{{$tag.tag}}</a>{{if !$smarty.foreach.tags.last}}, {{/if}}
        {{elseif $limit_over==0}}
            ...
            {{assign var="limit_over" value="1"}}
        {{/if}}
    {{/foreach}}
    3. Models:
    HTML Code:
    Models:
    {{assign var="max_limit" value="0"}}
    {{assign var="index_limit" value="0"}}
    {{assign var="limit_over" value="0"}}
    {{foreach from=$item.models item="model" name="models"}}
        {{if $max_limit>0}}
            {{assign var="index_limit" value=$index_limit+1}}
        {{/if}}
        {{if $index_limit<=$max_limit}}
            <a href="{{$lang.urls.videos_by_model|replace:"%DIR%":$model.dir|replace:"%ID%":$model.model_id}}">{{$model.title}}</a>{{if !$smarty.foreach.models.last}}, {{/if}}
        {{elseif $limit_over==0}}
            ...
            {{assign var="limit_over" value="1"}}
        {{/if}}
    {{/foreach}}
    4. Content source:
    HTML Code:
    Sponsor:
    {{if $item.content_source.content_source_id>0}}
        <a href="{{$lang.urls.videos_by_sponsor|replace:"%DIR%":$item.content_source.dir|replace:"%ID%":$item.content_source.content_source_id}}">{{$item.content_source.title}}</a>
    {{/if}}
    5. Channel:
    HTML Code:
    Channel:
    {{if $item.dvd.dvd_id>0}}
        <a href="{{$lang.urls.videos_by_channel|replace:"%DIR%":$item.dvd.dir|replace:"%ID%":$item.dvd.dvd_id}}">{{$item.dvd.title}}</a>
    {{/if}}
    6. User:
    HTML Code:
    Uploaded by:
    {{if $item.user.user_id>0}}
        <a href="{{$lang.urls.memberzone_profile|replace:"%ID%":$item.user.user_id|replace:"%LOGIN%":$item.user.username}}">
            {{if $lang.memberzone.truncate_username_to>0}}
                {{$item.user.display_name|truncate:$lang.memberzone.truncate_username_to:"...":true}}
            {{else}}
                {{$item.user.display_name}}
            {{/if}}
        </a>
    {{/if}}
Working...
X