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.

Modifying already existing module through plugin?

QvintusQvintus New
edited July 2013 in Vanilla 2.0 - 2.8

Hi again ^_^

I've been at this for an hour or two trying different stuff. But all I've gotten to is 3(4) lines of code that sorta does what I want but not.

I've been trying to edit the already existing About Module when viewing Profile page. However all I do is pretty much override the profile page instead.

public function ProfileController_Render_Before($Sender, $Args) {
$Sender->View = $this->GetView('/modules/userinfo.php'); // Overrides everything inside the profile view (not what I wanted)
//$Sender->Render('OnBasicInfo', '', '/modules/userinfo.php'); //Internal Error
}

As you can see it doesn't exactly override the right place... Again there is probably something I havn't understood correct.
And all I seem to do lately here is ask questions.

Even so I really appreciate the warm help I've been getting! With that said please help again.

Best Answers

  • peregrineperegrine MVP
    edited July 2013 Answer ✓

    not an answer to your question but an alternative.

    public function UserInfoModule_OnBasicInfo_Handler($Sender) {

           echo Wrap(T("Warframe"), 'dt', array('class' => 'My Warframe'));
            echo $Sender->User->Warframe
          }
    

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

Answers

  • R_JR_J Ex-Fanboy Munich Admin

    I'm not quite sure what your question is, ut I assume you want your info at another place than it is right now. There are 4 ways that might work.

    1. The most direct one is CSS. It's always worth thinking if your problem could be "styled" away.
    2. You can manipulate the DOM tree with JavaScript, but if you have to code, than you could do it right from the beginning with one of the following two alternatives
    3. Activate the plugin Eventi and look if there is a event fired right when you need it. You can hook it and your problem is solved.
    4. If the view doesn't suit your need, create a custom theme where you just override this one special view

    I think, you'll end up with 4. Copy applications/dashboard/views/profile/info.php to /theme/yourtheme/views/profile/info.phpand edit yournew file. Just add your <dd class="Value Warframe"><?php echo $this->User->Warframe; ?></dd> where you need it.

    You only have to enable your new theme to see your newly created field in user profile.

  • QvintusQvintus New
    edited July 2013

    I see I didn't explain my self enough. What I've been working on is a plugin that changes.

    1 The Registration form to have 'Warframe' option (Done thanks to peregrine)

    2 I want it to be shown in the already existing About box. (This I fail to do)

    I've tried some new attempts but they still seem to be in vain.


    public function ProfileController_Render_Before($Sender, $Args) {
    $UserInfoModule = new UserInfoModule($Sender);
    $UserInfoModule->View = $this->GetView('/modules/userinfo.php');
    }

    As you can see I've been trying to get hold of the Module of the '$Sender' which I would assume is the current one on the Profile page. But I don't seem to be able to change its view. Yet another failed attempt.

  • Simply put I want to be able to through my plugin to override the current 'view' of the UserInfoModule.

  • R_JR_J Ex-Fanboy Munich Admin

    No, it was my fault! I must have recognized it. I made the same error and @peregrine gave me a useful hint vanillaforums.org/discussion/comment/185882/#Comment_185882

    You must make sure that your view isn't rendered to "content" but to "asset". Sadly I cannot tell you how to do it... :-(

  • peregrineperegrine MVP
    edited July 2013 Answer ✓

    not an answer to your question but an alternative.

    public function UserInfoModule_OnBasicInfo_Handler($Sender) {

           echo Wrap(T("Warframe"), 'dt', array('class' => 'My Warframe'));
            echo $Sender->User->Warframe
          }
    

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

  • So thats how I use the event properly, thanks! Not what I was looking for but it'll do until I figure out how to do otherwise.

  • x00x00 MVP
    edited July 2013

    all you are doing is create a new instance of the module an setting a non-existent property.

    You could copy userinfo.php and place it in your theme's views/modules folder or your theme's views/dashboard/modules folder

    You first bet is to actually look a the code in class.module.php that will tell you exact the order of which it find the view.

    Another is to remove the module form the panel an load a custom module.

    unset($Sender->Assets['Panel']['UserInfoModule']);

    $Sender->AddModule('CustomModule', 'Panel');

    Another somewhat hacky method is to use the public Path() method. You can pretend the module is in a different location

    $Sender->Assets['Panel']['UserModule']->Path(dirname(__FILE__).DS.'modules'.DS.'class.userinfomodule.php');
    

    It will then look for 'yourtheme/views/modules/userinfo.php'

    grep is your friend.

  • QvintusQvintus New
    edited July 2013

    @peregrine said:
    not an answer to your question but an alternative.

       public function UserInfoModule_OnBasicInfo_Handler($Sender) {
         
           echo Wrap(T("Warframe"), 'dt', array('class' => 'My Warframe'));
            echo $Sender->User->Warframe
          }
    

    I ended up doing it a little different though, since your way seemed to block my path for an extra field:

    public function UserInfoModule_OnBasicInfo_Handler($Sender) {
    
        $Warframe = $Sender->User->Warframe;
        $InName = $Sender->User->Ingame;
        echo Wrap(T("Warframe"), 'dt', array('class' => 'MWarframe'));
        echo Wrap(T($Warframe), 'dd', array('class' => 'MWarframe'));
        echo Wrap(T("In-game"), 'dt', array('class' => 'Ingame'));
        echo Wrap(T($InName), 'dd', array('class' => 'Ingame'));
    }
    

    Simply wanted to add this if anyone should run into same problem.

  • T($Warframe)?
    (T($InName) ?

    why the Translate?

    don't you want this?

    echo Wrap($Warframe, 'dd', array('class' => 'MWarframe'));

    echo Wrap($InName, 'dd', array('class' => 'Ingame'));

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

  • QvintusQvintus New
    edited July 2013

    Well since I'm new to php so don't know what T() does, I simply assumed it converted stuff to readable string or something. Eitherway it works ^^

  • R_JR_J Ex-Fanboy Munich Admin

    Do you know it now? It's quite comfortable: put your string output into T() and you can override it with a language file. See the wiki for localization.

    But some functions that accept strings automatically send them through the T() function, so that you do not need to do that.

  • well in this case there appears no reason to translate $Warframe unless you are maing it generic and storing values always ash , etc

    and wanting to translate e.g. ash to bash, or ash to cash, or any other of the warframe options.

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

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    ash to cash

    or in hgtonight's case, ass to class .... ;)

  • hgtonighthgtonight ∞ · New Moderator
    edited July 2013

    @vrijvlinder said:
    or in hgtonight's case, ass to class .... ;)

    :O

    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.

Sign In or Register to comment.