KVS Documentation

Frequently Asked Questions

Contents

1. Troubleshooting
1.1. I added a video, but I don't see it on the site.
1.2. I deactivated a video, but I can still see it when I open the URL. I need it to be not available via the URL.
1.3. I added a few videos to a category, but the category list still shows me this category has 0 videos (or less videos than I think it should have).
1.4. I created a timeline screenshot format and selected it in player settings, but I still don't see timeline screenshots on the site.
1.5. Background task processing looks frozen.
1.6. I don't like the screenshot quality. How do I adjust it?
1.7. Overload protection is triggered a lot. My admins did not see any issues.
1.8. After I save data in the admin area, all quotation marks get / before them.
1.9. I disabled comment approval, but comments are still shown in the pending approval list.
1.10. I lost my admin area password, how do I reset it?
1.11. Some MP4 files do not play. I cannot download them to check.
1.12. In the video list, ?pqr=string was added to the links. Where did it come from and how do I get rid of it?
1.13. I do not want the videos I upload to be converted, but they still are.
1.14. Large files would not upload.
2. Managing Content, Videos, Photo Albums
2.1. Using trailer duration as video duration.
2.2. I want to create FHGs that would have 4 1-minute fragments for each video.
2.3. I want to modify format settings, but KVS would not let me do this because there are background tasks running. Can I bypass this?
2.4. How do I move videos to another server correctly?
2.5. How do I add a second HDD for video storage?
2.6. Can third party webmasters upload content and set custom ads for video pages?
2.7. What is the right way to add a video format?
3. Player and Player-Related Issues
3.1. How do I send my own embed code to the player on the site? I want to use non-standard code.
3.2. I do not want visitors to be able to copy the embed codes for my videos from the player.
3.3. How do I display embed codes in RSS?
3.4. How do I switch to the new iframe embed code format having updated to 3.5.0?
3.5. How do I switch to the new related videos format having updated to 3.9.0?
4. Managing Your Site, Templates, and Data Output
4.1. How do I change the way links to video or photo album pages look in the lists?
4.2. I want to customize values in page header, e.g. title, description, and/or keywords.
4.3. How do I display ads from custom fields of content sources on video pages?
4.4. How do I display ads after 12th and 24th thumbnails on video list pages?
4.5. I want to build a tree of categories. How do I use categories with same names in different groups?
4.6. In a template, I want to display HTML code from an custom field of a category so that it becomes part of the page.
4.7. In video lists, how do I change the number of thumbnails in a row?
4.8. In video lists, how do I modify thumbnail size?
4.9. How do I display the number of likes videos or albums have instead of ratings?
4.10. How do I show video download links in video lists?
4.11. How do I change date format?
4.12. How do I use category name in video page titles?
4.13. On my index page, I want to show screenshots of a different size compared to my other pages. Is it possible?
4.14. How do I add next / previous links for related videos so that they scroll without the page reloading?
4.15. On video / photo album pages, how do I display % of visitors who voted for the 'I like it' flag without using ratings?
4.16. What are the pagination options for my site?
4.17. How do I display video screenshots on the video page and on the video list page?
4.18. In video lists by category, how do I display category-specific ads?
4.19. How do I use different code in headers of different pages?
4.20. How do I make lists of videos by tags look different than other lists on the site?
4.21. Can my visitors add model data to my content?
4.22. Can content be added to playlists? Can system favourites be expanded?
4.23. On video / photo album pages, how do I enable token-based access purchases?
4.24. How do I enable voting for user comments?
4.26. How do I enable bb-codes and emoticons in comments?
4.27. How do I migrate the design from one site to another?
5. Customization
5.1. How do I connect a script counting incoming hits for traffic trade?
5.2. How do I make my trade links look nicer?
5.3. How do I include my custom PHP script in templates?
6. KVS Infrastructure
6.1. How do I move my site to another server?
6.2. How do I move a site from a subfolder to the root folder of a domain?
6.3. How do I build a mobile version of my site?
6.4. How do I restore my site from a backup I created with the KVS plugin?
6.5. How do I configure file uploads via subdomain when running under CloudFlare?

1. Troubleshooting

1.1. I added a video, but I don't see it on the site.

Videos and photo albums appear on your site when both these conditions are met:

  • The item's status is set to Active.
  • The date and time when the video or album should be posted (the 'post date' field) is less than current server time, i.e. the posting time has come.

Most likely, in your situation the posting time has not come yet, and the item will appear later. Also, the item can be inactive. Another reason, you may be seeing a cached site page if you visit the site using not the browser you used to log into the admin panel.

1.2. I deactivated a video, but I can still see it when I open the URL. I need it to be not available via the URL.

This has a purpose. Inactive videos and photo albums remain available via direct URLs, and they are not shown on other site pages, e.g. in lists. To disable access to an item via the URL, do one of the following:

  • Delete the item.
  • Set the posting date to far future (e.g. in 10 years).
  • In Settings -> Website settings configure 404 error under Disabled content availability option.

Please note that if you choose option 2 or 3, you will still be able to see the videos or photo albums if you use the browser in which you are logged into the admin panel. Use a different browser to check item availability.

Also, please remember all pages and blocks are cached by the site's engine. By default, the cache of a video page 'lives' for 24 hours. If you deactivated a video, the page may stay available for a while until the cache expires.

1.3. I added a few videos to a category, but the category list still shows me this category has 0 videos (or less videos than I think it should have).

This behavior is normal for all categorization objects, including categories, tags, models, and content sources. Any list of these objects on your site can show total related videos/albums, and related videos/albums added today. In order to optimize server load, these figures are updated with a 8-hour delay regardless of what value the page cache lifetime is set to. Thus, these figures will be recalculated within 8 hours max.

Also, total number of related videos and photo albums is calculated taking into account their status and posting date, i.e. only active items posted in the past are counted.

1.4. I created a timeline screenshot format and selected it in player settings, but I still don't see timeline screenshots on the site.

If you want your site to show timeline screenshots, first, you need to enable their creation in the settings of the video format you want them created for (Settings -> Video Formats -> Edit Format):

Timeline screenshots in video format settings
Timeline screenshots in video format settings.

When you enable timeline screenshots in video format settings, it may take a long time for them to be created if you already have videos in that format. For each video, a background timeline screenshot creation task will be launched. You can always see all current background tasks in Administration -> Background Tasks. If you want to check whether this or that video has timeline screenshots, in the admin panel, go to the video edit page (Videos -> Videos -> Edit Video). This page shows you all the formats of this video. For any format that has timeline screenshots, you will see how many screenshots are there. If you don't see this number, it means the video currently has no timeline screenshots:

Total timeline screenshots for a video.
Total timeline screenshots for a video..

If for any reasons you deleted the background timeline screenshot creation tasks before they were completed, it is possible that even though these screenshots are enabled for a particular format, they have not been created for all your videos. This is easy to fix. Just go to video format settings, uncheck the timeline screenshot option, and save the changes. After that, check this option back again and save the format. When you check the option, KVS launches new background tasks that create timeline screenshots for videos that don't have them.

1.5. Background task processing looks frozen. The admin panel shows the tasks are pending, but it has been almost 24 hours.

Most likely reason is that your conversion engine is frozen because of an error. There may be different causes for that, mostly related to downloading or uploading files to third party sites. To check this, you need to have a look at the conversion engine log. Go to Administration -> Installation Info in the administration panel. In the bottom of the page, you will see the list of all logs. You need the file named cron_conversion.txt:

System log list
System log list.

If the last event was logged many hours ago, it means the engine is frozen. You will need shell access to fix this. Kill the PHP process that handles the cron_conversion.php script.

Other possible situations when your background tasks may get frozen:

  • Primary cron engine is not working. In this case, there should be an error notification on your start page. Check your server cron settings to see if the correct command launching it once every minute is set up. Go to Administration -> Installation Info to find out about the format of this command.
  • There were problems while connecting to conversion or storage server(s). In this case, the start page will also show error notfifications. Go to storage server list or to conversion settings in Settings for details.

1.6. I don't like the screenshot quality. How do I adjust it?

You can manage your screenshot quality from 2 locations:

  • In screenshot formats, the ImageMagick option string contains the quality parameter: -quality 92
  • In the /admin/include/setup.php file, the global quality setting is set. It is used for intermediary tasks. The string looks like this: $config['imagemagick_default_jpeg_quality']="85";

1.7. Overload protection is triggered a lot. My admins did not see any issues.

Usually the protection is triggered because the LA value goes up rapidly. You can set custom thresholds so that the protection is not triggered so often. Ask your server administrators to determine the optimal LA for your server. By default, KVS sees any LA below 10 as normal.

To customize the thresholds, edit the following 3 settings in the /admin/include/setup.php file:

// If LA > 30, blocks are not generated, only cached versions are working.
$config['overload_max_la_blocks']=30;

// If LA > 50, site responds with overloaded error.
$config['overload_max_la_pages']=50;

// If LA > 10, background tasks stop working.
$config['overload_max_la_cron']=10;

1.8. After I save data in the admin area, all quotation marks get / before them.

It happens because the magic_quotes_gpc directive is enabled in your PHP configuration. Ask your server administrators to disable it.

1.9. I disabled comment approval, but comments are still shown in the pending approval list.

This is normal. When comment approval is disabled (the need_approve parameter of the comments block), comments will appear on the site without having to be approved by site admin. However, they will also be shown in pending approval list so that the administrator can check new comments and delete some if necessary. In any case, when the need_approve parameter is disabled, the comments are seen on the site right away.

KVS works similarly with all other user content that is uploaded to your site.

1.10. I lost my admin area password, how do I reset it?

Reset your superadministrator username and password by using the password reset script:

http://kernel-scripts.com/files/reset_admin_password.zip

You will need to copy the PHP file from this archive to your site's root folder and launch this script from the web. After that, username and password will be set to admin / 123. Remember to delete the script afterwards.

