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.

Vanilla fatal error Call to undefined function AdminCheck()

steamsteam www.planamigo.org - #1 foro planes amigo

Hello,
I think its an interesting plugin but the latest version of vanilla falls with:
Fatal error: Call to undefined function AdminCheck() in /planamigo.org/applications/vanilla/views/discussions/index.php on line 6

Can someone help me activate it?

Comments

  • hgtonighthgtonight ∞ · New Moderator

    This is an interesting plugin, but I wouldn't suggest using it. It depends on a view override that has changed significantly since this plugin was last updated.

    I would suggest modifying the plugin to use a simple hook rather than a view override to add a category specific class. Something like:

    public function discussionsController_beforeDiscussionName_handler($sender) {
      $sender->EventArguments['CssClass'] .= ' Category_' . $sender->EventArguments['Discussion']->CategoryID;
    }
    

    That should remove the requirement of the view override.

    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.

  • R_JR_J Ex-Fanboy Munich Admin

    Go to the dashboard and edit a category of yours: add a value in the field "Css Class". Then look at the html source of a discussion: the body element will look similar to this

    <body id="vanilla_discussion_index" class="Vanilla Discussion Index Section-Discussion Section-CssClassValue">

    That means that you do not have to use a plugin to style discussions. Now you can use the great plugin CSSEdit to add this code to your css:

    body.SectionCssClassValue div.ItemDiscussion {
      background-color: red;
    }
    
  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited May 2015

    Thanks for reply.

    Does you mean override default.php with your code ?

    class kCategoryColorsPluin extends Gdn_Plugin {

    public function discussionsController_beforeDiscussionName_handler($sender) {
    $sender->EventArguments['CssClass'] .= ' Category_' . $sender->EventArguments['Discussion']->CategoryID;
    }

    }

    I'm a new on this framework, if you can explain in more detail will appreciated.

    I have also seen that the class kCategoryColors uses a database connection. This class need?

    I think this should be more simple ...

    Thanks.

  • steamsteam www.planamigo.org - #1 foro planes amigo

    Thanks for reply.

    R_J - Your solution seems to be perfect!
    Does you mean like this ?

    http://www.planamigo.org/discussions

    Do you know how can I put color to all li discussion area ?

    Thanks in advance.

  • R_JR_J Ex-Fanboy Munich Admin

    Oops! Seems like I have misread what that plugin does! I thought you were trying to change the in a discussion like that: www.planamigo.org/discussion/2 but you try to color the list entries of the recent discussion page.

    So the approach of @hgtonight is the way to go.

  • steamsteam www.planamigo.org - #1 foro planes amigo

    I have seen that I have category style on the database table - category.

    Now using "hgtonight" function I could concatenate category style but I don't know how can I get
    this value from $sender or something else...

  • hgtonighthgtonight ∞ · New Moderator

    I intended my modification to replace the view override you are asked to overwrite core files with.

    Everything else should "just work".

    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.

  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited May 2015

    It's not good idea to override core ... I'll think of some solution with styles by using your function.

  • R_JR_J Ex-Fanboy Munich Admin
    edited May 2015

    Hope I made no error in there...

    <?php defined('APPLICATION') or die;
    
    $PluginInfo['DiscussionsCategoryClass'] = array(
        'Name' => 'Discussions Category CSS Class',
        'Description' => 'Adds categories css class to discussions in discussion lists.',
        'RequiredApplications' => array('Vanilla' => '>= 2.1.10'),
        'Version' => '0.1',
        'Author' => 'R_J',
        'License' => 'MIT'
        'MobileFriendly' => true,
        'HasLocale' => false,
        'Author' => 'R_J',
        'AuthorUrl' => 'http://vanillaforums.org/profile/44046/R_J',
        'License' => 'MIT'
    );
    
    class DiscussionsCategoryClassPlugin extends Gdn_Plugin {
        public function base_beforeDiscussionName_handler($sender) {
            $categoryModel = new CategoryModel();
            $category = $categoryModel->getID($sender->EventArguments['Discussion']->CategoryID);
            $cssClass = $category->CssClass;
            if ($cssClass != '') {
              $sender->addCssFile('discussionscategoryclass.css', 'plugins/DiscussionsCategoryClass');
              $sender->EventArguments['CssClass'] .= " Category-$cssClass";
            }
        }
    }
    
    

    Save that as /plugins/DiscussionsCategoryClass/class.discussionscategoryclass.plugin.php and you can create a css file /plugins/DiscussionsCategoryClass/design/discussionscategoryclass.css where you can save the custom css for your categories. You will be able to access them as - in your example - ".Category-catSelfBank {background-color: yellow}"

  • R_JR_J Ex-Fanboy Munich Admin

    I'll upload that one later - and when I tested it a little bit - to the addon section and to GitHub...

  • R_JR_J Ex-Fanboy Munich Admin

    The plugin info is longer than the real code :mrgreen: - a reason why I love Vanilla!

  • steamsteam www.planamigo.org - #1 foro planes amigo

    I will try your new plugin =) . Thanks.

    Do you now how can I override urls ? /categories/categoria-test2 to /categorias/categoria-test2

    inglish - categories spanish - categorias

    The same problem en articles and activity
    /article/2015/my-first-article

    I need to change .htaccess o can localized properties or something else ?

    Thanks.

  • steamsteam www.planamigo.org - #1 foro planes amigo

    I have corrected a bit your code to work.

  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited May 2015

    <?php if (!defined('APPLICATION')) exit(); $PluginInfo['DiscussionsCategoryClass'] = array( 'Name' => 'Discussions Category CSS Class', 'Description' => 'Adds categories css class to discussions in discussion lists.', 'RequiredApplications' => array('Vanilla' => '>= 2.1.10'), 'Version' => '0.1', 'Author' => 'R_J', 'MobileFriendly' => true, 'HasLocale' => false, 'AuthorUrl' => 'http://vanillaforums.org/profile/44046/R_J', 'License' => 'MIT' ); class DiscussionsCategoryClass extends Gdn_Plugin { public function base_beforeDiscussionName_handler($sender) { $categoryModel = new CategoryModel(); $category = $categoryModel->getID($sender->EventArguments['Discussion']->CategoryID); $cssClass = $category->CssClass; if ($cssClass != '') { $sender->addCssFile('discussionscategoryclass.css', 'plugins/DiscussionsCategoryClass'); $sender->EventArguments['CssClass'] .= " Category-$cssClass"; } } }

  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited May 2015

    But for some reason does not pick up style ... I've seen that style is imported and created

  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited May 2015

    It's working now...!!! Thanks... ;)

  • phreakphreak Vanilla*APP (White Label) & Vanilla*Skins Shop MVP

    Thanx for the plugin @R_J .

    • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
    • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla
Sign In or Register to comment.