Keyword

Template Override

  • Michael Brown
  • Michael Brown's Avatar Topic Author
  • Offline
  • New Member
More
8 years 10 months ago - 8 years 10 months ago #149076 by Michael Brown
Template Override was created by Michael Brown
Hi,

I thought I had this figured out, but I have a problem. Template override the way I have it setup only seems to work if the folder directory is named 'default', other template overrides do not work either.

http://postimg.org/image/aff7e2tc7/full/



I first modified the default override to my specific style / layout. It does work as default. However when I change the folder directory name from "default" to anything else, the override files do not load on the page, thus all of the styling is absent.

Likewise, my other template override ('regular' as seen in the link above) doesn't work at all.

Specific Questions:

1) is my file structure correct for the overrides (file structure visible in link above)? If I change the 'default' folder name to something like 'puppies', set the template for the category in K2 and update the css link, the stylesheet isn't included in the page. I must have the folder structure wrong?

Thank you for any insight you may have on this!
Last edit: 8 years 10 months ago by Michael Brown.

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

More
8 years 10 months ago #149112 by Lefteris
Replied by Lefteris on topic Template Override
Hi,

If you create a custom override you also have K2 to use this instead of the default one. You can select which override will be used in the category edit page. If you have created a menu link, this option is also available in the menu link.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Michael Brown
  • Michael Brown's Avatar Topic Author
  • Offline
  • New Member
More
8 years 10 months ago #149134 by Michael Brown
Replied by Michael Brown on topic Template Override
Hi Lefteris,

Yes, I only have one menu item 'blog' which points to a category overview. The new template override created does show up in the category template option, but when selected, the css does not load to the page. Only default works. I verified these settings were correct.

My file structure is correct for the template override and there is no special file name format required for the .css override file, correct?

I know this should be simple, but it isn't working and I can't seem to see why not. I have poured over the settings for hours.

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

  • Michael Brown
  • Michael Brown's Avatar Topic Author
  • Offline
  • New Member
More
8 years 10 months ago #149137 by Michael Brown
Replied by Michael Brown on topic Template Override
So I was looking at the menu item settings for the k2 blog - i saw it had an option to set the template to all of k2. I changed that master template setting from default to 'regular' and it does in fact work. The style changes and the width applies to the blog category view and the css file is pulled...but it of course changes it on all categories. This shows the css folder structure is right..so why when I change a specific K2 category template does it not change on the front-end? This is fairly maddening.

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

More
8 years 10 months ago #149147 by Lefteris
Replied by Lefteris on topic Template Override
If you have a menu link pointing to a single category then the option for selecting the template is located in the category edit page, not in the menu link. Have you selected your desired template at the category page?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Michael Brown
  • Michael Brown's Avatar Topic Author
  • Offline
  • New Member
More
8 years 10 months ago #149156 by Michael Brown
Replied by Michael Brown on topic Template Override
yes, the category within K2 is set to use the template via the drop down option. I have several template overrides created, none of which change the css on K2, none of which are loaded as viewed from html view source. I've fiddled with the k2 component for many hours so i'm pretty familiar with the location of the settings at this point.

To configure the k2 override there really seems to be two basic steps, possibly 3 depending on the situation:

1) create the folder directory from the original 'default' K2 folder - copy, rename, add css edits as required and a link to the appropriate .php file for the custom k2 template override css file.
2) go into K2 component, into categories and select the template override from the template drop down option
3) if you created additional k2 categories and have one menu item pointed to the k2 component category view - make sure you go back into the menu item and add the additional categories created to the 'content' tab.

The steps are simple, the expected result is ...elusive for some dang reason. It's becoming quite aggravating on my end :/

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

  • Michael Brown
  • Michael Brown's Avatar Topic Author
  • Offline
  • New Member
More
8 years 10 months ago - 8 years 10 months ago #149158 by Michael Brown
Replied by Michael Brown on topic Template Override
Okay, progress.

My template overrides work. One final question.

My blog menu link in joomla goes to the K2 category view. I was hoping the template override would apply even when you are not in that specific category, but rather in the category view page that has blog posts from all combined categories. As of right now, the template override is only visible when you enter into that specific category.

Is there a way to target a specific category to modify the css when in the category view? I have added an extension that allows you to put a k2 blog post into multiple categories, and that works wonderfully, but again the css only applies when you enter into that specific category, it doesn't apply in the overview category view. Would I need to add php to target the category names in the category.php file?

You may be wondering why I want this, it is so I am able to apply a different width to any single blog post regardless of the category the post belongs to. I create an override something like "wide" and that blog post when assigned to 'wide' will have a width of maybe 49%. I hate the cookie cutter grid layout :) Odd for a guy with OCD.
Last edit: 8 years 10 months ago by Michael Brown. Reason: Updated Status

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

More
8 years 10 months ago #149174 by Lefteris
Replied by Lefteris on topic Template Override
Just to make things clear: K2 always loads a single CSS file. The file is located at components/com_k2/css/k2.css. If you want to make changes to that file you can copy it to templates/YOUR_TEMPLATE/css/k2.css .

If K2 detects that this file exists in your template it will load that file instead of the one located in the component.

Template overrides allow you to change the HTML markup of the component, not CSS. The recommended way is to add custom class names in your overrides and then apply styling targeting those classes in your CSS file.

Regarding the multiple categories listing, you wrote that you have added an extension. You have to ask the extension developer for help. If you want to create a page listing items from multiple categories, you can do it directly from K2. Just create a menu link to "K2 categories" and select the desired categories. There you will also fine an option to select which K2 template you want to be used.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Michael Brown
  • Michael Brown's Avatar Topic Author
  • Offline
  • New Member
More
8 years 10 months ago #149191 by Michael Brown
Replied by Michael Brown on topic Template Override
Okay, so going back to my very first original post on this thread as well as the old thread asking to verify if my folder structure was correct, I'm now learning it is wrong.

I have fixed that which is a good thing.

K2 puts all categories into one CSS class: .itemContainer

That is the problem that I don't know how to work around. It has nothing to do with external extensions. The Add K2 categories component works perfectly and is well documented and intuitive, so no need to contact them.

K2 structure doesn't allow css targeting of a specific category with CSS in the category overview? I would have to add PHP to get the category name and then load a specific CSS sheet to override a targeted K2 category in category viewing, is that correct?

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

More
8 years 10 months ago #149200 by Lefteris
Replied by Lefteris on topic Template Override
Yes, that is correct. Editing the templates and adding custom class names is the recommended way. For example you create a template named "michael" and then edit it's layout files to add a class name "myclass".

Select this template for the categories you wish and then target the "myclass" class name on your CSS.

In CSS you can also target using the full path selector:
.itemContainer {...}
.myclass .itemContainer {...}

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum