The master templates that come with the Vanilla install respect the $CssClass member for all controllers (since it is actually a member of Gdn_Controller). So you can modify the CSS class of any controller using the snippet I shared.
You just have to hook into the controller you want to modify.
the controller being the body class ... I think we all explained the same thing... it is not easy to get general help because it varies depending on purpose.
If the purpose is to add class to anything, we explained that ,jquery, hooks via plugin or theme hooks using the controller aka body/page there are many plugins that do this..
I'm not really interested in workarounds that would only lead me to ask another question in a week and make me end up with tons of additional lines and tiny adjustments for things that could have all been done in one way.
For that you need to be more specific. General IS a workaround when one does not have all the data. So in general what we all have said would do what you need.
But I see you need to disassociate body as a static idea. And you can simply use css if you get in the habit of inspecting the code using a web inspector. Or any kind of tool which will show you the html and css relation on that page.
for example in the role badges plugin you have this which adds css file
public function Base_Render_Before( $Sender ) {
$Sender->AddCssFile( $this->GetResource( 'design/RoleBadges.css', FALSE, FALSE ) );
}
but you can also make it so it only does so on specific pages only
public function DiscussionsController_Render_Before( $Sender ) {
$Sender->AddCssFile( $this->GetResource( 'design/RoleBadges.css', FALSE, FALSE ) );
}
Your can also add an array or list of pages you want it to show on but not others
In the functions above you can add either a js file or another css file.or arguments for either or.
Within the controllers here are handlers which get instructions on what to render where on the page based on arguments whether the user is logged in or not and what to display .
The code of this is within the views of each page in php. In the theme hooks as well.
Hooking into a controller means adding a function like the ones above and the sample hg gave, to do whatever it is you want. Usually it is to add a css file or js file where the stuff to be added resides and the css how it looks.
From my experience with vanilla style, there is nothing that can't be styled by css alone. And I mean nothing. So whatever you are doing, you are making it hard for yourself by going some complicated route. I suggest you look at some css tutorials which will help you simplify . Not to say that some things need some extra cleverness but there really is nothing that css can't do with some ingenuity.
Comments
The master templates that come with the Vanilla install respect the
$CssClass
member for all controllers (since it is actually a member ofGdn_Controller
). So you can modify the CSS class of any controller using the snippet I shared.You just have to hook into the controller you want to modify.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
the controller being the body class ... I think we all explained the same thing... it is not easy to get general help because it varies depending on purpose.
If the purpose is to add class to anything, we explained that ,jquery, hooks via plugin or theme hooks using the controller aka body/page there are many plugins that do this..
For that you need to be more specific. General IS a workaround when one does not have all the data. So in general what we all have said would do what you need.
But I see you need to disassociate body as a static idea. And you can simply use css if you get in the habit of inspecting the code using a web inspector. Or any kind of tool which will show you the html and css relation on that page.
for example in the role badges plugin you have this which adds css file
but you can also make it so it only does so on specific pages only
Your can also add an array or list of pages you want it to show on but not others
In the functions above you can add either a js file or another css file.or arguments for either or.
Within the controllers here are handlers which get instructions on what to render where on the page based on arguments whether the user is logged in or not and what to display .
The code of this is within the views of each page in php. In the theme hooks as well.
Hooking into a controller means adding a function like the ones above and the sample hg gave, to do whatever it is you want. Usually it is to add a css file or js file where the stuff to be added resides and the css how it looks.
From my experience with vanilla style, there is nothing that can't be styled by css alone. And I mean nothing. So whatever you are doing, you are making it hard for yourself by going some complicated route. I suggest you look at some css tutorials which will help you simplify . Not to say that some things need some extra cleverness but there really is nothing that css can't do with some ingenuity.
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