Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter
Support for Vanilla Forums Cloud product

In this Discussion

Follow Us


Vanilla variables used in Custom Page

edited January 2012 in Questions
This discussion is related to the Custom Pages addon.

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".

Best Answers

  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    Answer ✓

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

    Theme Charcha for great desktop and mobile experience! - drop me a message :)

    evolucja
  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    Answer ✓
    $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

    Theme Charcha for great desktop and mobile experience! - drop me a message :)

Answers

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

    var_dump(get_defined_vars());

    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();

    Theme Charcha for great desktop and mobile experience! - drop me a message :)

  • 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? :)

Sign In or Register to comment.