Finding MojoMotor’s disappearing Control Panel

Clinton Reeves / Posted 3.6.2012

Finding MojoMotor's disappearing Control Panel

MojoMotor is a great framework for projects that are smaller in scope or in budget, and its overall simplicity, combined with its affordable price and the phenomenal support provided by EllisLab makes it a fantastic CMS for a variety of sites.

But, (as with all systems), MojoMotor does have some quirks (or “features” if you prefer) which take a little getting used to at first. One of these quirks can be very frustrating and downright scary if you aren't expecting it. Specifically, I'm talking about the “disappearing Control Panel” issue.

If you have yet to encounter this problem when working in MojoMotor, consider yourself lucky but realize that yes, it can happen to you, so be prepared.

If you have encountered this problem in the past, or are currently experiencing it, you know exactly what I'm talking about. Whatever the case may be, hang tight, I’ll walk you through the issue and help you find a solution.

Understanding why your control panel “disappeared”

Part of fixing any problem is figuring out what caused it to happen in the first place. MojoMotor’s Control Panel is rendered through the use of jQuery and while this is a perfectly acceptable means of creating this feature, at times it can present some real challenges.

If you use jQuery for any additional elements within your website, its possible that a conflict will occur. If say, you’re calling in additional jQuery libraries within your layouts, some of these calls might conflict with the libraries that MojoMotor depends on.

When a conflict like this happens, jQuery's built-in response is to stop code execution. This response, while understandable, means that important features on your site may not show up at all – important features like your Control Panel.

Fixing the Problem

So you've lost the Control Panel. Now what? In order to get it back you have one of two options:

  1. Reinstall MojoMotor
  2. Remove the offending code from the MojoMotor database

Reinstall MojoMotor

If you have encountered this problem and you have not yet put too much work into the site, and most importantly, wouldn't have a problem losing all of your work up to that point, you can simply reinstall MojoMotor.

This will wipe out all of the data stored in the MojoMotor database and take you back to square one. The process can taken anywhere from 60 seconds to 5 minutes – depending on how comfortable you are with the framework. After a full reinstall, your Control Panel will reappear.

Remove the offending code

Of course, doing a complete rebuild of the framework, and in extension, losing all of the work you have put into the site up to that point, is not always a viable or practical option. If you’re not willing to start over completely, the other option you have is to find the offending code and remove it from the database.

To begin searching for the offending code, you will need to log in to your Database Control Panel. For the majority of users, this means you will need to open up phpMyAdmin.

Depending on your website’s hosting service, you will probably be greeted with a screen that looks like the following:

When you see this screen (or something similar), you will then need to select the database where your MojoMotor records are being stored.

After you have selected your MojoMotor database, you should see a screen with a list of tables. Depending on your initial configuration and any add ons you have installed, your table list may differ slightly from the one you see below:

From here, you will want to select the mojo_layouts table. Once you have selected this table, a list of all the layouts you have created for the site thus far should appear. In this tutorial I have decided to use the standard installation, so only one layout is displayed – you may have more.

Think back to the layout you were working in right before your Control Panel disappeared. Find this layout in the list and then select “Edit.” A new screen will appear which looks like this:    

From here, it’s just a matter of locating the offending line of code from the layout_content field, removing it, and then saving the revised content. You may have a good idea what piece of code is causing the problem – if you do, then it’s simply a matter of removing it from the layout_content field, saving the changes and refreshing your site.

If you don't know or aren’t 100% which line of code is causing the problem, I would recommend doing two things:

  1. Open a text document, copy and paste (make sure you don't cut and paste) the content into the text document (so you have a backup if you need it) then proceed to the next step.

  2. As discussed above, the cause of your problem is most likely related to a conflict in the jQuery. To find the source of the problem, remove each script tag within the layout one by one. After you have removed a script tag, save the changes and then refresh your site to see if the Control Panel appears. If it does, you found the problem! If it doesn't, the problem is still there. Add the script tag you just removed back in to the layout_content field, and move on to the next one. Continue by process of elimination until your Control Panel reappears.

Note: If you are following the steps above and not having any success, make sure you are logged in. If you aren't logged in, the Control Panel won't display – even if you fix the problem.  

Clinton Reeves

Clinton Reeves

Back-end Developer

Clinton is a back-end developer at Q Digital Studio who lives and breathes code. He is Q Digital's resident problem-solver; if he can't fix it, he'll just create new code or a shiny new add-on. When he's not problem-solving at the studio, he's likely under the hood of a car or remodeling his house.