Keyword

Sub-templating issue

  • Stewart Kingsley
  • Stewart Kingsley's Avatar Topic Author
  • Offline
  • New Member
More
11 years 6 months ago #104821 by Stewart Kingsley
Sub-templating issue was created by Stewart Kingsley
I have been spending the last 2 days trying to get the subtemplating to work with K2, there are some articles that are either incorrect or just simply misleading. However I have finally got it working after delving into the code to see what is going on.

After some time I came to understand the k2 elements folder and the xml files that reside there. Looking at the category.xml file i noticed that the theme parameter was of type category, and there was no k2 element of the same name only moduletemplate which after looking at the code looked exactly the element that would do the trick.

After some fiddling the theme field has now become a text field, where I can manually enter my customised theme name, which works perfectly. I realise that the code should be a dropdown list, as this is what the moduletemplate element works, but there seems to be caching involved or some other magic that is causing the textbox to appear instead.

Maybe someone can have a proper look at this and resolve it before it becomes a real issue with newbies.

Please Log in or Create an account to join the conversation.

More
11 years 6 months ago #104822 by william white
Replied by william white on topic Re: Sub-templating issue
The movies from ostraining under documentation show how to correctly configure a k2 template or override
the override should be a copy of the folder
YoursiteRoot/components/com_k2/templates/default
placed in
YourSiteRoot/Templates/YourTemplateName/html/com_k2/templates and renamed from default to your custom template name
It will then show in the pick list when you look at a k2 category and it contains the php files to edit so you can both change the display of the items and also not loose your changes upon upgrade

Please Log in or Create an account to join the conversation.

  • Stewart Kingsley
  • Stewart Kingsley's Avatar Topic Author
  • Offline
  • New Member
More
11 years 6 months ago #104823 by Stewart Kingsley
Replied by Stewart Kingsley on topic Re: Sub-templating issue
Actually the code does not work the way you describe, the template overrides should NOT be in a Templates subfolder.... each template should be a subfolder of YourSiteRoot/Templates/YourTemplateName/html/com_k2. The code will retrieve the component templates and also the template sub-templates and put them into the same list, however it is his list that is not functioning correctly, Although the sub-templating works correctly now that I can set the theme name in the admin screen.

With the latest version of Joomla and K2, can you confirm that you are able to set the theme name in any of the K2 categories, menus etc?

If you can then I will check if there is a conflict with another component that is causing the problem.

Please Log in or Create an account to join the conversation.

More
11 years 6 months ago #104824 by william white
Replied by william white on topic Re: Sub-templating issue
I am speaking only of regular category overrides.
In my j2.5 install with k2 2.6.1 When i locate the files in Root/templates/MyTemplate/html/com_k2/MyOverride it is not picked up in the Edit Category- Item Layout - Select a Template Picklist
It shows only when i place it in html/com_k2/templates/MyOverride directory

I do see in the docs here getk2.org/documentation/tutorials/item/174-templating-with-k2-and-the-concepts-of-sub-templates that it does not say to put it there

but i also see in the movie from ostraining about templating they are using the templates directory to put the overrides in and also,

in the templates from gavick and jbamboo w k2 support i find the overrides in a templates folder.
I do see

I have never used an xml file for templating starting with early versions of k2
You may be correct or i may be missing something about the docs that are confilicting
the attached file shows what is working for me
Attachments:

Please Log in or Create an account to join the conversation.

  • Stewart Kingsley
  • Stewart Kingsley's Avatar Topic Author
  • Offline
  • New Member
More
11 years 6 months ago #104825 by Stewart Kingsley
Replied by Stewart Kingsley on topic Re: Sub-templating issue
It seems my earlier observations were not entirely correct. I had assumed that my K2 installation had been complete, but it had in fact missing the template.php element file. After restoring the file onto my site I can see that the code actually allows both templates folders directly inside the Mytemplate/html/com_k2 folder OR in Mytemplate/html/com_k2/templates folder. This would explain the slightly differing approaches to K2 template overriding.
While reviewing the Joomla element code I had noticed that the current method of elements that K2 uses appears to be deprecated.

One small thing I have changed that I thought might of interest is that in /administrator/components/com_k2/elements/template.php, line 62, I have replaced the preg_match with a simple equality statement as the preg was matching any folder name that included default.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum