- Posts: 14
COMMUNITY FORUM
sub-templates for K2Content module
- trumpeter
-
Topic Author
- Offline
- New Member
I have a k2content module at the top of my front page. It is using the default template to display a featured article.
Now, further down on my main page, I would like to use another k2content module to display non-featured articles with a slightly different layout.
Can someone explain how this is achievable? Thanks.
Please Log in or Create an account to join the conversation.
- DAVID JANES
-
- Offline
- New Member
- Posts: 16
Please Log in or Create an account to join the conversation.
- trumpeter
-
Topic Author
- Offline
- New Member
- Posts: 14
Do you know if it's possible to put these files in my overall template folder somehow so that I don't lose them on updates?
Please Log in or Create an account to join the conversation.
- DAVID JANES
-
- Offline
- New Member
- Posts: 16
Jimmy Cricket said:Thanks Dave.
Do you know if it's possible to put these files in my overall template folder somehow so that I don't lose them on updates?
Please Log in or Create an account to join the conversation.
- Krzysztof
-
- Offline
- New Member
- Posts: 4
Please Log in or Create an account to join the conversation.
- Gary Heitman
-
- Offline
- New Member
- Posts: 2
I, too, agree that backups are very important - they wouldn't call it Content Management if there wasn't some work involved, I suspect ... maybe Content uh ... something. :)
Additionally, I also agree that it would make more sense to have ALL templates located in the specific template folder, rather than sprinkled around - or, at least having a choice which area to use?
Again thanks - the Forum saved me the trouble of poking around too much on my own.
Please Log in or Create an account to join the conversation.
- jamesrward
-
- Offline
- Junior Member
- Posts: 25
/templates/[joomla template]/html/com_k2/templates/[yourtemplatename]/
But K2 Modules will look for templates in:
/modules/mod_k2_content/tmpl/[yourmoduletemplatename]/
These templates are in no way linked, one does not require the other and they can have completely different names as I have tried to indicate in my paths. Hopefully this will make it easier to understand for the next person who stumbles across this thread.
And yes this is a terrible situation for data to be overwritten during an upgrade. Hopefully the jw gang will come up with a better solution in the future.
Thanks for the help all.
Please Log in or Create an account to join the conversation.
- Oceanwatcher
-
- Offline
- Elite Member
- Posts: 175
To make a template override, go to
/templates/YOUR ACTIVE JOOMLA TEMPLATE/html/ and create a folder called mod_k2_content. In this folder you add a new folder with the name of your new template. Copy the default.php file mentioned above into this new folder. You should then get a structure like this for your new template:
/templates/YOUR ACTIVE JOOMLA TEMPLATE/html/mod_k2_content/new-template/default.php
You can not change the name default.php, but you can now go ahead and change this file to suit your need.
The new template appears in the sub-template drop down menu. I have this working in v. 2.3 beta.
If you set up your template override this way, it will not be lost when you upgrade k2. But you should of course make regular backups of your site. If you have not done it yet, check out Akeeba Backup.
Please Log in or Create an account to join the conversation.
- jamesrward
-
- Offline
- Junior Member
- Posts: 25
Please Log in or Create an account to join the conversation.
- Oceanwatcher
-
- Offline
- Elite Member
- Posts: 175
James Ward said:This does not appear to work in v2.2
Please Log in or Create an account to join the conversation.
- jamesrward
-
- Offline
- Junior Member
- Posts: 25
/modules/mod_k2_content/tmpl/[mymoduletemplatename]/
and moved it to:
/templates/MY ACTIVE JOOMLA TEMPLATE/html/mod_k2_content/[mymoduletemplatename]/
I clear the cache and edit my module and the sub-template disappears from the Select sub-template drop-down.
Please Log in or Create an account to join the conversation.
- jamesrward
-
- Offline
- Junior Member
- Posts: 25
param name="getTemplate" type="folderlist" default="Default" label="Select sub-template" directory="/modules/mod_k2_content/tmpl" hide_default="1" hide_none="1" description=""
With the directory set as /modules/mod_k2content/tmpl
And in the php it looks like it just takes that variable directly. I don't see any if statements looking for templates in other directories.
Maybe 2.3 changes this.
Please Log in or Create an account to join the conversation.
- Oceanwatcher
-
- Offline
- Elite Member
- Posts: 175
Sorry, was thinking about the general com_k2 template override while talking about the module templateoverride.
I stand corrected :-)
The functionality in v. 2.3 is how it SHOULD work and in general is how all extensions in Joomla should work. I am not sure how it will be handled from Joomla v. 1.6 as that one will have automatic upgrades (yay!). It will put more stress on developers and sitebuilders to use overrides and extensions instead of editing core files.
And last, but not least - backup, backup, backup .... eh... backup!
Thank you for correcting this.
James Ward said:A quick look at the xml file for the module shows this line:
param name="getTemplate" type="folderlist" default="Default" label="Select sub-template" directory="/modules/mod_k2_content/tmpl" hide_default="1" hide_none="1" description=""
With the directory set as /modules/mod_k2content/tmpl
And in the php it looks like it just takes that variable directly. I don't see any if statements looking for templates in other directories.
Maybe 2.3 changes this.
Please Log in or Create an account to join the conversation.