1.11. Some MP4 files do not play. I cannot download them to check.

If this happens only to some files, the problem lies in the files themselves. Most likely, you uploaded a file directly as an MP4 format file (and not as a source file). Even though the file had the MP4 extension and could be played back, it was not a valid MP4 container. During conversion, this issue was not detected, as KVS does not check whether video containers are valid files of their format.

As a result, conversion was successful, screenshots have been created, and the video still cannot be played. You need to re-create this video uploading the file as a source file, not as a MP4 video file. The engine will process the video, and a valid MP4 movie will be created.

1.12. In the video list, ?pqr=string was added to the links. Where did it come from and how do I get rid of it?

These parameters are added by the rotator to detect location and screenshot on which the click was made. These parameters appear automatically when rotator is enabled. In the list_videos block code, they are displayed together with the link to the video page, when the {{$item.view_page_url}} is used. To get rid of these, you can use the built-in JavaScript function that sends click data asynchronously (versions 3.0 upwards). However, to achieve this, you will need to make changes to your templates and to KVS configuration. You can find the page components that will be edited further on in the admin panel: Website UI - > Page components.

First, you need to edit the list_videos_block_common.tpl page component. Thus this change will only affect the list_video blocks that actually use this component. If you use other templates that display HTML code of video lists, you will need to include them as well. In all the links where {{$item.view_page_url}} is used as the URL you need to add the data-rt attritube. This is how links to your video pages are supposed to look:

<a href="{{$item.view_page_url}}" data-rt="{{$item.rotator_params}}" ...

Important! In the list_videos_block_common.tpl component, there are several links to the video view page ({{$item.view_page_url}}). You need to add the data-rt attruitube to all these links. Only clicks on links with this attribute will be counted.

Then, in your site's footer (by default it is the footer_general.tpl component), you need to add this JavaScript code:

<script type="text/javascript">
    rotatorEnableLinks(true, 'videos');
</script>

When this function is called, event handler will be added for each link with a non-empty data-rt attribute. When the link is clicked, data will be sent to the server. Last thing to do, let the rotator know it no longer needs to add the ?pqr parameter to all video links. Add this line somewhere in the bottom of the /admin/include/setup.php file, or, if the line already exists there, change false to true:

$config['rotator_no_params']="true";

1.13. I do not want the videos I upload to be converted, but they still are.

KVS lets you upload videos 'as is', without any processing. However, they need to be uploaded as videos of a specific format, not as source files. You can upload videos of specific formats both manually and with bulk importing.

In your case, the most likely reason is that you upload your files as source files. In this situation, the engine converts them to files of certain video formats that are later shown on your site.

1.14. Large files would not upload.

If your project works under CloudFlare, please see question 6.5.

You may find file upload limits in several configurations:

  • The root .htaccess file, with default 2,000 Mbyte limits: php_value upload_max_filesize 2000M
    php_value post_max_size 2000M
  • If your .htaccess files disable overriding PHP options, these strings will be disabled or deleted. In this case, you can only customize the limits in your primary PHP configuration file (php.ini).
  • If your server is powered by Nginx, which it probably is, there are limitations on the Nginx level. In Nginx configuration, the client_max_body_size may be used to set these limitations.

2. Managing Content, Videos, Photo Albums

2.1. I upload long videos as source files, and 3-minute trailers are created. However, video duration is set to the original source file duration (not 3 minutes), which is wrong for my site.

By default, video duration is always defined by the source file. If you need your duration to be set based on a file of a certain format, you need to select that format in Detect video duration from option. You will find this option in Settings -> Content Settings:

Setting your video duration
Setting your video duration.

2.2. I want to create FHGs that would have 4 1-minute fragments for each video.

Yes, you can do this. You need to create 4 different video formats with similar postfixes, e.g. free1.mp4, free2.mp4, free3.mp4 and free4.mp4. For each format, in limit settings, you need to set a 1-minute duration limit. Also, you need to set up offsets in % depending on format:

  • Format 1: offset from beginning - 0%, offset from end - 75%.
  • Format 2: offset from beginning - 25%, offset from end - 50%.
  • Format 3: offset from beginning - 50%, offset from end - 25%.
  • Format 4: offset from beginning - 75%, offset from end - 0%.
Setting duration limits for format 2
Setting duration limits for format 2.

Thus you will get 4 videos, each 1 minute long, and each video will be a fragment of the original video starting from a certain point. If you need 2, 3, or 5 videos like this, the concept stays the same, only the % values change.

2.3. I want to modify format settings, but KVS would not let me do this because there are background tasks running. Can I bypass this?

In situations like this, you need to use the pause mode. Go to Settings -> Content Settings to enable it. Then, you need to wait until all existing tasks are completed. After that, in the top of your admin panel where total tasks are shown, you will see a notification saying the conversion engine is in pause mode. Now you can make changes to your format settings and disable the pause mode when you are done.

Enabling pause mode
Enabling pause mode.
Pause mode enabled
Pause mode enabled.

2.4. How do I move videos to another server correctly?

Before you start moving videos, you need to set the conversion engine to pause mode to prevent processing new videos that may be added while files are being copied (see question 2.3).

Videos are stored on server A in /path/to/contents/videos. The path to this folder is set in storage server settings in the KVS admin panel, or in FTP server settings, if you use a remote storage server (Settings -> Storage Servers -> Edit Server A).

Path to storage folder for local storage server
Path to storage folder for local storage server.

You need to copy the contents of this folder on server A to server B. The contents are essentially a structure of files and subfolders. You can copy these to any folder, not necessarily to /path/to/contents/videos. The resulting files and folders need to have the same owner that will be used to connect to server B. Thus this owner will always have sufficient permissions to delete files and folders as well as create new ones.

Then, when you are done copying files, in KVS admin panel, you need to add server B to the same server group as server A. You need to specify the path to the folder where you have copied the files (or the FTP connection to this folder). After you add a new server to the group, the system tests how random files are served. If you copied the files to a wrong location or the settings are incorrect, you will get error notifications.

After you add server B, it will show on the list as disabled. No content will be served from it so far. Before you enable it, you need to make sure the content is served without errors. To do this, use the Test content serving option in the context menu of this server in the server list. When you enable server B, you can temporarily disable server A to see how your site works with just one server. Go to server group settings to enable or disable serving content from your content servers:

Disabling content serving for server A and enabling server B
Disabling content serving for server A and enabling server B.

Also, we recommend launching full content check in the audit plugin. All files will be checked. When after a while you see that all files are where they should be, you can delete server A from the system.

Important! If you leave your old storage server in inactive mode, content will still be copied to it even though no content will be served from it. If you do not need to store files on the old server anymore, you need to delete this server from the system and then delete all files from its folder manually, as KVS does not delete files automatically.

2.5. How do I add a second HDD for video storage?

The main difference about connecting a storage server on a second HDD of the same physical server is that this HDD will have a special server path when serving videos via all methods (e.g. /hdd2). Deal with this by adding a symlink on your primary HDD leading to your secondary HDD, for instance:

/usr/username/domains/mydomain.com/www/contents/videos2 -> /hdd2

After that, you can assign your new storage server to a folder on your primary HDD that is a symlink to your secondary HDD (/hdd2). This is a standard setting.

2.6. Can third party webmasters upload content and set custom ads for video pages?

You can organize webmaster uploads in the following way.

Webmasters are your registered users having Webmaster status. It is recommended to use this status to be able to show certain controls to such users in your site's templates.

Ads on video pages (and inside the player, when needed) are displayed using video content sources (Categorization -> Content Sources). You can use any fields for this, including custom fields. Enable those in Settings -> Customization. For each webmaster, you need to pre-setup a list of content sources with their referral links to ads. All content sources of a webmaster need to be added to the same group of content sources. It is obvious that if you want several webmasters to use the same ad, this ad needs to be added as several different content sources. These need to belong to different groups, and their referral URLs will be different.

You need to assign a group of content sources to each webmaster in their profile settings. This group needs to be created for this webmaster only and contains only content sources with ad settings specific to this webmaster. In this case, when this webmaster uploads a video, they will be able to choose from content sources added to their group. They will also be able to choose content sources that do not belong to any group.

Setting up a group of content sources for a webmaster-type user
Setting up a group of content sources for a webmaster-type user.

Uploading a video to site is handled by the video_edit block. If you want to allow video uploads to webmasters only, in most cases, it is sufficient to hide the upload link for non-webmaster users. It is a simple condition in the template that contains the video upload link:

{{if $smarty.session.status_id==6}} {{* this condition was added *}}
    {{* current user is a webmaster, display the link *}}
    <a href="...">Upload video</a>
{{/if}}

If you want to allow video uploads for all site users but let only webmasters choose a content source, you need to edit the video_edit block going to Website UI -> Pages -> [Memberzone] My Video Edit and find the code that displays the list of content sources. You will need to wrap this block of code into the same condition as in the example above:

{{if $smarty.session.status_id==6}} {{* this condition was added *}}
    {{* current user is a webmaster, show select with ability to choose content source *}}
    {{if count($list_content_sources)>0}}
        ...
        Sponsor:
        ...
        <select name="content_source_id">
            <option value="0">I do not want to use this field</option>
            {{foreach item=item from=$list_content_sources}}
                <option value="{{$item.content_source_id}}" {{if $item.content_source_id==$smarty.post.content_source_id}}selected="selected"{{/if}}>{{$item.title}}</option>
            {{/foreach}}
        </select>
    {{/if}}
{{/if}}

2.7. What is the right way to add a video format?

Depending on how you intend to use your new video format, the procedure of adding it may vary.

First, you need to choose the format postfix. A postfix contains the file extension (e.g. .mp4), and sometimes contains additional characters before the extension, if you plan to have multiple formats with the same extension (e.g. _lq.mp4 and _hq.mp4).

