- Posts: 2
COMMUNITY FORUM
Best Practices for custom K2 templates and code
- Preston
- Topic Author
- Offline
- New Member
Less
More
12 years 6 months ago #64025
by Preston
Best Practices for custom K2 templates and code was created by Preston
Hello,
I'm new to Joomla and K2 and would like the insight of experienced K2 folks. I've created a custom K2 template, which is stored in:
[mySite]/templates/rt_modulus_j16/html/com_k2/[myTemplate]
I've made a number of changes to the PHP code in the template files. I've also created a PHP class that's used by this template. Ideally I'd like to make this custom class available site-wide (i.e. not just tied to this template).
One specific question I have is where should I place this custom PHP class, and what do I need to do to make it generally available. I've read some things about auto-loading of classes, but I've not found a good explanation of this yet, and am not sure this is the proper approach.
My broader concern is I want to make my customizations in a way that will minimize the impact of any future updates to Joomla and/or K2. What suggestions do you have with regard to this?
Thanks,
Preston
I'm new to Joomla and K2 and would like the insight of experienced K2 folks. I've created a custom K2 template, which is stored in:
[mySite]/templates/rt_modulus_j16/html/com_k2/[myTemplate]
I've made a number of changes to the PHP code in the template files. I've also created a PHP class that's used by this template. Ideally I'd like to make this custom class available site-wide (i.e. not just tied to this template).
One specific question I have is where should I place this custom PHP class, and what do I need to do to make it generally available. I've read some things about auto-loading of classes, but I've not found a good explanation of this yet, and am not sure this is the proper approach.
My broader concern is I want to make my customizations in a way that will minimize the impact of any future updates to Joomla and/or K2. What suggestions do you have with regard to this?
Thanks,
Preston
Please Log in or Create an account to join the conversation.
- william white
- Offline
- Platinum Member
Less
More
- Posts: 3722
12 years 6 months ago #64026
by william white
Replied by william white on topic Re: Best Practices for custom K2 templates and code
if you put your code anywhere but html/com_k2/templates/youroverride it will get whacked by both k2 and template upgrades...be carefull about template upgrades if they already have a com_k2 directory in them as well......backup is the only sure way
Please Log in or Create an account to join the conversation.
- Preston
- Topic Author
- Offline
- New Member
Less
More
- Posts: 2
12 years 6 months ago #64027
by Preston
Replied by Preston on topic Re: Best Practices for custom K2 templates and code
Thanks William
Please Log in or Create an account to join the conversation.
- Aaron
- Offline
- Premium Member
12 years 6 months ago #64028
by Aaron
Aaron :)
Replied by Aaron on topic Re: Best Practices for custom K2 templates and code
I agree with William, but I found that during development, it is easier to keep the K2 templates in the components/com_k2/templates folder.
Once you finish development and have settled on a template, then you should move the template to html/com_k2/templates/youroverride as William recommends.
The other thing I have found is that it is better to keep the code as simple as possible. Trying to add in a lot of special code will increase the risk that you will have to do work if there is an update.
Once you finish development and have settled on a template, then you should move the template to html/com_k2/templates/youroverride as William recommends.
The other thing I have found is that it is better to keep the code as simple as possible. Trying to add in a lot of special code will increase the risk that you will have to do work if there is an update.
Aaron :)
Please Log in or Create an account to join the conversation.