Users running a non-download version of Vanilla (pulled from github), on branch release/2019.016 or master from the last 2 weeks should upgrade to release/2019.017 or latest master for security reasons. Downloaded official open sources releases are not affected.
Please upgrade here. These earlier versions are no longer being updated and have security issues.

Vanilla variables used in Custom Page

This discussion is related to the Custom Pages addon.
evolucjaevolucja New
edited January 2012 in Vanilla 2.0 - 2.8

Can I use Vanilla variables in Custom Pages? For example I want to make pages avaiable only for some users or something like "Hello, $username" or "You've got a nice avatar: [AVATAR IMG], $username".


  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭

    yes you can use all variables, Classes, Functions from vanilla in custom pages.

  • Well.. so how can I use them? I made a Custom Page with


    and I don't see there any user or other useful data..

  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭

    i created a page demo.php in custom pages plugin and put

    <?php if (!defined('APPLICATION')) exit();
    $this->Head->Title('Demo title for using Custom Page Plugin!');
    $DiscussionModel = new DiscussionModel();
    $DiscussionData = $DiscussionModel->Get(0, 10);
    var_dump($DiscussionData );

    which set the title of page as Set above and printed out the first 10 discussions.

    what kind of data you want to print? - you will have to look for variable in core and echo it out or var_dump();

  • is there any list of all variables I can view and set in Custom Pages? Especially I want to know if user is logged, his username and avatar image.

    Can I make queries in Custom Page? Can I set a default sidebar? Can I set content of own sidebar?
    If yes, can anyone tell me how? :)

  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    $Session = Gdn::Session();
    if ($Session->IsValid()) {
    $userid = $Session->UserID;
    $Name = $Session->User->Name; }

    above can be used to check if session is valid i.e user is logged in. then u can get his username and userid. then using userid u can check for function in UserModel to get the userdetails from ID or USERNAME. i suppose that you are familiar with programming and u can go through the code to find out what details u want - i have given u userid and username.

    i tried $this->AddModule('CategoriesModule'); but it doesnot seem to work on mine. u can try on your install if it works for u

Sign In or Register to comment.