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

question about views

edited March 2010 in Vanilla 2.0 - 2.8
Hello! First of all I must say that I am so happy to have found this forum package. Finally the php forum written in well designed oop style, even using some cutting edge patterns and comments blocks are the best I've seen in any php forum code.

By the way, I am talking about version 2, from github, I have not looked at version 1.

Ok, I have good experience with oop style in php, but still this package is new to me, so this is what I don't understand yet.
How are the pages rendered? I saw a folder for Smarty class somewhere in the code but then in the view modules I don't see any references that Smarty is even being used anywhere.

Do you use your own templating system then? How are these views php files loaded so that you are able to have $this variable in the views files, and there are no classes. This means that somehow the entire content of the view file is somehow added into the class, some type of code injection or classes generated dymanically?

Please explaing this because as much as I love this code and I think I am going to use it to setup my own forum, I hate when there are some parts of the code I don't understand.

Comments

  • Options
    edited March 2010
    You will want to look at:
    http://github.com/lussumo/Garden/blob/master/library/core/class.controller.php

    The controller contains the Render functions and FetchView.

    Smarty was used in earlier versions of vanilla 2, it hasn't been used since i believe. However smarty remains there. I don't know if there are any plans to use smarty again, but i sure hope not.
  • Options
    Thanks. Maybe some code has changed but I can't find the Render() in class.controller.php
    Can you point me to the class/method where the view file in parsed?
  • Options
    edited March 2010
    Sorry its called xRender() should have been more clear.

    And if you want to know why it begins with an x look here:
    http://vanillaforums.org/page/Plugins for the section marked 2a. Declared Magic Events
  • Options
    Very interesting plugin system.

    This is what I don't understand, on that page you say:
    $PluginInfo['SuperFancifier'] = array(
    'Description' => 'Adds some niceties onto MyFancyClass.',
    'Version' => '1.0',
    'RequiredPlugins' => FALSE, // This is an array of plugin names/versions that this plugin requires
    'HasLocale' => FALSE, // Does this plugin have any locale definitions?
    'RegisterPermissions' => FALSE, // Permissions that should be added for this plugin.
    'SettingsUrl' => FALSE, // Url of the plugin's settings page.
    'SettingsPermission' => FALSE, // The permission required to view the SettingsUrl.
    'Author' => "Mark O'Sullivan",
    'AuthorEmail' => 'mark@lussumo.com',
    'AuthorUrl' => 'http://markosullivan.ca'
    );


    But where is the $Plugininfo array? I mean in which file?
  • Options
    http://github.com/lussumo/Garden/blob/master/plugins/Gravatar/default.php

    Thats the example from the gravatar plugin. In the plugins folder there are several examples of plugins.
  • Options
    oliverraduneroliverraduner Contributing to Vanilla since 2010 Switzerland ✭✭
    As asked by @snytkine, I would also be interested to know how to access the information from the $PluginInfo array inside my Plugin.
  • Options
    TimTim Operations Vanilla Staff
    That's the reason I made Gdn_Plugin work the way it did... there is no real easy way to do that yet :p I'll be adding it though. Coming very soon to a Vanilla 2 near you.

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • Options
    TimTim Operations Vanilla Staff
    You can now easily access the info for plugins, from within your plugin, by doing:

    $Var = $this->GetPluginKey(NAME_OF_ARRAY_ITEM, $Default = NULL);

    So for example if you wanted to access the "Author" value for your plugin (but return NULL if 'Author' is not found):

    $MyAuthor = $this->GetPluginKey('Author', NULL);

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • Options
    TimTim Operations Vanilla Staff
    Several other methods also exist:

    GetPluginName()
    Returns the value of the 'Name' entry in the PluginInfo array

    GetPluginIndex
    Returns the key used in your PluginInfo array entry. In @snytkine's example:
    $PluginInfo['SuperFancifier'] = array(...)
    $this->GetPluginIndex() would return 'SuperFancifier'.

    GetPluginFolder($Absolute = TRUE)
    Gets the full (or relative, if you pass in FALSE) path to the plugin's main file.

    Vanilla Forums COO [GitHub, Twitter, About.me]

Sign In or Register to comment.