Second, you need to select whether this new video format will be used in standard or premium videos.

Third, you will need to determine several video-related details e.g. aspect ratio, duration limit, FFmpeg option string etc. See main documentation for general information on the FFmpeg option string.

Finally, you will need to select format status, required or optional. Files of required formats will be created for all videos, existing ones included. Files of optional formats will be created only if you upload them manually or launch their creation via bulk edit. If you already have videos in this format group, standard or premium, creating a required format will lead to automated creation of files of this format for all existing videos. If you specified incorrect format settings, you may end up wasting some time and having to re-create files of this format for all videos. In these situations, we always recommend creating an optional format first and then launch manual file creation for a few test videos via bulk editing. Check whether the files created from your test videos are valid by going to the video edit page in the admin panel. It shows files of all available formats that can be played back or downloaded. If there were no errors while creating files of a new format for your test videos and you are happy with the size, duration and quality of the videos, you can switch the format status from optional to required. Thus you will tell KVS to create files of this format for all remaining videos.

3. Player and Player-Related Issues

3.1. How do I send my own embed code to the player on the site? I want to use non-standard code.

In the template of the video view block (video_view) which you will find in Website UI -> Pages -> View Video, there is a JavaScript code:

function getEmbed() {
    var embedCode = '<iframe width="{{$player_size_embed[0]}}" height="{{$player_size_embed[1]}}" ...>';
    embedCode += '</iframe>';
    return embedCode;
}

You can customize your embed code in this fragment.

3.2. I do not want visitors to be able to copy the embed codes for my videos from the player.

In player and embed player settings, you will find an option that prevents your embed code from being copied:

Here, copying of a video's embed code is disabled
Here, copying of a video's embed code is disabled.

The option in player settings defines how the player behaves on your site. The option in embed player settings defines how your embed codes behave on third party sites.

3.3. How do I display embed codes via RSS?

By default, RSS video lists are generated by this page: Website UI -> Pages -> RSS Videos. You need to modify the list_videos block template on this page so that its output includes the embed code, for example:

<content><![CDATA[
    <iframe width="600" height="400" src="{{$config.project_url}}/embed/{{$item.video_id}}" frameborder="0" allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe>
]]></content>

Here, the size of each embed is fixed (600x400) and do not depend on the dimensions of the original video.

3.4. How do I switch to the new iframe embed code format having updated to 3.5.0?

Go to Settings -> Embed Player Settings and make sure the Embed code template field is not empty. Make sure the new embed code works properly using this link (in the end of the URL, you need to add the ID of any active video):

http://domain.com/player/iframe_embed.php?video_id=12345

If the player is displayed correctly, you need to make sure the new format works via standard links as well. To do that, modify the rule in the very bottom of your .htaccess file:

RewriteRule ^embed/(.+)$ /iframe_embed.php?video_id=$1 [L,QSA]

To this:

RewriteRule ^embed/(.+)$ /player/iframe_embed.php?video_id=$1 [L,QSA]

Now your iframe embed codes will work according to the new format on all third party sites. Check once again everything is working fine (add the ID of any active video in the end of the URL).

http://domain.com/embed/12345

3.5. How do I switch to the new related videos format having updated to 3.9.0?

Download the following ZIP and upload its contents via FTP on top of your project:

http://kernel-scripts.com/files/related_videos.zip

Add the following rule under SYSTEM / DO NOT CHANGE section of your main .htaccess file:

RewriteRule ^related_videos_html/([0-9]+)/?$ /related_videos_html.php?video_id=$1 [L,QSA]

It is also recommended to disallow SE robots indexing these new URLs. You can do that by adding the following line into your robots.txt file:

Disallow: /related_videos_html/*

Add the following styles into your actual CSS file:

/* related videos in player */
.player-related-videos {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
padding: 5px 10px 30px 10px;
background: #000000;
overflow: hidden;
}
.player-related-videos .player-related-videos-container {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
text-align: center;
}
.player-related-videos .player-related-videos-item {
position: relative;
display: inline-block;
vertical-align: middle;
margin-top: 5px;
}
.player-related-videos .player-related-videos-item .title {
display: none;
position: absolute;
left: 0;
top: 0;
right: 0;
height: 52px;
overflow: hidden;
text-align: left;
padding: 5px;
color: #ffffff;
background: -moz-linear-gradient(top, rgba(12, 12, 12, 0.8) 0px, transparent 50px);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0px, rgba(12, 12, 12, 0.8)), color-stop(50px, transparent));
background: -webkit-linear-gradient(top, rgba(12, 12, 12, 0.8) 0px, transparent 50px);
background: -o-linear-gradient(top, rgba(12, 12, 12, 0.8) 0px, transparent 50px);
background: -ms-linear-gradient(top, rgba(12, 12, 12, 0.8) 0px, transparent 50px);
background: linear-gradient(to bottom, rgba(12, 12, 12, 0.8) 0px, transparent 50px);
}
.player-related-videos .player-related-videos-item .duration {
display: none;
position: absolute;
bottom: 5px;
right: 5px;
color: #ffffff;
background: rgba(12, 12, 12, 0.8);
padding: 2px 5px;
}
.player-related-videos .player-related-videos-item:hover .title,
.player-related-videos .player-related-videos-item:hover .duration {
display: block;
}

Important! Player related videos will use 180x135 screenshot format by default. If you don't have it, you should modify template under Website UI -> Pages -> [System] Player Related Videos -> Player Related Videos block. In this block's settings you can also change related videos calculation mode in mode_related parameter.

4. Managing Your Site, Templates, and Data Output

4.1. How do I change the way links to video or photo album pages look in the lists?

Go to Settings -> Website Settings to configure your video and album view link patterns.

Configuring link patterns for video and album pages
Configuring link patterns for video and album pages.

When you modify these patterns, you also need to modify the rules for these pages in the .htaccess file in the root of your site so that the pages stay functional:

# for videos
RewriteRule ^videos/([0-9]+)/([^/]+)/([0-9]+)/$ /view_video.php?id=$1&dir=$2&from=$3 [L,QSA]
RewriteRule ^videos/([0-9]+)/([^/]+)/$ /view_video.php?id=$1&dir=$2 [L,QSA]

# for albums
RewriteRule ^albums/([0-9]+)/([^/]+)/([0-9]+)/$ /view_album.php?id=$1&dir=$2&from=$3 [L,QSA]
RewriteRule ^albums/([0-9]+)/([^/]+)/$ /view_album.php?id=$1&dir=$2 [L,QSA]
RewriteRule ^albums/([0-9]+)/([^/]+)/image([0-9]+)/([0-9]+)/$ /view_album.php?id=$1&dir=$2&image_id=$3&from=$4 [L,QSA]
RewriteRule ^albums/([0-9]+)/([^/]+)/image([0-9]+)/$ /view_album.php?id=$1&dir=$2&image_id=$3 [L,QSA]

4.2. I want to customize values in page header, e.g. title, description, and/or keywords.

The page component that dispays the header (Website UI -> Page Components -> header_general.tpl) supports several variables that let you make these customizations:

  • page_title
  • page_description
  • page_keywords

Usually the values of these variables are set before the header is included into page template, for example:

{{assign var=page_title value="Demo Tube Website"}}
{{assign var=page_description value="..."}}
{{assign var=page_keywords value="..."}}
{{include file="header_general.tpl"}}

The value can be not just static text, but also storage variables of any blocks defined earler in the template of this page, for example:

{{insert name="getBlock" block_id="video_view" block_name="Video View" assign="video_view_result"}}

{{assign var=page_title value="This is a video named `$storage.video_view_video_view.title`"}}
{{assign var=page_description value=$storage.video_view_video_view.description}}
{{assign var=page_keywords value=$storage.video_view_video_view.tags_as_string}}
{{include file="header_general.tpl"}}

Let us make several comments on the code above:

  • When inserting the block, you need the assign="video_view_result" attritube so that the block sends its output to the $video_view_result instead of displaying it on the page. Later, you can display this data where you need in the template.
  • Remember to use quotation marks (``) with smarty variables. They escape smarty variables when they are used within a string wrapped in double quotation marks.
  • If you want to find out what variables from the block's storage environment you can use, open page debugger (add ?debug=true to the page URL), and you will see all variables listed for each block on the page. For example: {{insert name="getBlock" block_id="video_view" block_name="Video View" assign="video_view_result"}}

    {{assign var=page_title value="This is a video named `$storage.video_view_video_view.title` uploaded by `$storage.video_view_video_view.username`"}}
    Pay attention that you can only use storage variables of a block only after the place in the template where this block is inserted. For instance, this will NOT work: {{* You are trying to use storage of video_view_video_view block before this block is inserted *}}
    {{* It will display empty values: This is a video named   uploaded by   *}}
    {{assign var=page_title value="This is a video named `$storage.video_view_video_view.title` uploaded by `$storage.video_view_video_view.username`"}}

    {{insert name="getBlock" block_id="video_view" block_name="Video View"}}
    {{* Now you can use video_view_video_view block storage variables *}}

4.3. How do I display ads from custom fields of content sources on video pages?

Content sources can have many custom fields. These can contain text data as well as files. Go to Settings -> Customization to enable these custom fields:

Enabling custom fields for content sources
Enabling custom fields for content sources.

You can use any custom fields to display their contents on the video view page (text blocks, links, banners). To display the contents of a custom field with text in the video view block (Website UI -> Pages -> View Video -> video_view block), you can use this code in its template:

{{if $data.content_source.content_source_id>0}} {{* Does video have a content source? *}}
    Custom 1 field contains: {{$data.content_source.custom1}}

    {{if $data.content_source.custom2<>''}} {{* Does content source have a value in custom2 field? *}}
        Custom 2 can be blank for some content sources: {{$data.content_source.custom2}}
    {{/if}}
    ...
{{/if}}

