In this tutorial you will learn the way to duplicate k2 item module sub template and edit it.
- Open your admin panel and locate correct module (you can locate by pressing enable/disable button)
- Open correct module and check module template used, see “Select sub-template” on the top right.
- Now you need to open your FTP and locate your Joomla root folder (the one that you’ve used to install Joomla)
- Open the following folder: /templates/YOUR_THEME/html/mod_k2_content
we use “YOUR_THEME” but you should open your theme folder, regularly it is “themeXXX” (XXX are numbers)
We open “mod_k2_content” folder as it is the one used for our module, you can check module title in Extensions >> Modules and clicking the module you need:
- After opening correct folder you should see some folders – each folder is a separate module template and as you need to create new template you just need to copy existing folder (folder contents as well, you need to have same structure inside folder, do not change filenames inside folder), rename it and paste in the same place so you have all same folders and one new (we will use it as new template).
- Open your new folder and you will see “default.php” file – this is the one we need to update it – open it with any text editor. You will see a lot of scripting but it is really easy to locate is the script is set into separate blocks, e.g. (for displaying item image)
<?php if($params->get('itemImage') && isset($item->image)): ?> <a class="moduleItemImage" href="" title="<?php echo JText::_('K2_CONTINUE_READING'); ?> "<?php echo K2HelperUtilities::cleanHtml($item->title); ?>""> <img src="<?php echo $item->image; ?>" alt="v?php echo K2HelperUtilities::cleanHtml($item->title); ?>"/> </a> <?php endif; ?>
As you can see there is heading “itemImage” so we can be sure what it is for.
- Now as we have new template and the file opened we can edit it, to remove linking from image we just need to locate proper block (we just specified it before) and remove the actual link (anchor) tag to look as it follows:
<?php if($params->get('itemImage') && isset($item->image)): ?> <img src="<?php echo $item->image; ?>" alt="<?php echo K2HelperUtilities::cleanHtml($item->title); ?>"/> <?php endif; ?>
- The last step we need to do is to open Extensions >> Modules >>, open the template you want to use k2 item new sub template and assign it in “Select sub-template” section on the top right, save it and refresh your website.
This method will work to edit any content of k2 modules even in case you don’t have such option in admin panel.
After you set up new module sub template you will be able to create new module, displaying content in a different way.
Feel free to check the detailed video tutorial below: