- Posts: 14
COMMUNITY FORUM
sub-templates for K2Content module
- trumpeter
- Topic Author
- Offline
- New Member
Less
More
15 years 3 months ago #71262
by trumpeter
sub-templates for K2Content module was created by trumpeter
how do I create sub-templates for this?
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.
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
Less
More
- Posts: 16
15 years 3 months ago #71263
by DAVID JANES
Replied by DAVID JANES on topic sub-templates for K2Content module
In your root go to modules/mod_k2_content/tmpl. In there where the module sub-template folders go. Right now you'll see a default folder. Just duplicate the folder and rename it what you want. Then you can edit default php to make some changes. You then select the new subtemplate in the module options. Also to have multiple k2 content modules, just copy the module you have and rename it then adjust to display the content you want. If you want to style them differently then I just assume to change the module class suffix so that it can be styled in the css using different classes so they don't interact. Havent done different stylings for them myself yet so I'm not sure how well that works. Just play around with it and see what happens, its the best way to learn.
Please Log in or Create an account to join the conversation.
- trumpeter
- Topic Author
- Offline
- New Member
Less
More
- Posts: 14
15 years 3 months ago #71264
by trumpeter
Replied by trumpeter on topic sub-templates for K2Content module
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?
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
Less
More
- Posts: 16
15 years 3 months ago #71265
by DAVID JANES
Replied by DAVID JANES on topic sub-templates for K2Content module
I dont think so. It would be a good habit to backup any original or modified code you make. That way in case something does get overwritten on an update or if something horrible happens to your server files then you can replace it.
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?
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
Less
More
- Posts: 4
15 years 3 days ago #71266
by Krzysztof
Replied by Krzysztof on topic sub-templates for K2Content module
It's weird, to make your subtemplate work you need to create respective folder in modules/mod_k2_content/tmpl, let's say Featured, then put similar folder in templates/YOURTEMPLATE/html/mod_k2_content/Featured. Works fine for me.
Please Log in or Create an account to join the conversation.
- Gary Heitman
- Offline
- New Member
Less
More
- Posts: 2
14 years 11 months ago #71267
by Gary Heitman
Replied by Gary Heitman on topic sub-templates for K2Content module
Thank you folks! This was very helpful to determine the discrepancy in the "documentation" ;) MAYBE this can be added to the otherwise very helpful information on 'K2 Templating' (?)
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.
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
Less
More
- Posts: 25
14 years 8 months ago #71268
by jamesrward
Replied by jamesrward on topic sub-templates for K2Content module
Yes this needs to be documented better. I had to read this thread a couple times to understand what is going on. Basically the K2 Component will look for templates in:
/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.
/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
Less
More
- Posts: 175
14 years 7 months ago #71269
by Oceanwatcher
Replied by Oceanwatcher on topic sub-templates for K2Content module
The mod_k2_content module should look for its template first in /modules/mod_k2_content/tmpl. This is where you find a folder called default with a file called default.php .
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.
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
Less
More
- Posts: 25
14 years 6 months ago #71270
by jamesrward
Replied by jamesrward on topic sub-templates for K2Content module
This does not appear to work in v2.2
Please Log in or Create an account to join the conversation.
- Oceanwatcher
- Offline
- Elite Member
Less
More
- Posts: 175
14 years 6 months ago #71271
by Oceanwatcher
Replied by Oceanwatcher on topic sub-templates for K2Content module
Sorry if my former message was unclear. I meant "I have it working in v. 2.3 AS WELL" :-) Yes, it work perfect in 2.2, so maybe you need to check that you have everything set up correct.
James Ward said:This does not appear to work in v2.2
James Ward said:This does not appear to work in v2.2
Please Log in or Create an account to join the conversation.