We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36926
    • 701 Posts
    Hi I don’t seem to be able to rename section or hide them. I’m using within a chunk this:
    mm_renameSection('tvs', 'Other info');

    The renaming of fields etc is working fine.

    Also is it possible to move fields into different sections.

    Thanks

    Ben
      • 21671
      • 244 Posts
      HI There,

      I think I fixed the renaming and hiding sections issue. I noticed that in the sections.inc.php supplied in version 0.37 of Managermanager the code says:
      	case 'content': 
      					$output .= '$j("div#sectionContentHeader").empty().prepend("'.jsSafe($newname).'");' . "\n";
      				break;
      				
      				case 'tvs': 
      					$output .= '$j("div#sectionTVsHeader").empty().prepend("'.jsSafe($newname).'");' . "\n" ;
      				break;
      				
      				

      and for the hide section functions further down the file. . .
      //---------------------------------------------------------------------------------
      // mm_hideSections
      // Hides sections
      //--------------------------------------------------------------------------------- 
      function mm_hideSections($sections, $roles='', $templates='') {
      
      	
      	global $modx;
      	$e = &$modx->Event;
      	
      	// if we've been supplied with a string, convert it into an array 
      	$sections = makeArray($sections);
      			
      	// if the current page is being edited by someone in the list of roles, and uses a template in the list of templates
      	if (useThisRule($roles, $templates)) {
      	
      	$output = " // ----------- Hide sections -------------- \n";
      	
      		foreach($sections as $section) {
      	
      			switch ($section) {
      										
      				case 'content': 
      					$output .= '
      					$j("#sectionContentHeader").hide();
      					$j("#sectionContentBody").hide(); 
      					';	
      				break;
      				
      				case 'tvs': 
      					$output .= ' 
      						$j("#sectionTVsHeader").hide(); 
      						$j("#sectionTVsBody").hide();
      						';
      				break;
      				
      				case 'access': // These have moved to tabs in 1.0.1
      					$output .= '
      					$j("#sectionAccessHeader").hide();
      					// $j("#sectionAccessBody").hide(); ';
      				break;
      				
      			} // end switch
      			$e->output($output . "\n");
      		} // end foreach
      	}	// end if
      	
      } // end function
      


      I then looked in the manager/actions/mutate_content.dynamic.php and noticed that none of the ids referenced in the code above (#sectionContentHeader and #sectionContentBody, #sectionTVsHeader and sectionTVsBody) existed. so I added id’s and voila.. . .it works.

      The exact lines in manager/actions/mutate_content.dynamic.php were:
      677, and 678 for the content, lines 736, 737 for the tv section.

      I also got rid of the for loop in the sections.inc.php in the hide sections part of the file and now you can hide sections one per rule.
      you can see the code below. I know there is a more elegant solution, but I didn’t need to be able to keep them in an array.
      function mm_hideSections($section, $roles='', $templates='') {
      
      	
      	global $modx;
      	$e = &$modx->Event;
      	
      	// if we've been supplied with a string, convert it into an array 
      	
      			
      	// if the current page is being edited by someone in the list of roles, and uses a template in the list of templates
      	if (useThisRule($roles, $templates)) {
      	
      	$output = " // ----------- Hide sections -------------- \n";
      	
      		
      	
      			switch ($section) {
      										
      				case 'content': 
      					$output .= '
      					$j("#sectionContentHeader").hide();
      					$j("#sectionContentBody").hide(); 
      					';	
      				break;
      				
      				case 'tvs': 
      					$output .= ' 
      						$j("#sectionTVsHeader").hide(); 
      						$j("#sectionTVsBody").hide();
      						';
      				break;
      				
      				case 'access': // These have moved to tabs in 1.0.1
      					$output .= '
      					$j("#tabAccess1").hide();
      					$j("#sectionAccessBody").hide(); ';
      				break;
      				
      			} // end switch
      			$e->output($output . "\n");
      		
      	}	// end if
      	
      } // end function
      


      I hope this helps someone out there.

      edit:

      This same technique worked for a site I have that runs evo 1.0.0-RC1 with different line numbers in the manager/actions/mutate_content.dynamic.php
      those lines were: 877, and 878 for the content, lines 936, 937 for the tv section.
        • 36926
        • 701 Posts
        Nice one noahlearner, i’ll try this out.

        Thanks

        Ben
          • 12943
          • 97 Posts
          Noahlearner, can you elaborate on your moves? I’m on 1.0.2 and MM0.3.7 and I didn’t find these lines. So I didn’t understand what/where to edit the id’s.

          Strangly enough I had this (renaming Sections) working before but it isnt anylonger -and I didnt upgrade anything.
          So perhaps it might be my/the config. I rather try your option first, before going trial&error with my config lines undecided
            Accelerate your Windows system with 9.8 m/s2.
            • 21671
            • 244 Posts
            @IngMA --Sure no problem.

            open file:manager/actions/mutate_content.dynamic.php in the evo1.02 release, go to line 677

            and change
            <div class="sectionHeader"><?php echo $_lang['resource_content']?></div>
            <div class="sectionBody">


            to:

            			<div id="sectionContentHeader" class="sectionHeader"><?php echo $_lang['resource_content']?></div>
            			<div id="sectionContentBody" class="sectionBody">


            go to line 736 and change
            <div class="sectionHeader"><?php echo $_lang['settings_templvars']?></div>
            			<div class="sectionBody tmplvars">


            to

            <div id="sectionTVsHeader" class="sectionHeader"><?php echo $_lang['settings_templvars']?></div>
            			<div id="sectionTVsBody" class="sectionBody tmplvars">
            and I then went to line 50 in assets/plugins/manangermanager/functions/sections.inc.php and changed the file as outline in reply #2. I hope this is helpful.

            _noah
              • 19975
              • 429 Posts
              Can the dev team ensure that the admin code is updated on the next release as MM is an important feature of MODx smiley
                Martin Sanders - Design & Web Development
                • 21671
                • 244 Posts
                I filed this in Jira the link is http://svn.modxcms.com/jira/browse/MODX-1600?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel If you vote for the issue in JIRA it is more likely to get fixed.

                Thanks,

                Noah
                  • 19975
                  • 429 Posts
                  Thank Noah, I never used the JIRA before smiley
                    Martin Sanders - Design & Web Development
                    • 12943
                    • 97 Posts
                    Thanks Noah for clearing that for me. I kept the foreach for the sections. It’s all working here. Except hiding the Access Permissions tab. It just won’t work here. I can do empty or print on this tab, so its picking up the mm_function correct I guess. But it wont hide for me. Anyway MM is still a favorite plugin.
                    Regards
                      Accelerate your Windows system with 9.8 m/s2.
                      • 32159
                      • 15 Posts
                      Works like a charm, thanks Noah!