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.

Adding a side pannel to a custom page

edited November 2011 in Vanilla 2.0 - 2.8
I am using the custom pages plugin as a base for my own plugin. I want to make my custom page have a sidebar with some useful stuff in it, otherwise it just looks a bit bare.

I've tried the below code, but the sidebar is not formatted properly - it shows everything overlapping with all possible options showing.

This is the code I'm using in default.php (from the Custom Pages plug in)

// See what page was requested $Page = ArrayValue('0', $Sender->RequestArgs, 'default'); $MasterView = ArrayValue('1', $Sender->RequestArgs, 'default'); $MasterView = $MasterView != 'admin' ? 'default' : 'admin'; $Path = PATH_PLUGINS . DS . 'Heresay' . DS . 'pages' . DS; // If the page doesn't exist, roll back to the default if (!file_exists($Path.$Page.'.php')) $Page = 'default'; // Use the default css if not viewing admin master $Sender->ClearCssFiles(); $Sender->AddCssFile('style.css'); $Sender->AddSideMenu(); $Sender->MasterView = $MasterView; $Sender->Render($Path.$Page.'.php');

I've also tried using:
$Sender->AddSideMenu('plugin/page/default');

Best Answer

  • AoleeAolee ✭✭
    edited November 2011 Answer ✓
    can we see how it looks like? url? i think i had the same problem before. what vanilla version are you using by the way?
«1

Answers

  • AoleeAolee ✭✭
    edited November 2011 Answer ✓
    can we see how it looks like? url? i think i had the same problem before. what vanilla version are you using by the way?
  • Thanks for getting back to me. This is Vanilla 2 - it's actually on localhost at the moment, I'll try and get it and post the link here.
  • This is Vanilla 2
    Which version of vanilla 2?
    2.0.17
    2.0.18 RC3
    another version?

    There was an error rendering this rich post.

  • Hi,

    Here it is:
    http://vanilla.heresay.org.uk/forum/plugin/page/test

    Vanilla Version 2.0.17.10

    Apologies for the rather useless answer "version 2"...

    Jimmy
  • AoleeAolee ✭✭
    edited November 2011
    hmm looks like this is a matter of css designing

    try replacing your

    <div> <div class="Box Group SiteSettings"> <h4>Settings</h4> <ul class="PanelInfo"> <li><a href="/forum/plugin/page/default/admin">Custom Pages</a> </li></ul> </div></div>

    with

    <div class="Box BoxCategories"> <h4><a href="/forum/categories/all">Categories</a></h4> <ul class="PanelInfo PanelCategories"> <li class="Active"><span><strong><a href="/forum/discussions">All Discussions</a></strong><span class="Count">0</span></span></li> <li class="Depth"><strong><a href="/forum/categories/general">General</a></strong><span class="Count">0</span></li> </ul> </div>


    to compare and see the diff

  • I'm sorry, I don't think I understand how to do this. Where would I make those changes? I haven't done anything to vanilla except add my custom page, so presumably I won't have upset the CSS?

  • x00x00 MVP
    edited November 2011
    You would have to actually have a AddSideMenu method for that controller and at the moment it is inheriting that from I suspect dashboard.

    I would have a look at applications/dashboard/modules/class.sidemenumodule.php

    For how to actually construct a side menu.
    $SideMenu = new SideMenuModule($Sender);

    ...

    $Sender->AddModule($SideMenu, 'Panel');

    grep is your friend.

  • In the same context, you page title for the custom page says "Heresay", which is the default title. Any idea how to override to give a page specific title for SEO reasons?
  • x00x00 MVP
    edited November 2011
    have you tried $Sender->Title('Some Title'); ?

    Actually what is between <h1> is dependent on your theme. The default uses Gdn_Theme::Logo(), which uses the site wide title.

    You could also load a different master template

    grep is your friend.

  • Thanks for all your help on this. As you can guess, I really don't particularly understand the way this is written. I'm guessing that the ... in x00's code represent me building the side content. However, I'd just like that side content to be the same is the configuration in the rest of the site. Is there no way to inherit this?

    Otherwise, I've looked at
    applications/dashboard/modules/class.sidemenumodule.php

    and I don't really understand it. If anyone could post a few lines that put the categories and and the add discussion button in the side menu that would be amazing.

    Having searched the rest of the code, I can't see any other instructive uses of the

    $this->AddModule($SideMenu, 'Panel');

    method.


  • x00x00 MVP
    edited November 2011
          $this->AddModule('GuestModule');
    $this->AddModule('SignedInModule');

    $this->AddModule('NewDiscussionModule');
    $this->AddModule('CategoriesModule');
    $this->AddModule('BookmarkedModule');
    If you are in garden but not vanilla, you might have to reference the vanilla app. As far as it is concerned it is another application.

    Why don't you say what it is you are tying to achieve with this page?

    grep is your friend.

  • mclovinmclovin New
    edited November 2011
    @x00
    $Sender->Title('Some Title'); works from the CustomPages plugin, but then every custom page would have the same title which is not what i want.

    I want set a different title for each page created.
    Custom Page Plugin:

    public function PluginController_Page_Create(&$Sender) { // See what page was requested $Page = ArrayValue('0', $Sender->RequestArgs, 'default'); .............. $Path = PATH_PLUGINS . DS . 'CustomPages' . DS . 'pages' . DS; ............ $Sender->Title('Generic title for all custom pages'); $Sender->MasterView = $MasterView; $Sender->Render($Path.$Page.'.php'); }
  • I'm not giving programming lessons, you need to apply some logic to your code to sort that out.

    grep is your friend.

  • Hi - apparently the AddModule method isn't available on my class.

    You can see what I'm trying to do here: http://vanilla.heresay.org.uk/forum/plugin/page/heresay

    I just want the damn page to appear in a normal template!

  • have some patience @jimmytidey
    here is what i changed to add some modules to custompages sidebar
    public function PluginController_Page_Create(&$Sender) { $Sender->Head->Title('The Page You requested could not be found on this server'); $Sender->AddModule('SignedInModule'); $Sender->AddModule('GuestModule'); // See what page was requested $Page = ArrayValue('0', $Sender->RequestArgs, 'default'); $MasterView = ArrayValue('1', $Sender->RequestArgs, 'default'); $MasterView = $MasterView != 'admin' ? 'default' : 'admin'; $Path = PATH_PLUGINS . DS . 'CustomPages' . DS . 'pages' . DS; // If the page doesn't exist, roll back to the default if (!file_exists($Path.$Page.'.php')) $Page = 'default'; // Use the default css if not viewing admin master if ($MasterView != 'admin') { $Sender->ClearCssFiles(); $Sender->AddCssFile('style.css'); } else { $Sender->AddSideMenu('plugin/page/default/admin'); } $Sender->MasterView = $MasterView; $Sender->Render($Path.$Page.'.php'); }
    note the AddModule function used

    There was an error rendering this rich post.

  • can you post which modules you are trying to add? so i can try them on my vanilla installation and see what i can do?

    There was an error rendering this rich post.

  • Thanks all for getting back to me - I didn't mean to be impatient! The code above causes a "bonk" error message, but hacking it into my own code still causes the display problem - here is what I used:
    public function PluginController_Page_Create(&$Sender) { $Sender->Head->Title('The Page You requested could not be found on this server'); $Sender->AddModule('SignedInModule'); $Sender->AddModule('GuestModule'); // See what page was requested $Page = ArrayValue('0', $Sender->RequestArgs, 'default'); $MasterView = ArrayValue('1', $Sender->RequestArgs, 'default'); $MasterView = $MasterView != 'admin' ? 'default' : 'admin'; $Path = PATH_PLUGINS . DS . 'Heresay' . DS . 'pages' . DS; // If the page doesn't exist, roll back to the default if (!file_exists($Path.$Page.'.php')) $Page = 'default'; // Use the default css if not viewing admin master if ($MasterView != 'admin') { $Sender->ClearCssFiles(); $Sender->AddCssFile('style.css'); } else { $Sender->AddSideMenu('plugin/page/default/admin'); } $Sender->AddSideMenu(); $Sender->MasterView = $MasterView; $Sender->Render($Path.$Page.'.php'); }

    Ideally this will show the same content as the rest of the site shows on the right hand column, otherwise - perhaps just the same right hand column on this page:
    http://vanilla.heresay.org.uk/forum/discussions
  • try removing the line $Sender->AddSideMenu();

    grep is your friend.

  • That seems to prevent it from rendering anything when I'm logged in. When I'm logged out it gives me the login box, which works for me...
  • ie. that's an appropriate thing to display when it's not logged in.
Sign In or Register to comment.