- Posts: 11
COMMUNITY FORUM
Template Override
- Michael Brown
-
Topic Author
- Offline
- New Member
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!
Please Log in or Create an account to join the conversation.
- Lefteris
-
- User
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.
Please Log in or Create an account to join the conversation.
- Michael Brown
-
Topic Author
- Offline
- New Member
- Posts: 11
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
-
Topic Author
- Offline
- New Member
- Posts: 11
Please Log in or Create an account to join the conversation.
- Lefteris
-
- User
Please Log in or Create an account to join the conversation.
- Michael Brown
-
Topic Author
- Offline
- New Member
- Posts: 11
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
-
Topic Author
- Offline
- New Member
- Posts: 11
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.
Please Log in or Create an account to join the conversation.
- Lefteris
-
- User
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.
Please Log in or Create an account to join the conversation.
- Michael Brown
-
Topic Author
- Offline
- New Member
- Posts: 11
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.
- Lefteris
-
- User
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 {...}
Please Log in or Create an account to join the conversation.
- Michael Brown
-
Topic Author
- Offline
- New Member
- Posts: 11
I need this to work not in the category_item.php but rather in the category.php file.
When I copy the working code from category_item.php to category.php it does not exectute. Any thoughts on how to apply a css style to a specific category while in the k2 category layout view?
All I'm attempting to do is on the k2 category layout, have a grid of 4 columns, one of the items will have a different css style - regardless of k2 category assignment.
Please Log in or Create an account to join the conversation.
- Lefteris
-
- User
Please Log in or Create an account to join the conversation.
- Erwin Hunter
-
- Offline
- New Member
- Posts: 2
Can you please share what you did to get the overrides to work? I have been combing the internet and can not find a solution. I followed JoomlaWorks instruction to a T. Everything you mentioned in the beginning of your post is exactly what I am experiencing. Only the default folder is getting picked up. I copied that folder to a folder called photogallery. Changed the template in both the K2 Categories area and on the Menu. I have placed additional instructions in the itemform.php file for the Photo Gallery. But now I want to create a Blogs area with K2 and the same instructions does not apply to blogs. I haven't even gotten to the CSS yet, but the last post sounds like it will work fine with using custom css classes.
My problem is getting K2 to pickup my override folder...other than default. Please help!
Erwin
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- User
Please read this post: www.joomlaworks.net/blog/item/194-k2-inheritance-sub-templating
If you are using a multi category menu, then the option is also located in the menu item's settings.
If you did everything correctly, some frameworks and 3rd party extensions are known to cause this issue.
Please Log in or Create an account to join the conversation.
- Erwin Hunter
-
- Offline
- New Member
- Posts: 2
I thought about your comment about 3rd party extensions and started to uninstall one extension at a time until it started working. But then seen another menu item for K2 called Latest Items. I chose that for my Menu item and narrowed it down to a single category and what do you know!! It pulled in the override!! So, that leads me to believe that it's not a problem of a 3rd party extension. It will pull in overrides if you choose Latest Items, but will not pull in overrides if you just chooses Categories. See Image. (Well, I had an image but don't want to go through the trouble of using imgur.com)
Any ideas why this would be the case?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- User
They describe how to setup your categories.
Please Log in or Create an account to join the conversation.