Use this code for custom fields with files:

{{if $data.content_source.content_source_id>0}} {{* Does video have a content source? *}}
    Custom file 1 links to:
    {{$data.content_source.base_files_url}}/{{$data.content_source.custom_file1}}

    {{if $data.content_source.custom_file2<>''}} {{* Does content source have a file uploaded into custom_file2 field? *}}
        Custom file 2 can be blank for some content sources:
        {{$data.content_source.base_files_url}}/{{$data.content_source.custom_file2}}
    {{/if}}
    ...
{{/if}}

4.4. How do I display ads after 12th and 24th thumbnails nn video list pages?

To make this work, you need to modify the video list template. Go to Website UI -> Page Components -> list_videos_block_common.tpl. The template contains the list display cycle:

{{foreach name=data item=item from=$data}}
    ...display video item
{{/foreach}}

We need to modify the way displaying works here:

{{assign var=pos value=1}}
{{foreach name=data item=item from=$data}}
    ...display video item
    {{if $pos==12}}
        display ad #1
    {{elseif $pos==24}}
        display ad #2
    {{/if}}
    {{assign var=pos value=$pos+1}}
{{/foreach}}

4.5. I want to build a tree of categories. How do I use categories with same names in different groups?

Let us address a basic example. Your site has groups of categories, e.g. TV Shows and Movies. Both these categories can have a Comedy subcategory. However, KVS cannot create categories with the same name as category names are used for item identification in certain situations, e.g. during content import.

To make categorization work the way you want, we need to create 2 categories for comedies, e.g. Comedy [TV Shows] and Comedy [Movies]. Then, we need to assign different groups of categories to these. If you want these subcategories to have the same name on your site, you can use a custom field. Enable it by going to Settings -> Customization. For instance, you can enable custom field #4 for categories, and enter Comedy for both your categories in this field:

Enabling custom field #4 for a category
Enabling custom field #4 for a category.
Setting same value to display in custom field #4 for both categories
Setting same value to display in custom field #4 for both categories.

Then, to display this subcategory name on your site, you need to use the value of custom4, not the the value of title.

If you want to display several groups of categories with a list of subcategories under each, you can use several list_categories blocks in a row, configuring each block to display only categories from a certain group, for example:

<h2>Movies</h2>
{{insert name="getBlock" block_id="list_categories" block_name="Movies Categories"}}
<h2>TV Shows</h2>
{{insert name="getBlock" block_id="list_categories" block_name="TV Shows Categories"}}
...

In the settings of each list_categories block from the code above, you need to enable the category_group_ids parameter, setting its value to the numeric ID of the category group you want this block to display subcategories from.

4.6. In a template, I want to display HTML code from an custom field of a category so that it becomes part of the page. When I try doing so, it is displayed as HTML code only.

Usually data in page or block template are displayed in this way (example for custom field #4 of a category in the list_categories block):

{{$item.custom4}}

With this standard output, all special HTML characters are automatically screened to prevent hackers from injecting malicious code into your site's templates. If you want to disable screening for some situations, use the |smarty:nodefaults modifier. This is how it would look for the example above:

{{$item.custom4|smarty:nodefaults}}

We strongly recommend always keeping the screening enabled for user content (comments, videos, albums, profiles). Otherwise you may be under the risk of having malicious HTML injected into your site's pages.

4.7. In video lists, how do I change the number of thumbnails in a row?

All elements of a video list go in one row. CSS styles define the sizes of each element, so container width and the width of each element determine how many of them are in one row. It means you need to adjust the width of the DIV container in your CSS styles. In default templates, this is how it goes:

.list_videos .item {
    float: left;
    width: 242px;
    padding: 2px;
    font-size: 11px;
}

4.8. In video lists, how do I modify thumbnail size??

First you need to create a screenshot format that would have the sizes you need (e.g. 300x200). The actual sizes used to display these images on the site are set directly in site templates. Use the search function (Website UI -> Template Search) to find all instances in your templates where sizes are set. In default templates, the sizes used are 240x180 and 180x135.

Searching for screenshot sizes in site templates
Searching for screenshot sizes in site templates.

A link to a video screenshot of a specific size will look like this:

{{$item.screen_url}}/240x180/{{$item.screen_main}}.jpg

You need to replace 240x180, the old size, with 300x200, your new size, in all the templates of your site. Please note that in some templates these sizes are included several times. For your site design to look properly, you will also need to adjust your CSS styles so that they match the new screenshot size.

4.9. How do I display the number of likes videos or albums have instead of ratings?

You can configure flags in such a way that they add certain values to the rating (or substract these values from it). You need to set the rating in flag settings in Categorization -> Flags. For the I like this flag, the rating needs to be 5, for the I dislike this, the rating needs to be 0:

I like this and I dislike this flag ratings
I like this and I dislike this flag ratings.

Thus, when choosing the I like this flag, the user will give the video a +5 rating. When the user chooses I dislike this, 0 will be added to the rating, but the video will have +1 vote. If you want to calculate the %, divide the value by 5, as 5 is a 100% rating.

In Settings -> Content Settings, you can set any value as a starting rating for your videos and photo albums, depending on what starting % you want to assign (4 will mean a rating of 80%).

Starting video rating is set to 0
Starting video rating is set to 0.

In the list_videos block template (Website UI -> Page Components -> list_videos_block_common.tpl and list_videos_block_internal.tpl) you can display the % of I like this votes for each video in the list in the following way:

{{assign var="flags" value="`$item.rating/5*100`"}}
{{if $flags>100}}
    {{assign var="flags" value="100"}}
{{/if}}
{{$flags|string_format:"%d"}}%

In the video_view block template (Website UI -> Pages -> View Video -> video_view block) you can display the % of I like this votes in this way:

{{assign var="flags" value="`$data.rating/5*100`"}}
{{if $flags>100}}
    {{assign var="flags" value="100"}}
{{/if}}
{{$flags|string_format:"%d"}}%

For photo albums, the procedure is identical.

4.10. How do I show video download links in video lists?

This is a complex issue. Video downloads may be available or not available to different user types, so we need to take a look at all possible combinations. Moreover, the way caching of list_videos block works, different variations of a template cannot be shown to different user types. So, in order to implement the separate permissions logic, we need some JavaScript.

Let us have a look at the most typical situation. The Download link behaves differently:

  • Premium users download a WMV file
  • Unregistered users are taken to the registration page

For each video in the list, you can build the link to the WMV file in the list_videos block in the following way (slash in the end is required):

{{if $item.server_group_id>0}}
    {{* ".wmv" - is the WMV format postfix, modify it if differs in your project *}}
    {{assign var="postfix" value=".wmv"}}
    Download url: {{$config.project_url}}/get_file/{{$item.server_group_id}}/{{$item.formats[$postfix].file_path}}/
{{/if}}

For this link to work, you need to enable downloads for the WMV format in format settings (Settings -> Video Formats -> Edit Format).

Enabling downloads for the WMV format
Enabling downloads for the WMV format.

Now, we can add WMV download links to the list_videos block template. These links will work for premium users only. For the site to take unregistered users to the registration page, we need to add this user status condition in the video list template:

{{if $item.server_group_id>0}}
    {{* ".wmv" - is the WMV format postfix, modify it if differs in your project *}}
    {{assign var="postfix" value=".wmv"}}
    {{if $smarty.session.status_id==3}}
        {{* current user is a premium one, downloading is possible *}}
        Download url: {{$config.project_url}}/get_file/{{$item.server_group_id}}/{{$item.formats[$postfix].file_path}}/
    {{else}}
        {{* current user is not a premium, redirect to signup *}}
        Download url: {{$config.project_url}}/signup.php
    {{/if}}
{{/if}}

However, when you save this code, KVS will return a caching error. Thing is, the video list block shows the same cache to all site users. This is why this condition will not function correctly during caching. Sometimes premium users will see the registration link and vice versa, unregistered users will see the video download link. To avoid this, you need to switch the engine to the mode when users with different status see different cache. Add this option to /admin/include/setup.php:

$config['cache_control_user_status_in_cache']="true";

4.11. How do I change date format?

Date format is set in the PHP locale settings. To change the locale of your site to other language, add this PHP code to /admin/include/pre_process_page_code.php:

setlocale(LC_ALL,'nl_NL.UTF-8'); // Dutch locale

The file /admin/include/pre_process_page_code.php is requested by the engine before each page is processed. Thus, this command will be executed only for the pages of your KVS site, not affecting any other sites on the same server.

4.12. How do I use category name in video page titles?

This is how video page title is built in the template in Website UI -> Pages -> View Video:

{{assign var=page_title value=$storage.video_view_video_view.title}}

The $storage.video_view_video_view.title variable contains the video title. In addition to this variable, you can also use the $storage.video_view_video_view.categories_as_string that contains the list of all the categories of this video separated by commas:

{{assign var=page_title value="Video `$storage.video_view_video_view.title` from `$storage.video_view_video_view.categories_as_string` categories"}}

4.13. On my index page, I want to show screenshots of a different size compared to my other pages. Is it possible?

Screenshot size is defined in the templates (see question 4.8). Most video lists on your site are displayed by 2 page components: Website UI -> Page Components -> list_videos_block_common.tpl and list_videos_block_internal.tpl. The second component is used to display favourites or uploaded videos of a user who is logged in. When you change sizes in the templates of these components, these changes will be applied site-wide. This is why you need to create a new component that will be used only on the video lists on your index page.

To create a new component, you can use component cloning:

Cloning list_videos_block_common.tpl
Cloning list_videos_block_common.tpl.

In the dialog, you can set the ID of your new component to list_videos_block_index:

New component name
New component name.

After you have cloned the component, its template will look the same as the original. You can modify the new template changing the standard screenshot size to your custom size you want to be used on your index page. After that, you need to switch all video lists on the index page to the new component instead of list_videos_block_common.tpl. To do so, edit each list_videos block in Website UI -> Pages -> Index, and replace the directive:

{{include file="list_videos_block_common.tpl"}}

with a similar directive:

{{include file="list_videos_block_index.tpl"}}

Switching your index page to the new component
Switching your index page to the new component.

4.14. How do I add next / previous links for related videos so that they scroll without the page reloading?

KVS lets you use AJAX requests to query any block on the page. For instance, if you are using the list_videos: Related Videos block on the video view page, you can extract its HTML code from the page in this way:

?mode=async&action=get_block&block_id=list_videos_related_videos

The value of list_videos_related_videos is a unique block ID on the page that may differ depending on block type and name. Using these queries, you can extract HTML code of any block on any page. Find out which block ID you need to use by opening the editing page for that block and finding its ID:

Unique block ID on the page
Unique block ID on the page.

If you want to get different pages of the related video list, you need to enable the var_from parameter in the block, leaving the from value in it. After you enable it, you can request pages of this block using links like this:

?mode=async&action=get_block&block_id=list_videos_related_videos&from=1
?mode=async&action=get_block&block_id=list_videos_related_videos&from=2
...
?mode=async&action=get_block&block_id=list_videos_related_videos&from=1234

After that, all you need to do is use a JavaScript code that will use these links to go left / right within the related videos list.

4.15. On video / photo album pages, how do I display % of visitors who voted for the 'I like it' flag without using ratings?

We addressed using rating to calculate the % of votes for the 'I like it' flag in question 4.9. If you do not want to use rating for this, you can display the % of votes for the 'I like it' flag only in the video / album view block. You can display the % by doing this:

{{if $data.flags.flag_like_this_video>0 || $data.flags.flag_dislike_this_video>0}}
    {{math equation="100*(x / (x + y))" format="%d" x=$data.flags.flag_like_this_video y=$data.flags.flag_dislike_this_video}}% likes
{{else}}
    50% likes
{{/if}}

4.16. What are the pagination options for my site?

Pagination can work differently depending on what links you use to access the list page. If your link is a folder link, then SE-friendly pagination will work like this:

http://domain.com/page-url/
http://domain.com/page-url/2/
http://domain.com/page-url/3/
...
http://domain.com/page-url/N/

In the default template set, the .htaccess file is written to support this kind of pagination. If your link to the list page is a file link, this is how SE-friendly pagination would work:

http://domain.com/page-url.html
http://domain.com/page-url-2.html
http://domain.com/page-url-3.html
...
http://domain.com/page-url-N.html

For these links to function, you need to add a corresponding rule to your .htaccess file (example for latest-updates.html):

RewriteRule ^latest-updates.html$ /videos_list.php [L,QSA]
RewriteRule ^latest-updates-([0-9]+).html$ /videos_list.php?from=$1 [L,QSA]

Both pagination kinds described above will work if you use pagination within list blocks (any block list_xxx with the var_from parameter enabled). You can also use a separate pagination block (pagination). It works just like pagination within a list block, but additionally it lets you use a URL prefix. You may need this in 2 cases: a) display links to another page in your pagination, and b) create all pagination links with a prefix.

