Hello there. And now, we continue to explain of unlimited features of K2 Filter and Search module and tell you, how to act it as content module (show some K2 items without make search). There are two way for make it: with Ajax mode and default mode.

 

1) Ajax mode

You will need to modify the template file here - modules/mod_k2_filter/tmpl/Default/elements/ajax_results.php (you can create new sub-template first).

Find this block of code:

1
2
jQuery(document).ready(function() {			
  jQuery('body').on("click"..............

 Then, just append ajax_results<?php echo $module->id; ?>() after first line:

1
2
3
jQuery(document).ready(function() {		
  ajax_results<?php echo $module->id; ?>();
  jQuery('body').on("click"..............

 

You can hold it as is, and it will show some search results without any search criteria on initial page loading.

But, for make it show some specific K2 items, e.g. based on some extrafield value or tag value, you should do the following:

1) Execute some search for get the K2 items you need. 

2) See generated URL and copy the query parameters, e.g. category=3&array2%5B%5D=Front+wheels&moduleId=116&Itemid=128

3) Modify ajax_results.php file.

Find this line:

1
data: data + "&format=raw",

 And replace it with the following, include data that you copied from the url:

1
data: "category=3&array2%5B%5D=Front+wheels&moduleId=116&Itemid=128&format=raw",

 

That's all, then you just need to hide K2 Filter module's block through css and it will show only some K2 items by default.

 

2) Default mode

By this way, you can show search results on any page of your site (menu item). It will show search results and K2 items by default (on initial page loading).

You need to modify Joomla menu item through phpMyAdmin (modify the database). Also, you can use Adminer extension for access the DB.

Find your menu item in *_menu table (it can be also homepage menu item). 

Then, modify 'link' attribute and place the following text (use the query parameters, that you copied from search results page) :

index.php?option=com_k2&view=itemlist&task=filter&category=3&array2%5B%5D=Front+wheels&moduleId=116&Itemid=128

 

That's all. Have fun! And you can ask about any questian through the Contact form.