Joomla Parent Menu Hack

By default, if you are adding new content to your Joomla CMS and wish to link the item in one of your menus you link the item when it's created then move to the menu manager to position the content where you want it displayed. This hack takes away that element and allows you to place your content exactly where you want it when it's created. Seemless content addition, saves you time and hassle.

Click to Enlarge
Here you see the standard Joomla "Add Content" page, you select the menu item you wish your content to appear in in the highlighted area.
Click to Enlarge
Once you click on the menu, you are shown the current contents and can place the menu item in the normal way within the location you want.

Here's how it's done:

  1. Download the Mootools library.
  2. Upload mootools.js to your_site/administrator/includes/js/
  1. Open the file your_site/administrator/templates/index.php
  2. Add the following in the file head:
    1. <!-- Start Parent Menu Hack //-->
      <script language="JavaScript" src="<?php echo $mosConfig_live_site; ?>/administrator/includes/js/mootools.js" type="text/javascript"></script>
      <!-- End Parent Menu Hack //-->
  1. Open the file your_site/administrator/components/com_content/admin.content.php
  2. Find (on line 27):
    1. switch ($task) {
      case 'new':
  3. Replace with:
    1. switch ($task) {
      // Start Parent Menu Hack
      case 'parentmenu':
      $hack->menutype = mosGetParam( $_REQUEST, 'menutype' );
      $hack->parent = 0;
      $hack->id = 0;
      print mosAdminMenus::Parent( $hack ); // Print the menu
      exit; // Stop it from printing out all the joomla headers
      break;
      // End Parent Menu Hack
      case 'new':
  4. Find (on line 640):
    1. $lists['menuselect'] = mosAdminMenus::MenuSelect();
  5. Replace with:
    1. $lists['menuselect'] = mosAdminMenus::MenuSelect( 'menuselect', "onclick='getMenu(this.options[this.options.selectedIndex].value)'" );
  6. Find (on line 1283):
    1. $link = strval( mosGetParam( $_POST, 'link_name', '' ) );
  7. Replace with:
    1. $link = strval( mosGetParam( $_POST, 'link_name', '' ) );
      // Start Parent Menu Hack
      $parent = strval( mosGetParam( $_POST, 'parent', '' ) );
      // End Parent Menu Hack
  8. Find (on line 1295):
    1. $row->ordering = 9999;
  9. Replace with:
    1. $row->ordering = 9999;
      // Start Parent Menu Hack
      $row->parent = $parent;
      // End Parent Menu Hack
  1. Open the file your_site/administrator/components/com_content/admin.content.html.php
  2. Find (on line 1006):
    1. <td valign="top" width="90">Select a Menu</td>
      <td><?php echo $lists['menuselect']; ?></td>
      </tr>
  3. Replace with:
    1. <td valign="top" width="90">Select a Menu</td>
      <td><?php echo $lists['menuselect']; ?></td>
      </tr>
      <!-- Start Parent Menu Hack //-->
      <script language="JavaScript" type="text/javascript">
      function getMenu(menutype) {
      // Do mootools ajax call, replace the parent menu with the one returned
      var postString = 'option=com_content&task=parentmenu&menutype='+menutype;
      $('menu_hack').innerHTML = 'Loading, please wait...';
      new Ajax ('index2.php', {
      postBody: postString,
      update: $('menu_hack')
      }).request();
      }
      </script>
      <tr>
      <td valign="top" width="90">Menu Parent</td>
      <td><div id="menu_hack">Please select a Menu</div></td>
      </tr>
      <!-- End Parent Menu Hack //-->