The a) option makes sense if you want to use pagination leading to the new videos page on your index page. This is how it works in default templates:

http://domain.com/
http://domain.com/latest-updates/2/
http://domain.com/latest-updates/3/
...
http://domain.com/latest-updates/N/

To make this happen, insert the pagination block into the index page and configure its parameters in this way:

Pagination block configuration parameters on the index page
Pagination block configuration parameters on the index page.

Choose the list block for which you display pagination on this page as the value for related_block_ext_id (Block). The url_prefix (String) sets the prefix used to generate links to pages. When users click on this link, they will be taken to the /latest-updates/N/ page with its own pagination.

The b) option lets you add the same prefix to all pagination across your site. This is how your pagination would look when you use pages as the prefix:

http://domain.com/some_page/
http://domain.com/some_page/pages/2/
http://domain.com/some_page/pages/3/
...
http://domain.com/some_page/pages/N/

This comes handy when you want to prevent search engine bots from indexing your pagination (via robots.txt). To do this, you can switch all your pagination to a unified prefix, e.g. pages, and disallow indexing for all pages with the pages prefix. Here, you will need to insert a separate pagination block on all required pages. The block needs to be configured in this way:

Pagination block configuration parameters on video list page
Pagination block configuration parameters on video list page.

Most important things to pay attention to here:

  • A prefix cannot start with a slash.
  • You need to get rid of old pagination that may be displayed inside a list block (in this case, in the template of the Common Videos List block).
  • Pagination caching time needs to correspond to the caching time of the list block this particular pagination is assigned to.
  • For every link where you want this pagination to work, you need to create an .htaccess rule, otherwise you will get the 404 error trying to access this page. Here is example for /latest-updates/: RewriteRule ^latest-updates/pages/([0-9]+)/$ /videos_list.php?from=$1 [L,QSA]

4.17. How do I display video screenshots on the video page and on the video list page?

If you want to display preview screenshots in the video_view block, on the Website UI -> Pages -> View Video, you can use this code (240x180 is the existing overview screenshot format, you can replace it with your custom format):

{{section name="screenshots" start="1" loop=$data.screen_amount+1}}
    <img src="{{$data.screen_url}}/240x180/{{$smarty.section.screenshots.index}}.jpg" alt="Screenshot #{{$smarty.section.screenshots.index}}"/>
{{/section}}

If you also want to use links to source files of the screenshots that have original size, use this:

{{section name="screenshots" start="1" loop=$data.screen_amount+1}}
    <a href="{{$data.screenshot_sources[$smarty.section.data.index]}}"">
        <img src="{{$data.screen_url}}/240x180/{{$smarty.section.screenshots.index}}.jpg" alt="Screenshot #{{$smarty.section.screenshots.index}}"/>
    </a>
{{/section}}

Displaying timeline screenshots is a little bit tricker. Timeline screenshots are assigned to a specific video format. Also, they may not exist for some videos. You can use this code:

{{assign var="format_postfix" value=".mp4"}} {{* ".mp4" is a video format postfix, which has timelines screenshots enabled, change it according to your configuration *}}
{{if $data.formats[$format_postfix]<>'' && $data.formats[$format_postfix].timeline_screen_amount>0}}
    {{section name="screenshots" start="1" loop=$data.formats[$format_postfix].timeline_screen_amount+1}}
        <img src="{{$data.screen_url}}/timelines/{{$data.formats[$format_postfix].timeline_directory}}/240x180/{{$smarty.section.screenshots.index}}.jpg"/>
    {{/section}}
{{/if}}

If you want to display preview screenshots in the list_videos block (in a list), you can use this code:

{{section name="screenshots" start="1" loop=$item.screen_amount+1}}
    <img src="{{$item.screen_url}}/240x180/{{$smarty.section.screenshots.index}}.jpg" alt="Screenshot #{{$smarty.section.screenshots.index}}"/>
{{/section}}

4.18. In video lists by category, how do I display category-specific ads?

If you want to display ads assigned to specific categories, you need to use custom fields of that category. Go to Settings -> Customization to enable one of the custom text fields, e.g. Custom field 5, and give it a name that is easy to understand. Now, for each category, you can use this custom field to store the HTML code of the ad you want to assign to this category.

Enabling a custom field for a category
Enabling a custom field for a category.

Then, you need to modify your site's templates so that they display ads. By default, video lists by category are displayed by Website UI -> Page Components -> list_videos_block_common.tpl used from the list_videos block here: Website UI -> Pages -> Common Videos List. In its template, insert this code where your ad is supposed to be:

