Vanilla open source was terminated 1 January 2025 by Higher Logic. See this announcement for more information.

Whats wrong with this code?

public function Base_Render_Before($Sender) { $Sender->AddCssFile($this->GetResource('design/custom.css', FALSE, FALSE)); }

Need help, http://dragonx.net/community

http://gyazo.com/fae0c5c11675c9d0378ed2ac180fd644

«1

Comments

  • I'm afraid that, without the context, it's hard to figure out what's wrong.

  • A wild stab in the dark is that the function declaration isn't in the scope of a class. Have you modified the WhosOnline plugin at all?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • best not work on a live site.

    grep is your friend.

  • peregrineperegrine MVP
    edited March 2013

    @Srggamer

    parse error - indicates problems with {};, etc.

    I suspect it is the lines above it causing the problem -

    I bet:

    T_PUBLIC happens

    you missed closing bracket "}" on a previous function or put too many {} in. Usually a bracket mismatch

    T_STRING errors

    happens when you mess up your quotes " ' . or mismatch them

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • SrggamerSrggamer ✭✭✭
    edited March 2013

    What I am trying to do, is make a modification of the Whosonline plugin to make it instead of names, Profile pictures, What I am trying now to implement is the Custom CSS, that Includes the showing of the images the layout and so on. Because I do not wish to add the Custom CSS, into my theme.

    http://pastebin.com/QaruHHyh

    This Is how the code looks like.

  • SrggamerSrggamer ✭✭✭

    @hgtonight said:
    A wild stab in the dark is that the function declaration isn't in the scope of a class. Have you modified the WhosOnline plugin at all?

    Thats what I am currently trying to do.

  • SrggamerSrggamer ✭✭✭

    @x00 said:
    best not work on a live site.

    Yes I agree, but working on a live site allows me to be able to see it with other plugins in operation. Though installing a LocalHost Vanilla Forum may be the way to go with Plugin development, or modification which I am currently trying to learn.

  • hgtonighthgtonight MVP
    edited March 2013

    @Srggamer

      include_once(PATH_PLUGINS.DS.'WhosOnline'.DS.'class.whosonlinemodule.php');
      $WhosOnlineModule = new WhosOnlineModule($Sender);
      $WhosOnlineModule->GetData(ArrayValue('Plugin.WhosOnline.Invisible', $UserMetaData));
      echo $WhosOnlineModule->ToString();
    ]
    public function Base_Render_Before($Sender) {
      $Sender->AddCssFile($this->GetResource('design/custom.css', FALSE, FALSE));
    }
    

    That square bracket, ], on the line 5 is causing the parsing error. Looks like it should be a closing curly brace instead }.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • around line 29

    // why the ]

    ] public function Base_Render_Before($Sender) {

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • For large code pastes like this, I would suggest a service like pastebin.com and just linking it

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • SrggamerSrggamer ✭✭✭

    @hgtonight said:
    For large code pastes like this, I would suggest a service like pastebin.com and just linking it

    http://pastebin.com/QaruHHyh

    Uploaded to this, thanks for tip.

  • SrggamerSrggamer ✭✭✭

    @hgtonight said:
    Srggamer

      include_once(PATH_PLUGINS.DS.'WhosOnline'.DS.'class.whosonlinemodule.php');
      $WhosOnlineModule = new WhosOnlineModule($Sender);
      $WhosOnlineModule->GetData(ArrayValue('Plugin.WhosOnline.Invisible', $UserMetaData));
      echo $WhosOnlineModule->ToString();
    ]
    public function Base_Render_Before($Sender) {
      $Sender->AddCssFile($this->GetResource('design/custom.css', FALSE, FALSE));
    }
    

    That square bracket, ], on the line 5 is causing the parsing error. Looks like it should be a closing curly brace instead }.

    Removed it still causing error. On anew line of course.

    http://gyazo.com/1b483dfd90dbab0bfdfa12a7c0333a06

  • peregrineperegrine MVP
    edited March 2013
        // Define the plugin: $PluginInfo['WhosOnline'] = array( 'Name' => 'WhosOnline', 'Description' => "Lists the users currently browsing the forum.", 'Version' => '1.3', 'Author' => "Gary Mardell", 'AuthorEmail' => 'gary@vanillaplugins.com', 'AuthorUrl' => 'http://vanillaplugins.com', 'RegisterPermissions' => array('Plugins.WhosOnline.ViewHidden', 'Plugins.WhosOnline.Manage'), 'SettingsPermission' => array('Plugins.WhosOnline.Manage') );
    
        /** * TODO: * Admin option to allow users it hide the module * User Meta table to store if they are hidden or not */
    
        class WhosOnlinePlugin extends Gdn_Plugin {
    
        public function PluginController_WhosOnline_Create(&$Sender) { $Sender->Permission('Plugins.WhosOnline.Manage'); $Sender->AddSideMenu('plugin/whosonline'); $Sender->Form = new Gdn_Form(); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('WhosOnline.Location.Show', 'WhosOnline.Frequency', 'WhosOnline.Hide')); $Sender->Form->SetModel($ConfigurationModel);
    
            if ($Sender->Form->AuthenticatedPostBack() === FALSE) {
            $Sender->Form->SetData($ConfigurationModel->Data);
            } else {
            $Data = $Sender->Form->FormValues();
            $ConfigurationModel->Validation->ApplyRule('WhosOnline.Frequency', array('Required', 'Integer'));
            $ConfigurationModel->Validation->ApplyRule('WhosOnline.Location.Show', 'Required');
            if ($Sender->Form->Save() !== FALSE)
            $Sender->StatusMessage = T("Your settings have been saved.");
            }
            // creates the page for the plugin options such as display options
            $Sender->Render($this->GetView('whosonline.php'));
    
        }
    
        public function PluginController_ImOnline_Create(&$Sender) {
    
            $Session = Gdn::Session();
            $UserMetaData = $this->GetUserMeta($Session->UserID, '%');
            // render new block and replace whole thing opposed to just the data
            include_once(PATH_PLUGINS.DS.'WhosOnline'.DS.'class.whosonlinemodule.php');
            $WhosOnlineModule = new WhosOnlineModule($Sender);
            $WhosOnlineModule->GetData(ArrayValue('Plugin.WhosOnline.Invisible', $UserMetaData));
            echo $WhosOnlineModule->ToString();
    
        ] public function Base_Render_Before($Sender) { $Sender->AddCssFile($this->GetResource('design/custom.css', FALSE, FALSE)); }
    
        }
    
        public function Base_Render_Before(&$Sender) { $ConfigItem = C('WhosOnline.Location.Show', 'every'); $Controller = $Sender->ControllerName; $Application = $Sender->ApplicationFolder; $Session = Gdn::Session();
    
            // Check if its visible to users
            if (C('WhosOnline.Hide', TRUE) && !$Session->IsValid()) {
            return;
            }
            $ShowOnController = array();
            switch($ConfigItem) {
            case 'every':
            $ShowOnController = array(
            'discussioncontroller',
            'categoriescontroller',
            'discussionscontroller',
            'profilecontroller',
            'activitycontroller'
            );
            break;
            case 'discussion':
            default:
            $ShowOnController = array(
            'discussioncontroller',
            'discussionscontroller',
            'categoriescontroller'
            );
            }
            if (!InArrayI($Controller, $ShowOnController)) return;
            $UserMetaData = $this->GetUserMeta($Session->UserID, '%');
            include_once(PATH_PLUGINS.DS.'WhosOnline'.DS.'class.whosonlinemodule.php');
            $WhosOnlineModule = new WhosOnlineModule($Sender);
            $WhosOnlineModule->GetData(ArrayValue('Plugin.WhosOnline.Invisible', $UserMetaData));
            $Sender->AddModule($WhosOnlineModule);
            $Sender->AddJsFile('/plugins/WhosOnline/whosonline.js');
            $Frequency = C('WhosOnline.Frequency', 4);
            if (!is_numeric($Frequency))
            $Frequency = 4;
            $Sender->AddDefinition('WhosOnlineFrequency', $Frequency);
    
        }
    
        public function Base_GetAppSettingsMenuItems_Handler(&$Sender) { $Menu = $Sender->EventArguments['SideMenu']; $Menu->AddLink('Add-ons', 'Whos Online', 'plugin/whosonline', 'Garden.Themes.Manage'); }
    
        // User Settings public function ProfileController_AfterAddSideMenu_Handler(&$Sender) { $SideMenu = $Sender->EventArguments['SideMenu']; $Session = Gdn::Session(); $ViewingUserID = $Session->UserID;
    
            if ($Sender->User->UserID == $ViewingUserID) {
            $SideMenu->AddLink('Options', T('Who\'s Online Settings'), '/profile/whosonline', FALSE, array('class' => 'Popup'));
            }
    
        }
    
        public function ProfileController_Whosonline_Create(&$Sender) {
    
            $Session = Gdn::Session();
            $UserID = $Session->IsValid() ? $Session->UserID : 0;
            // Get the data
            $UserMetaData = $this->GetUserMeta($UserID, '%');
            $ConfigArray = array(
            'Plugin.WhosOnline.Invisible' => NULL
            );
            if ($Sender->Form->AuthenticatedPostBack() === FALSE) {
            // Convert to using arrays if more options are added.
            $ConfigArray = array_merge($ConfigArray, $UserMetaData);
            $Sender->Form->SetData($ConfigArray);
            }
            else {
            $Values = $Sender->Form->FormValues();
            $FrmValues = array_intersect_key($Values, $ConfigArray);
            foreach($FrmValues as $MetaKey => $MetaValue) {
            $this->SetUserMeta($UserID, $this->TrimMetaKey($MetaKey), $MetaValue);
            }
            $Sender->StatusMessage = T("Your changes have been saved.");
            }
            $Sender->Render($this->GetView('settings.php'));
    
        }
    
        public function Setup() { $Structure = Gdn::Structure(); $Structure->Table('Whosonline') ->Column('UserID', 'int(11)', FALSE, 'primary') ->Column('Timestamp', 'datetime') ->Column('Invisible', 'int(1)', 0) ->Set(FALSE, FALSE); } } `
    

    if you leave the top line out with the php it is easier to paste the complete code.

    or use

     "&lt" with a ";"  

    for <

    and hgtonight beat me to the bracket.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • hgtonighthgtonight MVP
    edited March 2013

    In your pastebin link, you should just remove that curly brace.

    peregrine already mentioned this

    @peregrine said:
    Srggamer

    parse error - indicates problems with {};, etc.

    I suspect it is the lines above it causing the problem -

    I bet:

    T_PUBLIC happens

    you missed closing bracket "}" on a previous function or put too many {} in. Usually a bracket mismatch

    T_STRING errors

    happens when you mess up your quotes " ' . or mismatch them

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • SrggamerSrggamer ✭✭✭

    Okay. I decide to download the official version. Can someone tell me how I can make a CSS request?

  • the way you did it, just don't add syntax errors. Your routine you posted at the top was fine, you just messed up the code above it. to produce the error you got.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • SrggamerSrggamer ✭✭✭

    Finished made, it work. I wonder am I allowed to release this plugin, even though I did not fully code it?

  • yeah just give attribution to the other coder within the about.php

    There was an error rendering this rich post.

  • SrggamerSrggamer ✭✭✭

    @422 said:
    yeah just give attribution to the other coder within the about.php

    Thanks!

  • SrggamerSrggamer ✭✭✭

    @422 said:
    yeah just give attribution to the other coder within the about.php

    /default.php: The addon's key is not the same as its folder name.

    Any thing I can read somewhere? About this.

Sign In or Register to comment.