Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Users disabling certain extensions for themselves?

I was wondering if it was possible to allow users the ability to turn on and off certain extensions on their own, or if each extensions needed to be coded to create a user preference. For example, some of my members really enjoy the yellow fade and the quick tags, but others dont like them at all, and I'd like to give people an option. At the moment I only see how I can enable and disable them globally. Is there something I'm missing?

Comments

  • Options
    edited July 2006
    It's all up to the extension programmer. Some extensions should work globally, some can be switched on or off in the Forum Prefereces.

    But it's really easy to change an extension and have it switched on/off by a user! Let's take a look at the YellowFade add-on:
    <?php /* Extension Name: YellowFade Effect Extension Url: http://michaelraichelson.com/hacks/vanilla/ Description: Adds the YellowFade effect on some stuff. Version: 0.1 Author: Michael Raichelson Author Url: http://michaelraichelson.com/ */ if (in_array($Context->SelfUrl, array("index.php", "categories.php", ... bla bla.. { $Head->AddScript('extensions/YellowFade/functions.js'); } ?>

    Now let's make a user preference, so we add the following:
    if ($Context->SelfUrl == 'account.php') { $Context->AddToDelegate('PreferencesForm', 'PreRender', 'YellowFade_PreferencesForm'); function YellowFade_PreferencesForm(&$PreferencesForm) { $PreferencesForm->AddPreference('Other', 'EnableYellowFade', 'showYellowFade'); } }

    The second parameter for adding a preference is our language definition, so we should add it to our dictionary:
    $Context->Dictionary['EnableYellowFade'] = 'Show YellowFade';

    And now we need to check for the preference if we need to add the javascript to the head object:
    if( $Context->Session->User->Preference('showYellowFade')) { $Head->AddScript('extensions/YellowFade/functions.js'); }

    We're done!
  • Options
    @Jazzy (May I call you that?) ; )

    If you got a min, I got this working and the pref is there, but toggling the button makes no difference. YellowFade is on regardless. Hmmm?
  • Options
    edited July 2006
    Yeah, you can call me Jazzy :D

    Here's the full code (maybe you made a typo? It works for me):
    <?php /* Extension Name: YellowFade Effect Extension Url: http://michaelraichelson.com/hacks/vanilla/ Description: Adds the YellowFade effect on some stuff. Version: 0.1 Author: Michael Raichelson Author Url: http://michaelraichelson.com/ */ $Context->Dictionary['EnableYellowFade'] = 'Show YellowFade'; if (in_array($Context->SelfUrl, array("index.php", "categories.php", "comments.php", "search.php", "post.php", "account.php", "settings.php"))) { if( $Context->Session->User->Preference('showYellowFade')) { $Head->AddScript('extensions/YellowFade/functions.js'); } } // Add preference if ($Context->SelfUrl == 'account.php') { $Context->AddToDelegate('PreferencesForm', 'PreRender', 'YellowFade_PreferencesForm'); function YellowFade_PreferencesForm(&$PreferencesForm) { $PreferencesForm->AddPreference('Other', 'EnableYellowFade', 'showYellowFade'); } } ?>
  • Options
    wow. thank you so much. Im off to go figure out how to do this to quicktags now. :)
  • Options
    @Jazzy: Thanks. I see where I went wrong. School-boy error.
  • Options
    @onetwentyeight - did you figure this out for quicktags? if so let me know so I can update the package :)
  • Options
    TreyTrey Charlotte NC New
    edited July 2006
    that yellow fade extension would be awesomeee to have but I cant find it and the code above isnt working correctly for me.. is there someway I could get that whole extension in a zip file that works with v1?

    sorry for interupting here

    edit//
    I got it working now! :) I didnt know I had to activate it within the forum preferences tab. Thanks for posting that here!
  • Options
    3stripe - i got sidetracked and bogged down with my job. ill have it done in the next day or two. i will deffinately post it here when its done.
  • Options
    I might do it tonight actually dude. Will let you know :)
  • Options
    Not to bump a thread, but I used the code that jazzman posted, and although there's an option to turn yellowfades off, it doesn't do anything if someone wants to do that.
  • Options
    Hmm I'm having problems with this also... maybe http://lussumo.com/docs/doku.php?id=vanilla:development:userpreferences&s=user+preferences has some answers...
  • Options
    Jazzman, can you use your binary powers to fix this... somethings is very wrong cos it does nothing:

    <?php /* Extension Name: Quicktags Extension Url: http://lussumo.com/addons/ Description: Inserts an HTML formatting bar above the input field, using Alex King's Quicktags. Requires SirNot's Html Formatter extension. See http://www.tamba2.org.uk/wordpress/quicktags/ for guidance on adding custom Quicktags. Version: 0.6 Author: James Greig Author Url: http://www.3stripe.net */ $Configuration["QUICKTAGS_PATH"] = 'extensions/Quicktags/'; $Context->Dictionary['UseQuicktags'] = 'Show the Quicktags formatting bar above the post area'; $Context->Dictionary['MenuOptions'] = 'Nanananananannananana'; if(!in_array($Context->SelfUrl, array("post.php", "comments.php"))) return; if (in_array($Context->SelfUrl, array("post.php", "comments.php"))) { class QuicktagsBar { function QuicktagsBar_Create() { echo ' <div id="quicktags"> <script type="text/javascript">edToolbar();</script> </div> '; } function QuicktagsBarApres_Create() { echo ' <script type="text/javascript">var edCanvas = document.getElementById(\'CommentBox\');</script> '; } } } function AddQuicktagstoCommentForm(&$DiscussionForm) { $QuicktagsBar = new QuicktagsBar($DiscussionForm->Context); $QuicktagsBar-> QuicktagsBar_Create(); } function AddQuicktagsJavascriptafterCommentForm(&$DiscussionForm) { $QuicktagsBar = new QuicktagsBar($DiscussionForm->Context); $QuicktagsBar-> QuicktagsBarApres_Create(); } if( $Context->Session->UserID > 0) { if ($Context->Session->User->Preference('UseQuicktags')) { $Head->AddScript($Context->Configuration["BASE_URL"].$Context->Configuration["QUICKTAGS_PATH"].'quicktags.js'); $GLOBALS['Head']->AddStyleSheet($Context->Configuration["QUICKTAGS_PATH"].'quicktags.css'); $Context->AddToDelegate("DiscussionForm", "CommentForm_PreCommentsInputRender", 'AddQuicktagstoCommentForm'); $Context->AddToDelegate("DiscussionForm", "DiscussionForm_PreCommentRender",'AddQuicktagstoCommentForm'); $Context->AddToDelegate("DiscussionForm", "CommentForm_PreButtonsRender", 'AddQuicktagsJavascriptafterCommentForm'); $Context->AddToDelegate("DiscussionForm", "DiscussionForm_PreButtonsRender",'AddQuicktagsJavascriptafterCommentForm'); } } // Add the Quicktags setting to the forum preferences form if ($Context->SelfUrl == 'account.php' && $Context->Session->UserID > 0) { $PostBackAction = ForceIncomingString('PostBackAction', ''); if ($PostBackAction == 'Functionality') { function PreferencesForm_AddQuicktagsPreference(&$PreferencesForm) { $PreferencesForm->AddPreference('MenuOptions', 'UseQuicktags', 'UseQuicktags', 1); } $Context->AddToDelegate('PreferencesForm', 'Constructor', 'PreferencesForm_AddQuicktagsPreference'); } } ?>
  • Options
    still can't puzzle this out...
This discussion has been closed.