Jump to content

How to add duration and HD filters into video lists


Tech Support
 Share

Recommended Posts

Due to the complexity of AJAX filtering in the default theme, we won't explain this in details.  Using this advanced filtering requires deep understanding of default theme JS internals. This is just a working example that can be configured in default theme.

theme_filtering.png.fe1a405a9895861702c4b72645c401bb.png

 

Step 1. In Website UI -> Pages run a search by list_videos to filter out only list_videos blocks. Open every list_videos block and activate the following parameters:

  • var_duration_from = duration_from
  • var_duration_to = duration_to
  • var_is_hd = is_hd

It is recommended to ignore list_videos block named Related Videos and Player Related Videos, as these anyway won't render filtering and changing their parameters may result to performance overload for some period of time.

 

Step 2. In Website UI -> Page components -> include_list_videos_block_common.tpl add the following code under <div class="headline"> after header display:

{{if $duration_from>0}}
	{{assign var="list_videos_custom_sort_parameters" value="`$list_videos_custom_sort_parameters`;duration_from:$duration_from"}}
{{/if}}
{{if $duration_to>0}}
	{{assign var="list_videos_custom_sort_parameters" value="`$list_videos_custom_sort_parameters`;duration_to:$duration_to"}}
{{/if}}
{{if $is_hd==1}}
	{{assign var="list_videos_custom_sort_parameters" value="`$list_videos_custom_sort_parameters`;is_hd:$is_hd"}}
{{/if}}

<div class="sort">
	<span class="icon type-hd"></span>
	<strong>{{if $is_hd==1}}HD{{else}}All{{/if}}</strong>
	<ul id="{{$block_uid}}_hd_list">
		{{if $is_hd==1}}
			<li>
				<a data-action="ajax" data-container-id="{{$block_uid}}_hd_list" data-block-id="{{$block_uid}}" data-parameters="{{if $list_videos_custom_sort_parameters!=''}}{{$list_videos_custom_sort_parameters}};{{/if}}sort_by:{{$sort_by}};is_hd:">All</a>
			</li>
		{{/if}}
		{{if $is_hd==0}}
			<li>
				<a data-action="ajax" data-container-id="{{$block_uid}}_hd_list" data-block-id="{{$block_uid}}" data-parameters="{{if $list_videos_custom_sort_parameters!=''}}{{$list_videos_custom_sort_parameters}};{{/if}}sort_by:{{$sort_by}};is_hd:1">HD</a>
			</li>
		{{/if}}
	</ul>
</div>

<div class="sort">
	<span class="icon type-duration"></span>
	<strong>{{if $duration_to==600}}0-10{{elseif $duration_to==1800}}10-30{{elseif $duration_from==1800}}30+{{else}}Duration{{/if}}</strong>
	<ul id="{{$block_uid}}_duration_list">
		{{if $duration_to>0 || $duration_from>0}}
			<li>
				<a data-action="ajax" data-container-id="{{$block_uid}}_duration_list" data-block-id="{{$block_uid}}" data-parameters="{{if $list_videos_custom_sort_parameters!=''}}{{$list_videos_custom_sort_parameters}};{{/if}}sort_by:{{$sort_by}};duration_from:0;duration_to:0">All</a>
			</li>
		{{/if}}
		{{if $duration_to!=600}}
			<li>
				<a data-action="ajax" data-container-id="{{$block_uid}}_duration_list" data-block-id="{{$block_uid}}" data-parameters="{{if $list_videos_custom_sort_parameters!=''}}{{$list_videos_custom_sort_parameters}};{{/if}}sort_by:{{$sort_by}};duration_from:0;duration_to:600">0-10</a>
			</li>
		{{/if}}
		{{if $duration_to!=1800}}
			<li>
				<a data-action="ajax" data-container-id="{{$block_uid}}_duration_list" data-block-id="{{$block_uid}}" data-parameters="{{if $list_videos_custom_sort_parameters!=''}}{{$list_videos_custom_sort_parameters}};{{/if}}sort_by:{{$sort_by}};duration_from:600;duration_to:1800">10-30</a>
			</li>
		{{/if}}
		{{if $duration_from!=1800}}
			<li>
				<a data-action="ajax" data-container-id="{{$block_uid}}_duration_list" data-block-id="{{$block_uid}}" data-parameters="{{if $list_videos_custom_sort_parameters!=''}}{{$list_videos_custom_sort_parameters}};{{/if}}sort_by:{{$sort_by}};duration_from:1800;duration_to:0">30+</a>
			</li>
		{{/if}}
	</ul>
</div>

 

Step 3. In Website UI -> Page components -> include_pagination_block_common.tpl add the following code in the template beginning:

{{if $duration_from>0}}
	{{assign var="pagination_custom_parameters" value="`$pagination_custom_parameters`;duration_from:$duration_from"}}
{{/if}}
{{if $duration_to>0}}
	{{assign var="pagination_custom_parameters" value="`$pagination_custom_parameters`;duration_to:$duration_to"}}
{{/if}}
{{if $is_hd==1}}
	{{assign var="pagination_custom_parameters" value="`$pagination_custom_parameters`;is_hd:$is_hd"}}
{{/if}}

 

Edited by Tech Support
Bugfix for pagination not working correctly
  • Like 1
Link to comment
Share on other sites

6 hours ago, davex said:

but adding this section shows in all sites, index, new videos in all sites.

Right, it is expected that this filtering will appear everywhere.

 

6 hours ago, davex said:

and the 1 part only putting in 1 site.

Please read this step carefully, it says that you should activate those parameters in all list_videos blocks in all pages, except related videos.

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...