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.

How does one modify modules/assets called by default.master.tpl?

Hi all,

First of all: as you might know from previous posts of mine, or will see through this one, I'm pretty new to vanilla, so please forgive my relative incompetence! sorry!

I'm currently trying to tweak the layout of my forums, but I'm having some trouble understanding where I should look for files to modify. I've read the various pages in the documentation and I understand that default.master.tpl is the file that basically calls the various parts of the forum from the php files present in the views directories, and assembles everything together to generate your forum page...

The thing is, for instance I'd like to modify what is displayed in the forums' panel – the corresponding line in default.master.tpl is {asset name="Panel"}, and I did move that line to where I wanted the panel to be displayed, but I can't actually modify the contents. How should I proceed to do that?
Same goes for the modules: there's {module name="MeModule"} but then I found several folders called 'modules', containing several files that could refer to the 'MeModule'. How do I know which one I am to modify?

And, actually, for now I'm only having issues with the assets and modules but I'll probably run into the same problem later on with the views as well – for instance if I want to modify how the discussions list looks, where should I go? There are 2 folders called 'discussion(s)' in applications/vanilla/views, each containing several files, and then there's applications/conversations which could refer to discussions as well, and I'm probably missing some...

So, yeah, I'm a bit confused, haha :stuck_out_tongue_closed_eyes: Any help would be appreciated.

«13

Comments

  • peregrineperegrine MVP
    edited August 2014

    changing wording..

    http://vanillaforums.org/discussion/26597/tutorial-how-to-change-wording-how-to-change-text-how-to-change-language-how-to-change-locale

    if you want to sort panels via a confiig statement in config.php

    http://vanillaforums.org/discussion/comment/163830/#Comment_163830

    there is no generic answer to your questions really, if you have a specific module with something post a screenshot and show what you want to change and to what.

    you can add links to some modules or tabs, and remove them via events.

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

  • wow great answers. I'm gonna read everything and report back :) and if I manage to get a custom theme up and running I might even publish it here!

    now wondering whether I should mark your posts as insightful or awesome...

  • AccentAccent
    edited August 2014

    Just letting you know that I've been making a lot of progress in way less time than I expected, and now the layout is almost complete for the main views... I still have to handle special pages like individual profiles, etc. and make sure I don't forget anything (since I removed a lot of extra fluff I didn't want from some modules).

    As soon as it's all done and functional, I'll upload it with just the minimum amount of CSS to make it look right while keeping the default theme's colours and feel.

    Thanks again for your help! :)

  • Ran into an issue I can't quite manage to solve...
    I'm trying to move 4 elements: the side menu in a profile edit screen (where it says Edit Profile, Change My Password, Notification Preferences, etc.) and, in a conversation with someone, the Delete Conversation button, the list of people in the conversation, and the Add people form.

    Now I think I found which modules control those. Respectively, there's SideMenuModule from the dashboard application, and ClearHistoryModule, InThisConversationModule and AddPeopleModule from the conversations application.

    The thing is, when I add those modules to other parts of the site in default.master.tpl, they aren't actually displayed – apart from the 'add people' form which actually works as it should, but I thought I'd mention it to be clear. I've tried copying the views corresponding to those modules in my theme folder, in case there was a conflict between applications or something, but it didn't work.

    I really can't think of what I might be doing wrong, those are the only modules that are reluctant in this way...

  • How are you attempting to move them?

    Modules are sorted at the application level, so there are separate config items for each application.

    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.

  • I just copied {module name="SideMenuModule"} and the others where I want them to be in default.master.tpl. This is how I've done it for the others (CategoriesModule, NewDiscussionModule, DiscussionFilterModule, MeModule etc.) and it's always worked so far :/

  • I also tried adding echo Gdn_Theme::Module('ClearHistoryModule'); to the correct views I wanted the modules to be displayed in, and again only the AddPeople module works.

  • Modules are very, very variable in how they could be built. The clearhistorymodule expects a ConversationID. That ConversationID is not read somewhere in the module itself, but it must be given on the time the module is created.

    I guess you would have to create a custom smarty function, but I would not know how... :/

  • Modules are usually added via a controller method in the application or via a plugin that hooks into the controller. If you are adding a module via a view, you will need to pass it the information it needs via the {module} Smarty plugin.

    For example, for the ClearHistoryModule you would use the following smarty markup:

    {module name="ClearHistoryModule" ConversationID="123"}

    Where 123 is the conversation id.

    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.

  • @hgtonight said:
    {module name="ClearHistoryModule" ConversationID="123"}

    Where 123 is the conversation id.

    I bet he needs it dynamically. So I think it would be necessary to create a custom Smarty function where you have to get the ConversationID from the controller.

  • I can't just use Smarty plugins in php files though, can I? That's why I have to use echo Gdn_Theme::Module

  • R_JR_J Admin
    edited August 2014

    If you are in a php file, you could use the power of the framework! Great you reminded me of that...

    First you have to find out how you can get the ConversationID. Put a decho($this); somewhere in the target view and be prepared to see a lot of information. You should find the ConversationID somewhere and then you might be able to do the following in your new view (ugly, but maybe someone else has a better idea)

        $ConversationID = $this->...whatever you've found out->ConversationID;
        $ClearHistoryModule = new ClearHistoryModule($this);
        $ClearHistoryModule->ConversationID($ConversationID);
        $this->AddModule($ClearHistoryModule);
    

    edited based on hgtonights knowledge ;-)

  • hgtonighthgtonight MVP
    edited August 2014

    Views are executed in the scope of the controller, so you should inspect $this rather than sender.

    EDIT - I am getting confused, is this in a plugin hook? Then inpect $Sender :S

    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.

  • AccentAccent
    edited August 2014

    okay so I think I found something. I did see the ConversationID in the debug info... for instance there's this:

    [AddPeopleModule] => AddPeopleModule Object
                            (
                                [Conversation] => stdClass Object
                                    (
                                        [ConversationID] => 2
                                        ...
    

    which I assume confirms that the ConversationID was properly passed on to the AddPeople module.

    But then I found this:

    [ClearHistoryModule] => ClearHistoryModule Object
                            (
                                [ConversationID:protected] => 2
                                ...
    

    and doesn't that mean the ClearHistoryModule also managed to retrieve the correct ID? (It still doesn't show up, though...)

    And I also found:

    [InThisConversationModule] => InThisConversationModule Object
                            (
                                [AssetName] => 
                                [_ApplicationFolder:protected] => conversations
                                [Data] => Gdn_DataSet Object
                                    (
                                        ...
                                        [_Result:protected] => Array
                                            (
                                                [0] => stdClass Object
                                                    (
                                                        [UserID] => 1
                                                        [Name] => Accent
                                                        ...
    

    and below that, more information about me as well as the other participants of that conversation. So it really looks like the modules can get access to whatever information they need, and yet they're still not displayed...

  • R_JR_J Admin
    edited August 2014

    @Accent: it would be much easier if you you would show us some more code ;)
    I've added that lines to the /applications/conversations/views/messages/messages.php view:

    $ConversationID = $this->Conversation->ConversationID;
    $ClearHistoryModule = new ClearHistoryModule($this);
    $ClearHistoryModule->ConversationID($ConversationID);
    $this->AddModule($ClearHistoryModule, 'Content');
    

    and I see the [Delete Conversation] button now (also) under a conversation.

    Assets like Panel and Content are containers and you can stack modules. But if you want to have the modules output somewhere in the html flow, you couldn't always rely on the AddModule but you would have to trigger it's output directly. You can put that (nearly) anywhere you like inside of your views:

    $ConversationID = $this->Conversation->ConversationID;
    $ClearHistoryModule = new ClearHistoryModule($this);
    $ClearHistoryModule->ConversationID($ConversationID);
    echo $ClearHistoryModule->ToString(); // or simply echo $ClearHistoryModule;
    

    "nearly anywhere" because $this has to be a conversation controller, but I guess that button makes no sense outside of a conversation...


    @hgtonight: as far as I know, it should be inside of a custom view

  • Hm, it works with ClearHistoryModule but completely breaks with InThisConversationModule. I'll investigate. Those are the last things I need before I can publish the theme!!!

  • This is the error apparently:

             trigger_error(ErrorMessage('The "' . $this->ClassName . '" object does not have a "' . $ActualMethodName . '" method.', $this->ClassName, $ActualMethodName), E_USER_ERROR);
    
  • Investigate how that Module is called inside Vanilla (by using a full text search):

          $InThisConversationModule = new InThisConversationModule($this);
          $InThisConversationModule->SetData($this->RecipientData);
          $this->AddModule($InThisConversationModule);
    

    It needs "RecipientData". Don't know what that is but I guess if you copy those three lines into your view, you'll see the module (maybe you have to replace the last line with echo $InThisConversationModule;)

Sign In or Register to comment.