Announcement

Collapse
No announcement yet.

Theme customization: how to add search queries to KVS sitemap

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

  • Theme customization: how to add search queries to KVS sitemap

    General sitemap structure in KVS

    KVS renders sitemap dynamically as a typical web page configured to produce XML format instead of HTML. You can find sitemap page in Website UI -> Pages -> [System] Sitemap:

    Click image for larger version

Name:	sitemap_page_structure.png
Views:	449
Size:	50.0 KB
ID:	1144

    Due to specific sitemap structure limitations on the number of links, KVS breaks down sitemap into several sitemap indexes, rendering different entities:
    - Videos
    - Albums
    - Playlists
    - Tags
    - Models
    - Categories
    - Sponsors
    - Channels

    Sitemap indexes that can potentially generate more than 50k links are additionally broken down into paginated sitemaps. That's why sitemap page renders 2 blocks for some object types (videos, albums, playlists, models, tags): one block is for listing all pages (e.g. Sitemaps Videos), another block is for listing all objects per page (e.g. Links to Videos).

    For categories, sponsors and channels KVS considers that their amount is small, so they are rendered as single lists.


    Adding search queries into sitemap

    Since the number of search queries is potentially unlimited, you should consider adding them as 2 blocks similar to models.

    1) Open Sitemap page for editing and add the following 2 blocks into it:

    HTML Code:
    {{insert name="getBlock" block_id="search_results" block_name="Sitemaps Search Queries"}}
    HTML Code:
    {{elseif $smarty.request.type=='search'}}
        {{insert name="getBlock" block_id="search_results" block_name="Links To Search Queries"}}
    Here are the highlighted locations where to add these blocks as their position is quite important:

    Click image for larger version

Name:	sitemap_search_blocks.png
Views:	214
Size:	51.3 KB
ID:	1145

    2) Save page editor. After saving you can see that 2 new blocks were added to page structure with default settings:

    Click image for larger version

Name:	sitemaps_search_queries_default.png
Views:	208
Size:	8.3 KB
ID:	1146

    Click image for larger version

Name:	links_to_search_queries_default.png
Views:	214
Size:	8.0 KB
ID:	1147

    3) Open Sitemaps Search Queries block for editing. Set its template to the following code:

    HTML Code:
    {{section start=1 loop=$nav.page_total+1 name=pages}}
    <sitemap>
        <loc>{{$lang.urls.sitemap}}?type=search&amp;from_links_search={{$smarty.section.pages.index}}</loc>
        <lastmod>{{$smarty.now|date_format:"%Y-%m-%d"}}</lastmod>
    </sitemap>
    {{/section}}
    Set Cache lifetime (s) to 86400.

    Set the following parameter values:

    - items_per_page = 500
    - var_from = from_sitemaps_search
    - sort_by = Query text Desc

    Save this block editor.

    4) Open Links To Search Queries block for editing. Set its template to the following code:

    HTML Code:
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    {{foreach item=item from=$data}}
    {{assign var="query" value=$item.query|replace:"-":"[dash]"|replace:"&":"%26"|replace:"?":"%3F"|replace:"/":"%2F"|replace:" ":"-"|replace:"[dash]":"--"|rawurlencode}}
        <url>
            <loc>{{$lang.urls.search_query|replace:"%QUERY%":$query}}</loc>
            <lastmod>{{$smarty.now|date_format:"%Y-%m-%d"}}</lastmod>
            <changefreq>weekly</changefreq>
            <priority>0.6</priority>
        </url>
    {{/foreach}}
    </urlset>
    Set Cache lifetime (s) to 86400.

    Set the following parameter values:

    - items_per_page = 500
    - var_from = from_links_search
    - sort_by = Query text Desc

    Save this block editor.

    5) Now you should have a fully working search sitemap inside your main sitemap index. Try opening your sitemap and look for "search" keyword:

    Code:
    http://domain.com/sitemap.php
    If your database has search queries, you should see something like this in your sitemap:

    Code:
    http://domain.com/sitemap/?type=search&from_links_search=1
    http://domain.com/sitemap/?type=search&from_links_search=2
    ....
Working...
X