Things must move onwards and upwards, and a few weeks ago we got an onward and upwards looking new version of MojoMotor - MojoMotor 1.1. We got some great new features (embedding layouts - hooray!) but we also go some changes under the hood.
If you’re a developer of MojoMotor add-ons such as myself, you may have found your add-on broken in 1.1 on maybe even totally broken (sorry, Jamie!). Here is a little guide to what changed and how to deal.
First of all, if you need to fix something because of a MojoMotor version, you can always call upon the current version number to do comparisons:
$mm_version = $addon->site_model->get_setting('mojo_version');
The above will grab the version number (ex: 1.1) so you can do things like:
if($mm_version >= 1.1):
// Do something for MM 1.1
endif;
MojoMotor 1.1 has a subtle change - all of the admin controllers have been moved into an admin folder. More like ExpressionEngine 2’s file structure, the change is not noticeable to the end user because, of course, users do not go to an admin URL, but the URLs are called via AJAX using the MojoBar.
So what, you ask? In the Developer docs, it gives you a method to accessing your add-on via the URL using this structure:
index.php/addons/{name}/{function}/{optional_parameters}
This is useful for a few things. MojoBlocks uses custom JS and CSS so it is called via the add-on with special javascript and css functions.
However, this doesn’t work anymore, because the addons.php file is now in /admin. So now you need to call:
index.php/admin/addons/{name}/{function}/{optional_parameters}
So in order to be backwards compatible, you need to make accommodations for both. Good thing you can get the version number!
In MojoMotor 1.0, it was kind of hard to get a 404 to come up. For example, if you had an about page at /page/about, it would show your about page. Unfortunately, /page/about/midget-porn also showed your about page.
In many cases there was not a lot you could do about visitors seeing a page with a wrong URL if there was an old link or something. In MojoMotor 1.1, however, the page handling has been reworked and any page that does not specifically exist turns up a 404.
While this may be better for visitors, this has had an impact on add-on devs. Jamie Rumbelow’s MojoBlog broke in 1.1 because it depends on calling URLs that aren’t defined in the site structure. MojoBlog 2 is out soon though so never fear!
As outlined in the change log, there are some functions that are out of here:
delete_dummy_page_regions() - models/page_model.php
_add_page_to_structure() - models/page_model.php
update_site_structure - controllers/admin/pages.php
Unless you have an add-on that has some structural functions, it is unlikely you’re using these. So, this sections sucks. I’m sorry.
In the end, though, if you have a MojoMotor add-on you want tons of people using MojoMotor and version 1.1 gets rid of some of the biggest problems: no embedding and the super ugly page/ in the URL.
So suck it up and make sure your add-on is backwards compatible with a few if statements and you are good to go. Happy add-on creating!
There are no comments for this article.
Date: 03/03/11
Author: Adam Fairholm
I'm particularly interested in how the body class is added when the mojobar is opened! That was one that was hard to get around in the past.
Feb 09, 2012 3:20am