Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
experimenting new plugin
jackmaessen
✭✭✭
I am experimenting with a new plugin in which i want to change the background-color for 2 classes: .Unread and .New
In the css file (changebackgroundcolor.css) i put this:
/* lightblue en lichtgreen bg-color for new topic and new comment in existing topic */ li.Item.Unread { background: rgba(27, 117, 186, 0.2) !important; } li.Item.New { background: rgba(189, 209, 41, 0.2) !important; }
These classes have default a white background.
So what i want to achieve: if the user is logged in, these lines above should overwrite the default ones.
I started with an example plugin but do not succeed in it yet:
<?php if (!defined('APPLICATION')) exit(); // Define the plugin: $PluginInfo['ChangeBackgroundColor'] = array( 'Name' => 'ChangeBackgroundColor', 'Description' => "Changes backgroundcolor of discussions for new discussion and new comment", 'Version' => '1.0', 'Requires' => FALSE, 'HasLocale' => FALSE, 'License'=>"GNU GPL2", 'Author' => "jackmaessen" ); class ChangeBackgroundColorPlugin extends Gdn_Plugin { public function Base_Render_Before($Sender) { $Session = Gdn::Session(); if ($Session->IsValid()) { // if user is logged in, load css file below to overwrite the 2 classes $sender->AddCssFile($this->GetResource('design/changebackgroundcolor.css', FALSE, FALSE)); } } public function Setup() { // nothing to setup } }
Need some help with it...
1
Comments
Try
Or better use AssetModel_StyleCss_Handler instead of Base_Render_Before.
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
But this is probably the problem:
while function names are not, variable names are case sensitive in PHP
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
Works Great!
The main problem was: i already had given the 2 classes these different background-colors when i noticed when logged out, every topic gets the .Unread class, so everything had the lightblue color; which ofcourse was not the intention. So i thought: try to overwrite them if user is logged in and keep the default classes with white background color.
Great work @Bleistivt
I added some lines of code to this plugin for people to make it easy to change the background-colors by form input instead of changing the css file. I made this piece of code and it changes the content of changebackgroundcolor.css.
My question: how can i put this in a file (settings.php i think??) to make this work in the plugin?
and add this to your plugininfo array:
You can do it like that, but it is not recommended.
You are basically doing everything in the view this way and not making use of the framework.
Better rebuild your form using Gdn_Form and do all your processing in the hook.
And use the higher level file function like file_get_contents and file_put_contents or even Gdn_FileSystem.
You should also save the files you write in the cache or uploads directory and not in the plugin folder itself to still be able to enforce proper permissions.
This post contains a lot of useful information:
http://vanillaforums.org/discussion/comment/210058/#Comment_210058
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS