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
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)
I've also tried using:
$Sender->AddSideMenu('plugin/page/default');
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');
Tagged:
0
Best Answer
-
Aolee ✭✭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
2.0.17
2.0.18 RC3
another version?
There was an error rendering this rich post.
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
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 would have a look at applications/dashboard/modules/class.sidemenumodule.php
For how to actually construct a side menu.
grep is your friend.
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.
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.
Why don't you say what it is you are tying to achieve with this page?
grep is your friend.
$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'); }
grep is your friend.
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!
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.
There was an error rendering this rich post.
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
$Sender->AddSideMenu();
grep is your friend.