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?

2

Comments

  • Yep it works! Now I'll see if the side menu in the profile preferences work, and then it'll be all good I think.

    Also enabling debug breaks discussions, lol. It says there's something deprecated in vanilla's core files.

  • Normally debug doesn't break discussions. Could be a problem of your theme. I would be interested in the deprecated message, maybe it's on behalf of your theme, too. You should check if those errors are still there if you use the default theme

  • AccentAccent
    edited August 2014

    Now I'm stuck with the SideMenu that's used to go from page to page when editing a profile (edit profile, change password, notification preferences, etc.)
    This is the last thing I'm missing...

    The problem is, I can't even figure out what calls the SideMenuModule. Thanks to some investigation I found that in the default theme, the side menu is built by the profile controller (which is confirmed by the url if I'm not mistaken – .../profile/edit), and then only displayed when the profile page is in Edit mode... so I copied this in profile/index.php:

    $SideMenu = new SideMenuModule($this);
       if ($this->EditMode) {
          decho($this);
          $this->FireEvent('AfterAddSideMenu');
          $this->AddModule($SideMenu, 'Content');
       }
    

    but it didn't work. The debug info is never shown, even when I try to edit my profile. Of course I also tried the previous method (adding echo Gdn_Theme::Module('SideMenuModule');) but to no avail either. When I put decho($this); outside of the if { } test, the debug info is displayed on the profile page, but it doesn't mention any SideMenuModule at all (whereas previously in the conversation page, the debug info listed the ClearHistoryModule for instance but without enough data).

    I could try to add a side menu to each of the views (profile/edit.php, profile/password.php, etc.) but then it won't work with plugins that add a view to the profile edit page, like the Signatures plugin...

    edit:
    Nope, the discussions break when debug is on, even with the default theme. This is the error message:

    DiscussionController->CommentData is deprecated. Use DiscussionController->Data('Comments') instead.

    The error occurred on or near: .../public_html/recreatio/library/core/functions.general.php

    703:       $Msg = $Name.' is deprecated.';
    704:       if ($NewName)
    705:          $Msg .= " Use $NewName instead.";
    706: 
    707:       ---->trigger_error($Msg, E_USER_DEPRECATED);
    708:    }
    709: }
    710: 
    711: if (!function_exists('ExternalUrl')) {
    

    ----> is the line that's highlighted.

  • If you search the source of Vanilla 2.1 for "CommentData", you'll find only the deprecated message: https://github.com/vanilla/vanilla/search?q=CommentData&ref=cmdform

    There is no function where it is used. I guess some plugin is cuasing that. You might want to do a full text search for CommentData in the plugin folder and report that with a discussion that you post under the appropriate plugin.

  • I thought the ClearHistory and InThisConversation has been the last changes ;)

    Maybe we could figure out how to do that but I'm not sure that this would be the best way to achieve what you want to achieve. The SideMenuModule is a container by itself and it must be filled if I understand right what I have seen with a short glance.

    It contains calls to the FireEvent function which should alert you that every change could seriously break the layout (if not functionality!) if you use a function that uses that event. In order to test your theme, you will have to download quite a lot of the most popular plugins and do a full text search for the parameter of the FireEvent call.

    If what you are doing is pushing around modules, you might have been better off with creating more asset places in the default master and placing the modules there, but you've started it that way and maybe you can finish it like that. I should have told you that in the first place: giving a short sketch to the community often results in very good hints on how to achieve that goal on the best way. I feel a little lousy now that I lead you the hard way...

    But let's go through the code: we are in profilecontroller, so search for the SideMenuModue (since you want to see how it is built). It is part of function AddSideMenu and it is there 3 times:

    $SideMenu = new SideMenuModule($this);
    ...
    $this->BuildEditMenu($SideMenu, $CurrentUrl);
    ...
    $this->AddModule($SideMenu, 'Panel');
    

    There is the function BuildEditMenu that has the SideMenu as its parameter. Look at that function: the Module is passed and manipulated there, so you have to do some additional actions to create the SideMenu. There is quite a lot of work done in that function. The good news are, you do not have to copy that functionality, you can simply use it ;)

    It expects a reference to the Module and the current URl. Solve that current URl problem later and try if that works:

    $CurrentUrl = strtolower($this->SelfUrl); // don't kno if that works
    $SideMenu = new SideMenuModule($this);
    $this->BuildEditMenu($SideMenu, $CurrentUrl);
    $this->AddModule($SideMenu, 'Panel'); // or echo $SideModule->ToString(); 
    
  • AccentAccent
    edited August 2014

    Yup, it was ThankfulPeople2. Fixed it.

    Doesn't help me with SideMenuModule though...

    edit: talked too fast! When I said 'these are the last changes' I meant the 4 things I mentioned earlier, ie. AddPeople, ClearHistory, InThisConversation and SideMenu – now only the last one is left ;)

  • Okay, in what view do you want to insert the side menu? If I add the following lines to profilecontrollers view edit.php it works as expected:

        $CurrentUrl = strtolower($this->SelfUrl); // don't know if that works
    decho($CurrentUrl); // yes, it is correct :)    
        $SideMenu = new SideMenuModule($this);
        $this->BuildEditMenu($SideMenu, $CurrentUrl);
        $this->AddModule($SideMenu, 'Content'); // add module to bottom of asset Content
        echo $SideMenu->ToString(); // print it out right here
    
  • Guys, just so you know, my internet's down, the IAP had a failure or something, so I can't test anything right now and I can barely access this forum from my phone... I'll keep you posted as soon as I've had the chance to try things :)

  • I first read "My interest is down" and I was starting to boil with rage about that! :D

  • peregrineperegrine MVP
    edited August 2014

    @R_J said:
    I first read "My interest is down" and I was starting to boil with rage about that! :D

    @r_j, about the only time you were glad the internet was down :)

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

  • @R_J said:
    I was starting to boil with rage about that! :D

    We did have someone (several people) come through here that kind of said the same thing but used the words "I can't code and don't have the time or money..." which does translate into " My Interest is down" and it does similarly cause the blood to boil :#

    But Accent has demonstrated interest and spent time required to fix the issues and also has shared the results and has been generous as well. <3

  • Ok I'm using my phone's internet sharing for now, hopefully everything'll get fixed soon because while I can at least use my PC, the connection speed is terrible :(

    @vrijvlinder‌, well, I know I'm probably making you all sigh and facepalm a lot, but I do try my best to find solutions by myself, promise!

    So @R_J I tried your suggestion of using BuildEditMenu, it works... kinda :P

    If I copy that code in profile/index.php, I do see the menu added to my profile page. However, it's incomplete (doesn't include any links for plugin-related preferences). And when I click on one of the links, it leads me to the corresponding edit page, but once there the menu isn't displayed anymore*...
    Maybe I could make it so the links open pop-ups instead of leading to a new page, but that seems like it'd be a bit complicated...

    *I wrote that before I could see your suggestion to add it to edit.php – and, yeah, I tried that... the SideMenu does appear but the problems are the same: 1) it only shows 4 links (should be 8 with the plugins) and 2) I would need to do that for every view, and I can't modify the plugin views in a theme :( Unless you mean to add it to class.profilecontroller.php? I thought themes could only contain views...

    I got another idea though: I can leave {asset name="Panel"} in default.master.tpl and then use CSS to hide the Panel everywhere except in the edit profile pages... but 1) hiding it from everywhere else is going to be one hell of a mess, probably gonna cause exceptions to handle everywhere and 2) it's a bit of a shame to resort to that when SideMenu is the very last module I need and I managed (with your help ;) ) to get all the others to display already. But I guess it would probably solve the issue...

  • Yep, as I suspected, that last idea works. Leaving the Panel asset in every page, and setting display: none; in CSS except for the profile edit pages (identifiable by the .EditMode class). I wish I'd thought of that sooner – I'll have a look at the way I implemented other modules to see if I can't simplify it now that the Panel exists...

    If anyone thinks of a way to add either the complete SideMenu module or the Panel asset to the correct file (so, not profile/index.php, nor profile/edit.php, nor profile/password.php, etc.), I'd very much be interested in hearing it though :)

  • most pages have some css element that allows some identification of the page you are on, so if if you identify some element that is unique on the page you want to hide something in a class or id based on a another class or id. Since I'm a visual thinker, I need pictures to see what you want instead of names.

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

  • AccentAccent
    edited August 2014

    @peregrine‌: yeah, I managed to do that, but it just somewhat irks me to load the asset on every single page only to display it the user prefs.

    Anyway, after, after a tiny bit of cleaning up and removing a couple lines that had been made obsolete by the re-inclusion of the Panel asset, I've published the theme and you can have a look at it yourself :)

    Here it is!

    Now, I'm going to do some deeper CSS edits :P

    Thanks again everyone for your invaluable help!

  • R_JR_J Admin
    edited August 2014

    Some remarks to what you've done...

    First of all: great! You've finished your first own peace of Vanilla work! Feels great, doesn't it? I bet you've learned a lot out of that and you'll see that extending Vanilla is a piece of cake ;)

    Plugins work by hooking into events that are called in the program flow with calls to the function FireEvent. The ProfileController has a function AddSideMenu, that adds the side menu. From that function, I have taken the code. If you look at that, you'll see that it contains $this->FireEvent('AfterAddSideMenu');. So in order to keep the functionality that other plugins offer, you would have to enclose that FireEvent in your custom view, too.

    I am no themeing guy, but I've taken a look at your forum and I see there are still some major glitches around. The H1.HomepageTitle is only partly visible, the entries in the header (title, shoutbox, welcome stranger, searchbox) are totally unaligned and, as you've stated in the description of your theme, I guess nearly every plugin will break the layout.

    I really like the idea of hiding the panel in a kind of megamenu that is autohidden, but I guess it could have been achieved with a custom default.master.tpl and CSS. That approach would have preserved the functionality of other plugins. But as I've said before, it would have been better if I've asked you first what you want to achieve before answering your question literally - my fault.

    If I had known about your plans, I would have given you the advice to start with such a modified default master:

    <!DOCTYPE html>
    <html>
    <head>
      {asset name="Head"}
    </head>
    <body id="{$BodyID}" class="{$BodyClass}">
       <div id="Frame">
          <div class="Head" id="Head">
             <div class="Row AutoHide">
                <div class="Column PanelColumn" id="Panel">
                   {module name="MeModule"}
                   {asset name="Panel"}
                </div>
    
                <div class="Column MenuColumn">
                   <ul class="SiteMenu">
                      <!-- {dashboard_link} -->
                      {discussions_link}
                      {activity_link}
                      <!-- {inbox_link} -->
                      {custom_menu}
                      <!-- {profile_link}
                      {signinout_link}  -->
                   </ul>
                </div>
             </div>
             <div class="Row">
                <strong class="SiteTitle"><a href="{link path="/"}">{logo}</a></strong>
                <div class="SiteSearch">{searchbox}</div>
             </div>
          </div>
          <div id="Body">
             <div class="Row">
                <div class="BreadcrumbsWrapper">{breadcrumbs}</div>
                <div class="Column ContentColumn" id="Content">{asset name="Content"}</div>
             </div>
          </div>
          <div id="Foot">
             <div class="Row">
                <a href="{vanillaurl}" class="PoweredByVanilla" title="Community Software by Vanilla Forums">Powered by Vanilla</a>
                {asset name="Foot"}
             </div>
          </div>
       </div>
       {event name="AfterBody"}
    </body>
    </html>
    

    As you can see, the div.Head has now two rows, one with the Panel and some navigation links (those two columns should be set to width = 50%) and the other with the site title and the search box

    I would say the rest should be doable with styling by CSS. You might have the need for an additional asset container {asset name="HeadPanel"} inside of the second row.

    Normally Modules are added with the AddModule function and it should be possible to delete modules from the asset container, but you would have to ask for something like that, if simply not displaying them with CSS isn't enough for your needs.

  • R_JR_J Admin
    edited August 2014

    Well, I guess you have to quote my posting in order to see the html.

    Funny :) if not spooky! Nice way to hide some text, though completely useless...

  • AccentAccent
    edited August 2014

    Thanks :)

    I'll have a look at the FireEvents. I could probably add them where they need be; I haven't actually added many modules independently.

    The categories being unaligned wasn't planned! It works just as it's supposed to in Chrome, but only now did I see that it didn't in FireFox and IE >_< HomePageTitle not being fully visible is a direct consequence. (You can see the intended behaviour in the screenshots on the theme page.)

    Now, as for doing it all in default.master.tpl and CSS... I tried, but to be honest I'm not sure it'd be possible. I included as few views as I could – there are 8, and most are very tiny modifications like adding a <div> somewhere to allow better CSS targetting...

    Adding a second Row in .Head would maybe have made it easier to hide the entire div regardless of its content (now it slides by a set amount), but then again I'm sure that would be doable with my current implementation too. I guess what you're saying more importantly is that I should have added entire assets, instead of separate modules, and then added display:non to the modules I didn't want to see via CSS...? Maybe so. Do you think it would make a big difference? Both the Content and Panel assets are present in the default.master.tpl, so I think most plugins would still "work"... it's just that, yeah, some links wouldn't be visible, but it was my intention from the start to have a very limited and definite content in the Head...

  • Best way is to try it out. Get some plugins and see how they behave

  • I'll do that.

    In the meantime the non-aligned menu items are fixed in Firefox and IE :)
    There's an issue with IE showing the pop-up dialogs below the Header, but, sigh, IE...

Sign In or Register to comment.