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:
- Reinstall MojoMotor
- Remove the offending code from the MojoMotor database
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:
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.
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.
Photo credit: Steve Parker
Back-end developer at Q Digital Studio
Clinton Reeves is a back-end developer at Q Digital Studio. Clinton lives and breathes code and has the B.S. in Information Systems to back it up. Though a self-proclaimed nerd who happily embraces said nerdiness, Clinton actually makes coding look cool.
Even though Clinton thinks about code all day (and sometimes even dreams in code), it wasn't always so easy for him. In college, he took a programming class and really liked it, so he switched majors. Programming did not come intuitively to Clinton and was really hard for him to learn. But it was that challenge that ultimately attracted him and kept him interested. These days he makes coding look positively effortless, but that may have something to do with the requisite eight cups of coffee he drinks daily.