Categories

Featured templates

Joomla. How to duplicate k2 module sub template and edit it

Phil Nowak August 3, 2012
Rating: 5.0/5. From 1 vote.
Please wait...

In this tutorial you will learn the way to duplicate k2 item module sub template and edit it.

  1. Open your admin panel and locate correct module (you can locate by pressing enable/disable button)
  2. Open correct module and check module template used, see “Select sub-template” on the top right.
  3. Now you need to open your FTP and locate your Joomla root folder (the one that you’ve used to install Joomla)
  4. 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:

  5. 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).
  6. 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.

  7. 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; ?>
    			
  8. 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:

Joomla. How to duplicate k2 module sub template and edit it

Latest Joomla Templates
This entry was posted in Joomla! Tutorials and tagged item, joomla, k2, sub-template. Bookmark the permalink.

Submit a ticket

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket