Jump to content

Theme customization: how to show ads inside video lists


Recommended Posts

There are 2 possible ways to show ads in video lists:

  1.  Replacing 1 video with advertising of the same size and visual properties (e.g. width, height and structure to save the list layout). This is also called as native advertising. Use this if you know how to design your ad's layout to look similar to the video item.
  2.  Breaking list into 2 parts and showing advertising between them.

In both cases you should edit the following template: Website UI -> Page components -> include_list_videos_block_common.tpl. This template has the following iteration to display all list items:

{{foreach item="item" from=$data}}
   <div class="item ....">
   ... some list item rendering appears here
   </div>
{{/foreach}}

 

IMPORTANT! You should give a name to this iteration:

{{foreach item="item" name="videos" from=$data}}

 

Replacing specific item(s) with native advertising

If you want to replace one item (#3) with advertising change this code to look like this:

{{foreach item="item" name="videos" from=$data}}
   {{if $can_manage!=1 && $smarty.foreach.videos.iteration==3}}
       {{insert name="getAdv" place_id="spot_advertising_video_list_item"}}
   {{else}}
       <div class="item ....">
       ... some list item rendering appears here
       </div>
   {{/if}}
{{/foreach}}

 

This will insert advertising spot with external ID spot_advertising_video_list_item into the template. Right now there is no such advertising spot, so you should go and create it in Website UI -> Advertising -> Add spot. You should also add advertising into this new spot so that it appeared instead of 3rd video item. If you don't add advertising to this spot or don't create it, every video list will just skip rendering item #3 and will render less items than expected.

IMPORTANT! Please make sure you also add a closing {{/if}} tag before closing {{/foreach}} tag to not break template syntax.

This code fix replaces third video item on every public video list, including related videos, videos by category, index and etc. If you want to replace only on index, change {{if}} to this:

{{if $can_manage!=1 && $smarty.foreach.videos.iteration==3 && $page_id=='index'}}

 

If you want to replace everywhere EXCEPT related videos change {{if}} to this:

{{if $can_manage!=1 && $smarty.foreach.videos.iteration==3 && $page_id!='view_video'}}

 

If you want to replace ONLY on related videos change {{if}} to this:

{{if $can_manage!=1 && $smarty.foreach.videos.iteration==3 && $page_id=='view_video'}}

 

Finally, if you want to replace 2 videos with native ads, here the code:

{{foreach item="item" name="videos" from=$data}}
   {{if $can_manage!=1 && $smarty.foreach.videos.iteration==3}}
       {{insert name="getAdv" place_id="spot_advertising_video_list_item1"}}
   {{elseif $can_manage!=1 && $smarty.foreach.videos.iteration==4}}
       {{insert name="getAdv" place_id="spot_advertising_video_list_item2"}}
   {{else}}
       <div class="item ....">
       ... some list item rendering appears here
       </div>
   {{/if}}
{{/foreach}}

 

NOTE: each video item should be replaced individually with an individual ad. It is not possible to replace 2 video items with a single 'wide' ad, because it won't be rendered correctly on all types of devices. Therefore in the last example we used 2 different advertising spots with different IDs.

 

Inserting advertising in between video lines

The key thing here is to understand that it is not possible to insert advertising each 3 or 4 videos, for example. This is because list layout is adaptive and for some devices in can be 4 in a row, for other devices 3 in a row and for smaller devices it can be 2 or 1 in a row.

Therefore with such layout it makes sense to show advertising after each 12 items. Here is how:

{{foreach item="item" name="videos" from=$data}}
   <div class="item ....">
   ... some list item rendering appears here
   </div>
   {{if $can_manage!=1 && $smarty.foreach.videos.iteration==12}}
       {{insert name="getAdv" place_id="spot_advertising_video_list_item"}}
   {{/if}}
{{/foreach}}

 

This will insert advertising spot with external ID spot_advertising_video_list_item into the template. There is no such advertising spot by default, so you should go and create it in Website UI -> Advertising -> Add spot.

If you want to show after 12 and 24 items, then the code should be changed to this:

{{foreach item="item" name="videos" from=$data}}
   <div class="item ....">
   ... some list item rendering appears here
   </div>
   {{if $can_manage!=1 && $smarty.foreach.videos.iteration==12}}
       {{insert name="getAdv" place_id="spot_advertising_video_list_item1"}}
   {{elseif $can_manage!=1 && $smarty.foreach.videos.iteration==24}}
       {{insert name="getAdv" place_id="spot_advertising_video_list_item2"}}
   {{/if}}
{{/foreach}}
 
  • Like 1
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.

×
×
  • Create New...