{{if $list_type=='categories' && $category_info.custom5<>''}}
    {{* this list displays videos by category and category's custom field #5 is not empty -> display it *}}
    {{$category_info.custom5|smarty:nodefaults}}
{{else}}
    {{* this is not videos by category, or category's custom field #5 is empty -> show some default ad *}}
    ...
{{/if}}

This code will work only inside the list_videos block (the list_videos_block_common.tpl component is used within the list_videos block). If you need to display your ads outside of this block, e.g. in your site header (Website UI -> Page Components -> header_general.tpl), you can use a different code, provided that in this page's template, the list_videos block is inserted before the header. This condition is met in the case with the Common Videos List page:

{{if $storage.list_videos_common_videos_list.list_type=='categories' && $storage.list_videos_common_videos_list.category_info.custom5<>''}}
    {{* this list displays videos by category and category's custom field #5 is not empty -> display it *}}
    {{$storage.list_videos_common_videos_list.category_info.custom5|smarty:nodefaults}}
{{else}}
    {{* this is not videos by category, or category's custom field #5 is empty -> show some default ad *}}
    ...
{{/if}}

To display ads in this manner on the video view page, you need to use the same approach, but with a slight difference. As a video can have multiple categories, you need to take the ad from the first category available. This is the code you need to use in the template of the video_view block on Website UI -> Pages -> View Video:

{{if @count($data.categories)>0 && $data.categories.0.custom5<>''}}
    {{* video has at least 1 category and its custom field #5 is not empty -> display it *}}
    {{$data.categories.0.custom5|smarty:nodefaults}}
{{else}}
    {{* video doesn't have categories, or the first category's custom field #5 is empty -> show some default ad *}}
    ...
{{/if}}

To display ads outside of the video_view block, e.g. in site header, you need to use the code given below. As with video lists, in this case the video_view block on this page needs to be inserted before this code is used:

{{if @count($storage.video_view_video_view.categories)>0 && $storage.video_view_video_view.categories.0.custom5<>''}}
    {{* video has at least 1 category and its custom field #5 is not empty -> display it *}}
    {{$storage.video_view_video_view.categories.0.custom5|smarty:nodefaults}}
{{else}}
    {{* video doesn't have categories, or the first category's custom field #5 is empty -> show some default ad *}}
    ...
{{/if}}

4.19. How do I use different code in headers of different pages?

All pages of your site correspond to a PHP script in the root folder of your site. You can find out which page corresponds to which script using page debugging. Just add debug=true to page URL.

In any page component, e.g. in the site header component, you can link to this script in this way:

{{if $smarty.server.SCRIPT_NAME=='/index.php'}}
    display code specific to index.php
{{/if}}

4.20. How do I make lists of videos by tags look different than other lists on the site?

In the default templates, most video lists (new videos, popular videos, videos by category, tags etc.) are processed by one page called Common Videos List. This page contains the list_videos block that is configured in such a way so that it displays a list of videos using certain filters and types of sorting sent to it via HTTP request parameters.

Showing a list of videos by tag is one of the features of this page. To customize a list of videos by tag, the best way to go is create a duplicate of Common Videos List page and use it. Thus you can be sure that if there are any errors or issues, other lists will still be working. You can create a duplicate of this page in just two clicks by going to Website UI -> Pages:

Duplicating a page
Duplicating a page.

In the popup window, you need to enter the ID of your new page. You can base this ID on the ID of the existing page. It is important that sometimes KVS may not have enough permissions to create a new PHP file in the root folder of your site. Before you can be done duplicating, you need to copy /admin/tools/page_template.php to your root folder manually, renaming the resulting file according to the ID of your new page. In our example, it's videos_list_tags.php:

Setting the ID of a new page
Setting the ID of a new page.

In case a file named videos_list_tags.php already exists, KVS will create a full clone of the Common Videos List page with a different URL. Now, you can modify your new page to display videos by tag in a customized way. Finally, you just need to switch the rules in your .htaccess file for tags to the new page. Find all the rules you need and switch them to your new page called videos_list_tags.php instead of the old videos_list.php:

RewriteRule ^tags/(.*)/latest/([0-9]+)/$ /videos_list_tags.php?tag=$1&from=$2 [L,QSA]
RewriteRule ^tags/(.*)/latest/$ /videos_list_tags.php?tag=$1 [L,QSA]
...etc.

Now all lists of videos by tags should be processed by the new page. It means they will look differently compared to other lists of videos. When needed, you can apply this to other video lists displayed by the Common Videos List page.

4.21. Can my visitors add model data to my content?

For this, you need to use flags. In KVS, not only voting for flags is possible, but text messages can also be added. Such messages added to flags will show in admin panel in Videos -> User Feedback and Albums -> User Feedback.

By default, templates do not support this feature. You can easily change it, though. First, you need to create a new flag, e.g. like this:

Creating a flag so that users can specify models on your site
Creating a flag so that users can specify models on your site.

Then, go to Website UI -> Pages -> Video View to add the HTML code for the new flag to the template of the video_view block. This code includes a container with a text field, the Send button, hidden containers with successful / error notifications:

<div id="flag_video_model_container">
    <label for="flag_video_model_textfield">Specify models:</label>
    <input type="text" id="flag_video_model_textfield"/>
    <input type="button" id="flag_video_model_btn" value="Send"/>
</div>
<div id="flag_video_model_hint">please list video models</div>
<div id="flag_video_model_success" class="g_hidden">Thank you! We will consider your suggestion.</div>
<div id="flag_video_model_failure" class="g_hidden">Sorry, you have already specified models for this video.</div>

Also, you will need a JavaScript code that initializes this logic:

<script>
    params = {};
    params['flag_external_id'] = 'flag_video_model'; // flag external ID
    params['container_id'] = 'flag_video_model_container'; // ID of HTML container, which should become hidden after voting for the flag
    params['button_id'] = 'flag_video_model_btn'; // ID of HTML element, which should listen for click
    params['text_id'] = 'flag_video_model_textfield'; // ID of HTML text field, where flag message is entered
    params['hint_message_id'] = 'flag_video_model_hint'; // ID of HTML container with hint, which should become hidden after voting for the flag
    params['success_message_id'] = 'flag_video_model_success'; // ID of HTML container with success message, which should become visible after voting for the flag
    params['failure_message_id'] = 'flag_video_model_failure'; // ID of HTML container with error message, which should become visible after voting for the flag
    params['video_id'] = {{$data.video_id}}; // video ID
    videoViewEnableFlagging(params);
</script>

If you want to handle the response in a custom way, you do not need to specify various containers. Instead, you can use a callback function to be called instead of the default logic:

<script>
    params = {};
    params['flag_external_id'] = 'flag_video_model'; // flag external ID
    params['button_id'] = 'flag_video_model_btn'; // ID of HTML element, which should listen for click
    params['text_id'] = 'flag_video_model_textfield'; // ID of HTML text field, where flag message is entered
    params['video_id'] = {{$data.video_id}}; // video ID
    params['callback'] = function(errors) { // callback function
        if (errors) {
            alert('Sorry, you have already specified models for this video.');
        } else {
            alert('Thank you! We will consider your suggestion.');
        }
    };
    videoViewEnableFlagging(params);
</script>

For photo albums, everything is identical, with 2 exceptions:

  • Use params['album_id'] = {{$data.album_id}} instead of params['video_id'] = {{$data.video_id}}.
  • Use albumViewEnableFlagging() instead of videoViewEnableFlagging().

4.22. Can content be added to playlists? Can system favourites be expanded?

By default, templates let users add content only to standard favourites. However, KVS supports up to 10 additional favourite lists as well unlimited user-created playlists. Playlists are handled by these blocks: playlist_edit (creating and editing), and list_playlist (displaying a list of playlists).

On the video / photo album pages, content items are added to favourites when users press a special button. This action is processed with this JavaScript code:

var params = {};
params['link_id'] = 'fav_link'; // ID of HTML element, which should listen for click
params['success_message_id'] = 'fav_block_success'; // ID of HTML container with success message, which should become visible after video is added to favourites
params['video_id'] = {{$data.video_id}}; // video ID
videoViewEnableAddToFavourites(params);

Let's imagine we want to let our users add videos to an additional favourites list 'Watch Later', as well as to any custom playlist. To do this, we need to implement a drop down list of buttons represented by the ul element, containing 2 fixed buttons and buttons for all user playlists:

<ul>
    <li><a id="fav_link">Bookmaks</a></li>
    <li><a id="future_link">Watch Later</a></li>
    {{if count($smarty.session.playlists)>0}}
        {{foreach name=data item=item from=$smarty.session.playlists}}
            <li><a id="playlist_{{$item.playlist_id}}">'{{$item.title}}' playlist</a></li>
        {{/foreach}}
    {{/if}}
<ul>

<div id="fav_block_success" class="g_hidden">The video has been added to your member zone favourites.</div>

<script type="text/javascript">
    var params;

    // standard favourites
    params = {};
    params['link_id'] = 'fav_link'; // ID of HTML element, which should listen for click
    params['success_message_id'] = 'fav_block_success'; // ID of HTML container with success message, which should become visible after video is added to favourites
    params['video_id'] = {{$data.video_id}}; // video ID
    videoViewEnableAddToFavourites(params);

    // watch later favourites
    params = {};
    params['link_id'] = 'future_link'; // ID of HTML element, which should listen for click
    params['success_message_id'] = 'fav_block_success'; // ID of HTML container with success message, which should become visible after video is added to favourites
    params['video_id'] = {{$data.video_id}}; // video ID
    params['fav_type'] = 1; // favourites list ID > 0 (any number from 1 to 9)
    videoViewEnableAddToFavourites(params);

    {{if count($smarty.session.playlists)>0}}
        {{foreach name=data item=item from=$smarty.session.playlists}}
            // for every playlist
            params = {};
            params['link_id'] = 'playlist_{{$item.playlist_id}}'; // ID of HTML element, which should listen for click
            params['success_message_id'] = 'fav_block_success'; // ID of HTML container with success message, which should become visible after video is added to favourites
            params['video_id'] = {{$data.video_id}}; // video ID
            params['playlist_id'] = {{$item.playlist_id}}; // playlist ID
            videoViewEnableAddToFavourites(params);
        {{/foreach}}
    {{/if}}
</script>

For albums, playlists are not supported; however, built-in favourites lists are. You can use the same code, removing all playlist-related logic from it and making these changes:

  • Use params['album_id'] = {{$data.album_id}} instead of params['video_id'] = {{$data.video_id}}.
  • Use albumViewEnableAddToFavourites() instead of videoViewEnableAddToFavourites().

4.23. On video / photo album pages, how do I enable token-based access purchases?

To implement token-based video purchases, use these primary variables in the video_view block template:

{{$data.tokens_required}} - price in tokens, if 0, the video cannot be purchased
{{$data.is_purchased_video}} - flag 0/1 indicating whether current video was purchased by the user or not
{{$smarty.session.user_id}} - current user ID, needs to be >0 for the purchase to happen, i.e. the user needs to be logged in
{{$smarty.session.status_id}} - current user status, needs to be == 2 for the purchase to happen (standard user)
{{$smarty.session.tokens_available}} - total tokens available to user

So, to facilitate video purchases with tokens, you can use this code in your video_view block template:

{{if $data.tokens_required>0 && $data.is_purchased_video==0 && $smarty.session.user_id>0 && $smarty.session.status_id==2}}
    <div id="purchase_info_message" class="message_info">
        You can buy full access to this video for {{$data.tokens_required}} tokens. You have {{$smarty.session.tokens_available}} tokens available.<br/>
        <input type="checkbox" id="cb_confirm"/> please confirm spending tokens<br/>
        <input type="button" id="btn_purchase" value="Get full access"/>
        <script>
            var params = {};
            params['link_id'] = 'btn_purchase';
            params['checkbox_id'] = 'cb_confirm';
            params['info_message_id'] = 'purchase_info_message';
            params['success_message_id'] = 'purchase_success_message';
            params['error_message_id'] = 'purchase_error_message';
            params['video_id'] = {{$data.video_id}};
            videoViewEnablePurchaseVideo(params);
        </script>
    </div>
    <div id="purchase_error_message" class="g_hint g_hidden">You don't have enough tokens for this video.</div>
    <div id="purchase_success_message" class="g_hint g_hidden">Thank you! Now you have full access to this video. Please refresh the page.</div>
{{/if}}

You can use similar code in album_view (photo album view block):

{{if $data.tokens_required>0 && $data.is_purchased_album==0 && $smarty.session.user_id>0 && $smarty.session.status_id==2}}
    <div id="purchase_info_message" class="message_info">
        You can buy full access to this album for {{$data.tokens_required}} tokens. You have {{$smarty.session.tokens_available}} tokens available.<br/>
        <input type="checkbox" id="cb_confirm"/> please confirm spending tokens<br/>
        <input type="button" id="btn_purchase" value="Get full access"/>
        <script>
            var params = {};
            params['link_id'] = 'btn_purchase';
            params['checkbox_id'] = 'cb_confirm';
            params['info_message_id'] = 'purchase_info_message';
            params['success_message_id'] = 'purchase_success_message';
            params['error_message_id'] = 'purchase_error_message';
            params['album_id'] = {{$data.album_id}};
            albumViewEnablePurchaseAlbum(params);
        </script>
    </div>
    <div id="purchase_error_message" class="g_hint g_hidden">You don't have enough tokens for this album.</div>
    <div id="purchase_success_message" class="g_hint g_hidden">Thank you! Now you have full access to this album. Please refresh the page.</div>
{{/if}}

4.24. How do I enable voting for user comments?

In KVS, comments can get two types of flags, 'for' and 'against', essentially, upvoting and downvoting. In video_comments, album_comments and other blocks with comments, you can display total votes for each comment doing this:

{{$item.likes}} upvotes, {{$item.dislikes}} downvotes

To enable upvoting and downvoting, you can do this:

<script type="text/javascript">
    function voteCallback(errors) {
        if (!errors) {
            alert('Thank you!');
        } else {
            alert('You have already voted.');
        }
    }
</script>
<a href="javascript:stub()" onclick="videoCommentsVote({comment_id: {{$item.comment_id}}, vote: 1, callback: voteCallback})">+1</a>
<a href="javascript:stub()" onclick="videoCommentsVote({comment_id: {{$item.comment_id}}, vote: -1, callback: voteCallback})">-1</a>

The videoCommentsVote receives an object with 3 parameters:

  • comment_id - comment ID.
  • vote - vote value, positive figure with upvoting, otherwise the vote is counted as downvoting.
  • callback - response processing function.

The videoCommentsVote JavaScript function is available in video_comments only. For other blocks, you need to use other functions:

  • In album_comments, use albumCommentsVote.
  • In model_comments, use modelCommentsVote.
  • In content_source_comments, use csCommentsVote.
  • In dvd_comments, use dvdCommentsVote.

4.26. How do I enable bb-codes and emoticons in comments?

Smileys and bb-codes are supported all across the site, not just in comments. However, by default they are not processed. To enable their processing to display a certain string, you need to use the bbcode modifier in your template:

{{* In comments block for each comment *}}
{{$item.comment|bbcode|replace:"\n":"<br/>"}}

{{* In video view block for video description *}}
{{$data.description|bbcode}}

By default, standard bb-codes are supported:

[b]Bold[/b]
[i]Italic[/i]
[u]Underscore[/u]
[s]Strikethrough[/s]
[quote]Quote[/quote]
[code]Fixed width font[/code]
[img]Image URL[/img]

Modify the configuration script /admin/include/bbcode.php to add more bb-codes to your site. There, you will also see the list of smileys with links to their image files.

If you want to display a text fragment without any smileys or bb-codes (i.e. cut them out), add the hide parameter to the bbcode modifier:

{{* In comments block for each comment *}}
{{$item.comment|bbcode:"hide"|replace:"\n":"<br/>"}}

{{* In video view block for video description *}}
{{$data.description|bbcode:"hide"}}

4.27. How do I migrate the design from one site to another?

Migrating your design is easy when you use the backup plugin. In the plugin, enable only the create site backup option. It will create an archive with a website folder in it. This folder will contain not just page and template settings, but also JS files, styles, as well as site and player settings.

Before you copy the data to your new site, as long as this site hasn't been launched yet, we recommend deleting all site pages in WebSite UI -> Pages. Then, go to Website UI -> Restore Pages and delete all pages there. If you encounter permission errors while doing so, temporarily change your site's root folder permissions to 777. When you are done deleting, restore them to 755. Then, in Website UI -> Page Components, delete all components.

After that, copy the contents of the website folder from the backup copy, overwriting the root folder of your new site. When you are done with that, your site should be fully functional, provided your screenshot, video, and album formats are the same for both sites.

After you copy site files and components, you may see permission warnings in Website UI telling you there are not enough permissions to edit. Use these console commands to fix that (your current folder needs to be the root folder of your site):

find template -type d | xargs chmod 777
find template -type f \( ! -iname ".htaccess" \) | xargs chmod 666
find admin/data/config -type d | xargs chmod 777
find admin/data/config -type f \( -iname "*.dat" \) | xargs chmod 666

5. Customization

5.1. How do I connect a script counting incoming hits for traffic trade?

Usually your trade script will have a PHP or CGI file that counts incoming hits. This file should be triggered every time a page of your site is requested. It processes the request and returns a small block of JavaScript code. To make sure such scripts work smoothly with KVS, you need to do the following:

  • In Settings -> Website Settings, in the Website caching field, you need to select Block caching only option. It means the site header will not be cached and will be queried with each request.
  • In site header template (Website UI -> Page Components -> header_general.tpl), you need to insert the code that connects the trade script into the right place (check your trade script manual for the code): {{php}}
        virtual('/path/to/your/site/index/directory/trade_script/in.php');
    {{/php}}

5.2. How do I make my trade links look nicer?

In most cases, trade links look like this:

http://domain.com/out.php?u=http://domain.com/videos/123/video-directory/

You can add a custom rule to your .htaccess file that will send the actual link to the video to the out.php script, e.g. like this:

RewriteRule ^goto/([0-9]+)/([^/]+)/$ /out.php?url=http://domain.com/videos/$1/$2/ [L,QSA]

After that, in your list_videos blocks, you can use links of this type. These will be processed by the out.php trade script, redirecting your visitors either to the video page, or sending them to trade. To do this, replace the {{$item.view_page_url}} variable in the component template located at Website UI -> Page Components -> list_videos_block_common.tpl with this code:

{{$config.project_url}}/goto/{{$item.video_id}}/{{$item.dir}}/

When necessary, trade script parameters can be directly added to links of this type:

{{$config.project_url}}/goto/{{$item.video_id}}/{{$item.dir}}/?p=50&trade_option=value

Important! Never set your video view patterns to /goto/ type links in Settings -> Website Settings. The pattern always needs to link to the actual video view page, while /goto/ links lead to an intermediary script.

5.3. How do I include my custom PHP script in templates?

In order to do that you should first realize the function your custom PHP code does. Based on that there can be different scenarios:

  • Your custom code does not output anything, simply processes requests (e.g. stats). In this case you can add it into /admin/include/pre_display_page_code.php file that is being called for each request on displaying pages (except XML pages).
  • Your custom code outputs some data, but it doesn't rely on each request processing and the data itself can be cached without issues. If this is the case, then you can add your code anywhere in templates in the following way: {{php}}
        your code here
    {{/php}}
  • Your custom code outputs some data and it also relies on each request, so that the displayed data may be different for different requests and thus it can't be cached. In this case the only possible way for you is to disable Memcache caching in Settings -> Website settings. Then you can insert your code into page templates and header / footer components only: {{php}}
        your code here
    {{/php}}
    Important! Such code can't be used inside block templates or components that are used inside blocks (for example inside video list, inside video view block). Blocks will still be cached and there is no guarantee that your code will be executed for every request.

If your need to display advertising separately from KVS existing functionality, look at the option to create a custom PHP script and insert it into your design using iframe. This will guarantee no caching issues.

6. KVS Infrastructure

6.1. How do I move my site to another server?

When you move KVS to another server, it is expected that the settings of that new server will correspond to the settings of the old server. It is also expected that the Nginx configuration will correspond to the configuration on the old server (with modified server paths, if necessary).

This is what you need to do to move your site to a new server:

  • Move the contents of your database.
  • Copy all files from the folder where KVS is installed to a similar folder on your new server. Remember to keep all file permissions for files and directories.
  • Modify MySQL connection settings in /admin/include/setup_db.php.
  • Switch old paths to new ones in /admin/include/setup.php. This file contains paths to various site directories. Make sure you modify all of these.
  • If needed, change paths to PHP libraries, FFmpeg, ImageMagick in the /admin/include/setup.php file.
  • If you use a local conversion server, change the paths to libraries in /admin/data/conversion/config.properties, if libraries have different paths on your new server. Then, in conversion server settings in your admin panel, change the path to its folder (/admin/data/conversion).
  • If you use local storage servers, change the path to them in storage servers settings in the admin panel.
  • Set up a cron job with the script /admin/include/cron.php once every minute like this: cd /PATH/admin/include/ && /usr/local/bin/php cron.php > /dev/null 2>&1 or cd /PATH/admin/include/ && /usr/bin/php cron.php > /dev/null 2>&1
  • Run the audit plugin and fix all the errors. After that, you can consider your site move successful.

6.2. How do I move a site from a subfolder to the root folder of a domain?

Moving a working site from a subfolder to the root folder of your domain may lead to your site being temporarily down. We recommend creating a page to show your users while your site is not available. You can use the /website_unavailable.html page for that. Before you start moving, disable your site in Settings -> Website Settings. In this case, only the administrator will see the site. Everybody else will see the /website_unavailable.html page.

When you move KVS to the root folder of your domain, it is expected that the Nginx configuration will be modified in such a way that the rules that were working for the folder with KVS in it will work for the root folder of your domain.

This is what you need to do to move your site to the root folder of a domain:

  • Check your site's templates for links that point to a specific folder (you can search templates for /folder). You need to fix all those links. By default, KVS templates do not have them, but you may have added them during customization.
  • In the pagination block settings on the Index page, change the value of the url_prefix parameter so that it points to the root folder, not to a /folder folder (if necessary).
  • In all .htaccess files inside the KVS folder, remove all mentions of the /folder in all the rules. Here is the list of .htaccess files: /.htaccess
    /js/.htaccess (may not exist)
    /player/.htaccess
    /admin/.htaccess
    /admin/feeds/.htaccess (may not exist)
  • On the file system level, you need to move all the files and folders (with the exception of the KVS folder) to a separate location in your file system. Do that only if you want to replace the contents of your domain's root folder with your KVS site. If you want your old content in the root folder to keep functioning after you move KVS there, you need to take into account any possible file and folder overlaps.
  • Move all KVS files and folders from /folder to the root folder. Make sure you do this as fast as possible.
  • Remove /folder mentions from all paths and URLs in /admin/include/setup.php. This file contains many paths and URLs to various site folders. You need to make sure all of them have been changed.
  • If you did everything above correctly, your KVS site and the KVS admin panel will work error-free in the root folder of your domain. If you have any problems with the way data is displayed, check whether the paths and URLs in /admin/include/setup.php are correct.
  • If you use a local conversion server, you need to change the path to it in conversion server settings in the admin panel.
  • If you use local storage servers, change the path to them in storage servers settings in the admin panel.
  • Save Settings -> Content Settings and fix the validation errors that may come up during saving, if any.
  • In Settings -> Player Settings and Settings -> Embed Player Settings, change all links that lead to files in the folder where KVS used to be installed, if necessary.
  • Modify the cron command so that it launches the /admin/include/cron.php script from the root folder of the domain.
  • Run the audit plugin and fix all the errors, if any. After that, you can consider your move successful. Remember to turn your site back on in Settings -> Website Settings if you turned it off before moving.

6.3. How do I build a mobile version of my site?

The concept is that KVS lets you create a set of mobile-friendly pages (mobile index page, mobile video page etc.) with mobile-friendly page code. These pages, just like any other pages, will be available by your primary domain name. Then, in your Apache configuration, you need to create a virtual host for your mobile subdomain m.domain.com. It is set up in exactly the same way as usual, with 2 exceptions:

  • The DocumentRoot setting needs to be assigned to the same folder where KVS is installed for your primary domain.
  • The AccessFileName setting needs to contain a filename different from your standard .htaccess, e.g. .htaccess_mobile.

An example of how a mobile subdomain can be set up in Apache:

DocumentRoot /var/www/domain.com/public_html
ServerName m.domain.com
ServerAlias m.domain.com
AccessFileName .htaccess_mobile

Now, when your mobile subdomain is opened, the .htaccess_mobile file will be used. Use this file to define rewrite rules for your mobile pages. Also, you need to include several system rules, as they will be identical. Here is a small example of how rewrite rules for mobile index and mobile video / album pages are set:

RewriteEngine on
RewriteBase /

# mobile index page
RewriteRule ^$ /mobile_index.php [L,QSA]

# other mobile-specific rewrite rules go here
...

# mobile video page
RewriteRule ^videos/([0-9]+)/([^/]+)/([0-9]+)/$ /mobile_view_video.php?id=$1&dir=$2&from=$3 [L,QSA]
RewriteRule ^videos/([0-9]+)/([^/]+)/$ /mobile_view_video.php?id=$1&dir=$2 [L,QSA]

# mobile album page
RewriteRule ^albums/([0-9]+)/([^/]+)/([0-9]+)/$ /mobile_view_album.php?id=$1&dir=$2&from=$3 [L,QSA]
RewriteRule ^albums/([0-9]+)/([^/]+)/$ /mobile_view_album.php?id=$1&dir=$2 [L,QSA]
RewriteRule ^albums/([0-9]+)/([^/]+)/image([0-9]+)/([0-9]+)/$ /mobile_view_album.php?id=$1&dir=$2&image_id=$3&from=$4 [L,QSA]
RewriteRule ^albums/([0-9]+)/([^/]+)/image([0-9]+)/$ /mobile_view_album.php?id=$1&dir=$2&image_id=$3 [L,QSA]

# some other rewrite rules which are the same
RewriteRule ^random_video(/)?$ /redirect_random_video.php [L,QSA]
RewriteRule ^random_album(/)?$ /redirect_random_album.php [L,QSA]
RewriteRule ^cs/(.*)/.*$ /redirect_cs.php?dir=$1 [L,QSA]

# SYSTEM / DO NOT CHANGE -----------------------------------------------------------------------------------------------

RewriteRule ^embed/(.+)$ /player/iframe_embed.php?video_id=$1 [L,QSA]
RewriteRule ^related_videos_xml/([0-9]+)/?$ /related_videos_xml.php?video_id=$1 [L,QSA]
RewriteRule ^get_file/([0-9]+)/([^/]*)/(.*)$ /get_file.php?sg_id=$1&hash=$2&file=$3 [L,QSA]
RewriteRule ^get_image/([0-9]+)/([^/]*)/(.*)/$ /get_image.php?sg_id=$1&hash=$2&file=$3 [L,QSA]

# END SYSTEM -----------------------------------------------------------------------------------------------------------

For these rules to function correctly, you need to create all these pages in the Website UI section, and set up the way they look. In this example, we have rules for 3 mobile pages with these IDs: mobile_index (the index page), mobile_view_video (mobile video page), and mobile_view_album (mobile photo album page).

Now, when you go to http://m.domain.com, you are supposed to see the mobile index page. If some links on your pages still lead to domain.com and not m.domain.com, there can be 2 reasons for that:

  • In site templates, you set up your links directly through http://domain.com. This is not the best option for plenty of reasons. Instead of specifying your domain name in the templates, use the {{$config.project_url}} variable to generate your links, e.g.: {{$config.project_url}}/latest-updates/
  • If your original KVS version was less than 3.5.0, you will need to modify the /admin/include/setup.php file so that the links are switched to mobile, if your site is opened via the mobile subdomain. To do that, add this code in the bottom of the file before ?>, replacing domain.com with your domain name: if ($_SERVER['SERVER_NAME']== 'm.domain.com')
    {
        $config['project_url']="http://m.domain.com";
    }

Now all links on your mobile site should take the user to pages on the mobile subdomain. On your original site for desktop users, all links should point to your original non-mobile pages. Finally, to make your player work, create a copy of your /player/.htaccess file named /player/.htaccess_mobile, replacing domain.com with m.domain.com in its content.

6.4. How do I restore my site from a backup I created with the KVS plugin?

The backup plugin creates an archive with 3 components of your site:

  • Database: the mysql/backup.sql file in the archive. To restore your database from backup, you need to create a new database and execute backup.sql in it: mysql --user=%DB_USER% --password=%DB_PASS% --force --verbose %DB_DEVICE% < backup.sql Here %DB_USER% and %DB_PASS% are database user and password, and %DB_DEVICE% is the new database name. Then, set new database connection settings in /admin/include/setup_db.php.
  • KVS system files: the kvs folder in the archive. To restore system files, copy the contents of the kvs folder to your site's root folder. Do not delete any old site files.
  • Website settings: website folder in the archive. To restore your site to the condition it was when the backup was created, copy the contents of the website folder to your site's root folder. Do not delete any old site files.

When you are done restoring your site, run the audit plugin to make sure your site is functioning properly, and fix the errors it finds, if any.

6.5. How do I configure file uploads via subdomain when running under CloudFlare?

CloudFlare limits upload filesize to 100 megabytes. In order to workaround this limit you should configure an upload.domain.com subdomain (or any other name up to you) and configure KVS to use this subdomain for uploading files.

There are 2 things you should consider when configuring this subdomain in Apache:

  • The DocumentRoot setting needs to be assigned to the same folder where KVS is installed for your primary domain.
  • The AccessFileName setting needs to contain a filename different from your standard .htaccess, e.g. .htaccess_upload.

An example of how such a subdomain can be set up in Apache:

DocumentRoot /var/www/domain.com/public_html
ServerName upload.domain.com
ServerAlias upload.domain.com
AccessFileName .htaccess_upload

Here is what you should put into .htaccess_upload - please note that it contains max filesize limit as well (2000M), so you may need to adjust it:

php_flag magic_quotes_gpc Off
php_flag register_globals Off
php_flag display_errors Off
php_value upload_max_filesize 2000M
php_value post_max_size 2000M

RewriteEngine on
RewriteBase /

Header set Access-Control-Allow-Origin "*"

RewriteCond %{REQUEST_METHOD} =POST
RewriteRule ^uploader$ /admin/include/uploader_nginx.php [L,QSA]

RewriteCond %{REQUEST_METHOD} =POST
RewriteRule ^upload-video/$ /member_profile_view.php?type=upload_video [L,QSA]

RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{REQUEST_URI} !^/admin/include/uploader_nginx\.php.*
RewriteCond %{REQUEST_URI} !^/member_profile_view\.php.*
RewriteRule ^.*$ - [R=404,L]

RewriteCond %{REQUEST_METHOD} =GET
RewriteRule ^.*$ - [R=404,L]

Modify /admin/include/setup.php file with the new uploader URL:

$config['uploader_url']="http://upload.domain.com/uploader";

After doing this you should be able to upload big files from admin panel. In order to re-configure your site templates please create a ticket for our tech support, specify your domain name there and enable KVS support access in admin panel on starting page.