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.

Any to give users their own selection of homepage layout?

124»

Comments

  • hgtonighthgtonight ∞ · New Moderator

    @peregrine said:
    just to clarify for me and others hgtonight

    Is this what you mean

    class ABC implements Gdn_IPlugin {
     needs  Setup and Disable functions
    
    vs.
    
    
    class DEF  extends Gdn_Plugin {
       doesn't  need Setup and Disable functions
    

    I just looked at the source code to make sure I wasn't leading you astray. In Vanilla 2.1, you need to define a Setup() method to implement the Gdn_IPlugin interface. I.e. class ABC implements Gdn_IPlugin. You do not need to declare a Setup() method when extending Gdn_Plugin: i.e. class DEF extends Gdn_Plugin. The setup method is executed when you enable the plugin in the dashboard.

    You may define a OnDisable() method. This will be executed when you disable the plugin via the dashboard.

    Sorry for the confusion, as some things have changed. :|

    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.

  • I just looked at the source code to make sure I wasn't leading you astray. In Vanilla 2.1, you need to define a Setup() method to implement the Gdn_IPlugin interface. I.e. class ABC implements Gdn_IPlugin. You do not need to declare a Setup() method when extending Gdn_Plugin: i.e. class DEF extends Gdn_Plugin. The setup method is executed when you enable the plugin in the dashboard.

    You may define a OnDisable() method. This will be executed when you disable the plugin via the dashboard.

    it all corroborates now!

    class MobileThemeHooks implements Gdn_IPlugin {

    does not have a OnDisable() method.

    but it does have public function Setup() { }

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • hgtonighthgtonight ∞ · New Moderator

    Interfaces and inheritance are two facets of object oriented programming (OOP).

    Knowing a class implements an interface and knowing the interface lets you isolate functionality without knowing what is actually happening. For more information specific to PHP, check out http://www.php.net//manual/en/language.oop5.interfaces.php

    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.

  • some changes to add font size
    
    class CustomHomepagePlugin extends Gdn_Plugin {
    
      public function CategoriesController_Render_Before($Sender) {
        $this->_AddFontCSS($Sender);
      }
    
      public function DiscussionsController_Render_Before($Sender) {
        $this->AddFontCSS($Sender);
      }
    
     public function DiscussionController_Render_Before($Sender) {
        $this->AddFontCSS($Sender);
      }
      public function AddFontCSS($Sender) {
      $Session = Gdn::Session();
      $FontSize = $this->GetUserMeta($Session->UserID, 'FontSize', FALSE, TRUE);
       var_dump($FontSize); 
    
       if (($FontSize == "large")  || ($FontSize == "small")) {
         $cssfile = 'design/chp_' .$FontSize . '.css';
         $Sender->AddCSSFile($this->GetResource('design/chp_' .$FontSize . '.css', FALSE, FALSE));
        }
      }
    
       public function UserModel_AfterGetSession_Handler($Sender) {
            $Request = Gdn::Request();
            if ($Request->Path() == '') {
                $User = $Sender->EventArguments['User'];
    
    // override the default controller route temporarily if it has been set
    
                $Controller = $this->GetUserMeta($User->UserID, 'DefaultController', FALSE, TRUE);
                if ($Controller) {
                    Gdn::Router()->SetRoute('DefaultController', $Controller, 'Internal', FALSE);
                }
            }
        }
    
        public function Gdn_Dispatcher_AfterControllerCreate_Handler($Sender) {
            $User = Gdn::Session()->User;
            $Controller = $Sender->EventArguments['Controller'];
    
    // override the default layout temporarily if applicable
    
            switch ($Controller->ControllerName) {
                case 'discussionscontroller':
                    $DiscussionsLayout = $this->GetUserMeta($User->UserID, 'DiscussionsLayout', C('Vanilla.Discussions.Layout', NULL), TRUE);
                    SaveToConfig('Vanilla.Discussions.Layout', $DiscussionsLayout, array('Save' => FALSE));
                    break;
                case 'categoriescontroller':
                    $CategoriesLayout = $this->GetUserMeta($User->UserID, 'CategoriesLayout', C('Vanilla.Categories.Layout', NULL), TRUE);
                    SaveToConfig('Vanilla.Categories.Layout', $CategoriesLayout, array('Save' => FALSE));
                    break;
            }
        }
    
        public function ProfileController_EditMyAccountAfter_Handler($Sender) {
            $User = $Sender->User;
    
    // Load their current settings
    
            $Controller = $this->GetUserMeta($User->UserID, 'DefaultController', FALSE, TRUE);
            $DiscussionsLayout = $this->GetUserMeta($User->UserID, 'DiscussionsLayout', FALSE, TRUE);
            $CategoriesLayout = $this->GetUserMeta($User->UserID, 'CategoriesLayout', FALSE, TRUE);
            $FontSize = $this->GetUserMeta($User->UserID, 'FontSize', FALSE, TRUE);
    // Save the settings to the form
    
            $Sender->Form->SetValue('DefaultController', $Controller);
            $Sender->Form->SetValue('DiscussionsLayout', $DiscussionsLayout);
            $Sender->Form->SetValue('CategoriesLayout', $CategoriesLayout);
            $Sender->Form->SetValue('FontSize', $FontSize);
            $ControllerOptions = array(
                'discussions' => 'Discussion List',
                'categories' => 'Category List'
            );
            $LayoutOptions = array(
                'modern' => T('Modern non-table-based layout'),
                'table' => T('Classic table layout used by traditional forums')
            );
    
            $FontSizeOptions = array(
                'default' => T('default Font Size'),
                'small' => T('Smaller Font Size'),
                'large' => T('Larger Font Size')
            );
    
    
    
    
            echo '<li class="Homepage">';
            echo $Sender->Form->Label('Homepage View', 'DefaultController');
            echo $Sender->Form->DropDown('DefaultController', $ControllerOptions, array('IncludeNull' => TRUE));
            echo $Sender->Form->Label('Discussions View', 'DiscussionsLayout');
            echo $Sender->Form->DropDown('DiscussionsLayout', $LayoutOptions, array('IncludeNull' => TRUE));
            $LayoutOptions['mixed'] = T('All categories listed with a selection of 5 recent discussions under each');
            echo $Sender->Form->Label('Categories View', 'CategoriesLayout');
            echo $Sender->Form->DropDown('CategoriesLayout', $LayoutOptions, array('IncludeNull' => TRUE));
            echo $Sender->Form->Label('Font Size', 'FontSize');
            echo $Sender->Form->DropDown('FontSize', $FontSizeOptions, array('IncludeNull' => TRUE));
    
            echo '</li>';
        }
    
        public function UserModel_AfterSave_Handler($Sender) {
            $FormValues = $Sender->EventArguments['FormPostValues'];
            $UserID = val('UserID', $FormValues, 0);
    
    // Require valid user ID
    
            if (!is_numeric($UserID) || $UserID <= 0) {
                return;
            }
            $DefaultController = val('DefaultController', $FormValues, FALSE);
            if ($DefaultController) {
                $this->SetUserMeta($UserID, 'DefaultController', $DefaultController);
            }
            $DiscussionsLayout = val('DiscussionsLayout', $FormValues, FALSE);
            if ($DiscussionsLayout) {
                $this->SetUserMeta($UserID, 'DiscussionsLayout', $DiscussionsLayout);
            }
            $CategoriesLayout = val('CategoriesLayout', $FormValues, FALSE);
            if ($CategoriesLayout) {
                $this->SetUserMeta($UserID, 'CategoriesLayout', $CategoriesLayout);
            }
            $FontSize = val('FontSize', $FormValues, FALSE);
            if ($FontSize) {
                $this->SetUserMeta($UserID, 'FontSize', $FontSize);
            }
    
        }
    }
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • and then add (add what other elements you want to change size of

    CustomHomepage/design/chp_large.css

     .Message {
        font-size: 150%;
    }
    
     .Title {
        font-size: 130%!important;
    }
    

    and

    CustomHomepage/design/chp_small.css

     .Message {
        font-size: 80%;
    }
    
     .Title {
        font-size: 80%!important;
    }
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • DoyceTDoyceT Model Questioner ✭✭✭

    Looks like I've got some things to test in the morning. :)

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    I would not bother to change each one, if you use body it will simply enlarge all the elements 80% more than their values.

    the smallest font will only get 80% larger than say 9px making it still small but readable along with the rest of it.

  • peregrineperegrine MVP
    edited June 2014

    this needs to be removed from the above code

    var_dump($FontSize);

    http://vanillaforums.org/discussion/comment/210275/#Comment_210275

    @vrijvlinder said:
    I would not bother to change each one, if you use body it will simply enlarge all the elements 80% more than their values.

    the smallest font will only get 80% larger than say 9px making it still small but readable along with the rest of it.

    I know you know css V, But...

    I'll believe you after you test the actual plugin with bittersweet with your modified and posted :)

    CustomHomepage/design/chp_small.css
    CustomHomepage/design/chp_large.css

    after looking at discussions page, categories page, and a discussion page.

    since

        html,body,div, span, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, ins, kbd, q, samp, small, strike, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td{
        font-size:120%!important;
        }
    

    was 1/2 red-herring :) and you can test by playing the real outcome with web-designer.

    http://vanillaforums.org/discussion/comment/210261/#Comment_210261

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    No not herring, just needed to add a:link so it works for the titles, try with this

    html, body, div, span, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, ins, kbd, q,  samp, small, strike, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, a:link {
    
    font-size: large!important;
    }
    
  • peregrineperegrine MVP
    edited June 2014

    @vrijvlinder

    did you try it? doesn't look good in table view.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited June 2014

    I still also wonder if it would be faster or better to pull in all wildcarded values

    GetMeta($this->User->UserID, Plugin.CustomHomepage.%',

    and this bug I added needs to be changed

    from:

    public function CategoriesController_Render_Before($Sender) {
        $this->_AddFontCSS($Sender);
      }
    
    to
    
    public function CategoriesController_Render_Before($Sender) {
        $this->AddFontCSS($Sender);
      }
    

    and then parse since its now getting four meta values.

    CustomHomepage/design/chp_small.css

             .Message {
                font-size: 80%!important;
            }
    
             a.Title {
                font-size: 80%!important;
            }
    
    
        .Title a {
            font-size: 80%!important;
        }
    

    and CustomHomepage/design/chp_large.css

         .Message {
        font-size: 150%!important;
    }
    
     a.Title {
        font-size: 130%!important;
    }
    
    .Title a {
        font-size: 130%!important;
    }
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    I guess switching font size is not as easy as switching font family....

  • hgtonighthgtonight ∞ · New Moderator

    @peregrine said:
    I still also wonder if it would be faster or better to pull in all wildcarded values

    GetMeta($this->User->UserID, Plugin.CustomHomepage.%',

    I considered doing that originally. The current version only pulls in data when on a useful page (and even then, just one query).

    It might be better to request '%' on the profile edit page. It sucks that SetMeta auto prefixes but GetMeta won't remove the prefix. Brings a dependency on the Plugin name.

    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.

  • @DoyceT

    let me know if it ss ok with you and I'll will try to attach a zip file with my changes here if I have permission to do so or if the browser lets me. (I've had troubles uploading zips in discussussions in recent times, not sure if it is just me or a permission problem or a bug or the browser).

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • DoyceTDoyceT Model Questioner ✭✭✭

    @peregrine
    Sounds good! I haven't been following this last round of revisions as closely, because my users just use ctrl +/- to adjust screen displays, but I can certainly stick it into the addon as an option.

  • peregrineperegrine MVP
    edited June 2014

    apparently I might have succeeded with chrome.

    fingers crossed.

    @‌DoyceT

    this is the zip formatted and with css files (you might want to play with them) and formatted default,php with font size option.

    After you download this DoyceT and you upload new version with fonts or modify it, you can contact a moderator to delete this zip, so users get the new version from add-ons area instead.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • did you ever try the font size deal? or decide it wasn't worth the trouble for you site's needs

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • DoyceTDoyceT Model Questioner ✭✭✭

    I haven't implemented it yet. The learning curve for the users getting to pick their own layouts has kept me... pretty occupied since I turned it on.

    Some days, it's hard to remember I volunteered for this...

Sign In or Register to comment.