Stumbling onto Joomla

Before two months ago (about the time I got laid off) I had never even heard of “Joomla”. Very odd name… I stumbled onto the CMS (Content Management Software) from a friend of mine who wanted help with their website (http://www.sizzlencuisine.com). She had previously been working with other website designers and wasn’t very happy with their progress/communication (what a shocker). I have now spent a few weeks working very diligently to learn what Joomla is about, how to develop a website with Joomla and even how to develop a custom Joomla component (which I now have available for sale on my website). It has, overall, been an intriguing and experience and one that I find worth sharing.So, I decided to help her out given that I had a fair amount of free time anyways. At this point she had already spent almost $2,000 having these other website developers put the site together and she just need to finish it up so she could promote the site before her next big event. Her website focuses on gourmet food/beverage restaurants/shops in the inland north-west (Idaho area). The website is very content heavy and she needed a way to manage the content herself (write her own articles, upload images, manage newsletters, etc). Honestly, if you were to go to a website shop and ask them to design a website of this scale I believe they would likely come back with a multi-thousand dollar quote just for a bare minimum of what she needed. She, of course, had a laundry list of problems with what the previous developers had “finished” for her. Most of them were very stupid issues which in my mind shouldn’t have ever even been seen by her – issues like not being able to see the login screen until you press login, but the login screen shows up in the header instead of the body. When I initially looked at her website it looked very cluttered. I couldn’t tell the difference between contest and ads. I couldn’t even figure out where to login… I have no idea what kind of reputation these other developers had, but to see this kind of work come from someone that considered themself to be professional astounded me. I suppose my thoughts on the degredation of the developer’s good name are a separate subject though.

When you initially look at the website’s directory structure it can be a bit daunting. There are a great number of sub-directories and even more files. I found that starting out with the code was not a good approach to figuring out her problem. When I opened up the administrator section I found there was a rather nice (and fairly advanced) interface. The concept of joomla’s modules, components and plugins was rather fuzzy to me. I am very familiar with those concepts in the C#/.Net and Java world but how it is that it applied to a website developed in PHP was stumbling me (at first). Eventually through playing with the modules long enough I figured out that it really wasn’t very different from what I was used to: modular chunk of code (typically a small chunk) that can be placed in many different locations on a page that provides a distinct function of the component it relates to.

Quirks

I found that joomla has some quirks. I will only list the more prominent ones that i found:

  • Front-page blog layout: By default, joomla displays the front-page as a blog article layout. As you create articles for your website using joomla’s content component you can specify whether or not you want the article to display on the front page of the web site. This is a pretty cool feature. I wouldn’t mind there being an option to automatically rotate the articles in and out of the front page, but oh well – although, maybe there is an option and I just haven’t found it yet. Well anyways, for the longest while I couldn’t figure out how it is that joomla decides the layout order of the articles on the front page. By default, it shows a single article on top and then all remaining articles in a two-column fashion. I kept looking in the content component’s parameters thinking I would find the layout options there but ended up finding the options in the MAIN MENU’s parameters. It seems that joomla decides WHAT the main page is based on the menu (you can select a single menu item as the home page).
  • Article’s embedded content: When I wanted to place a Paypal button on an article I modified the html of the article with the advanced WYSIWYG editor. Well, every time I told the editor to update the html of the article it removed my form, select box, and hidden input fields. This stumped me for a while. When I google’d my problem I found plenty of people talking about it. They all referenced the article manager’s parameters and said that you need to select the “Registered” group and specify a filtering method. This didn’t work for me, period. The parameters/configuration made sense to me (at least I thought) but when I told it to do one thing it did another. I ended up finding (on my own) that there are additional parameters to edit inside the editor’s plugin (which you have to access from the “Extensions” menu. I still have not yet found any references to this on google, so maybe my blog will help with this confusion.
    • Although, I found that you have to be careful with this. If you mess with the editor’s settings and set the “filter on save” option to “none”, then your article’s read more separator won’t work.
  • Transferring the website: I always do my web development work in offline mode first, that way it is 1) quicker for me to develop and 2) not disturbing anyone viewing the live web site. So, I did this for my own web site and prepared the entire thing before launching the web site on my hosted account. This seemed to be working great until I transferred the web site’s files via ftp. All the files transferred but I kept getting a blank page on the front-page. I could access the administrator section just fine, but the front page ALWAYS showed blank. I ended up finding some articles on google saying that it is because of the PHP version or because of the MySql version. Even after changing the PHP and MySql versions on my hosting account it still continued not to work. I wasn’t able to get any debug information out of joomla and couldn’t even get php to report errors in the log file. Well, finally I took a stab in the dark and removed ALL files from my website and re-uploaded them. It worked. I was hesitant to do this initially because there are so many files and it takes a long time to upload. I found the best way around this is to package up all your files into one .zip archive and upload them onto the server, then use an SSH client such as putty to connect to the server and extract the archive right on the server. This is MUCH quicker.

Making a Component

So, there are TONS of components on Joomla’s extensions directory. I have been able to accomplish 90% of what I have wanted to do with even just the free components available for Joomla. However, I found one case where a component (even to pay for) wasn’t already made (at least not easily accessible). There are plenty of components that come relatively close to what I needed, but I generally found that with Joomla components you don’t really want to make changes to them. Not only is it someone else’s (generally) un-documented component and that can be time-consuming to make modifications to as you aren’t familiar with the code – at least that’s my experience. Even beyond that though, what happens when they provide an update to the component? You can’t update to the latest version because you have changes in there that will get overridden… For the reasons stated previously I ended up developing my own component for Joomla – I also wanted to be able to say I can develop Joomla components if need be on a resume.

Developing the component wasn’t really all that bad. There was a bit of a learning curve but all-in-all it only took me three days (from Tuesday to EOD Thursday) to create a full working component that did exactly what I wanted it to do. I am confident now that I could develop the same component in a third of the time on top of it.

The components are all driven by the MVC (Model-View-Controller) pattern where the controller determines what view should be used, the view class determines what data is accessible to the template, and the model provides the data to the view (interacts with the database). I had a very hard time initially conceptualizing this in the PHP world (but mainly because I had been unfamiliar with OO PHP). The biggest quirk that I found with the component development was that you had to watch how it is that you name your classes for the model, view and controller. For example, if in the controller you set the view to “listContestants”, you have to name your class “EzDrawingViewListContestants” (format: “<<COMPONENT>>View<<VIEW_NAME>>”). If you don’t, then it doesn’t find the view and throws an error.

Joomla automatically associates the model (if available) to the view so that when you are working with the view code you can call the model code simply by $this->get(“Data”) (for example). Joomla will automatically route that call to the associated modelClass->getData() method. In order for this automatic association to happen though, you have to have your model named in a similar format to the view: “<<COMPONENT>>Model<<VIEW_NAME>>”. As an example, the model name I would use for the listContestants view would be: “EzDrawingModelListContestants”.

BUG: I ended up finding a bug in Joomla (which I never submitted, though I probably should). The bug is that you cannot have a view named “ViewXXXX”. Even though I created my view class as “EzDrawingViewViewContestants” it threw errors saying that my template could not be found. As it turned out, it was building the paths for my template directory based on a sub string of my view name. In this case, it was only removing the word “view” because it performed a lastIndexOf() (equivilant) on the class name to generate the directory name. So, it took “EzDrawingViewViewConestants” and last indexed on “view” to come up with “Contestants”. My directory was named “viewContestants”, not “contestants” and all failed.

Final Note

Overall, I was fairly pleased with my experience with Joomla. Some of my buddies that are also in the PHP world may hate me for saying it, (as they are avid Joomla-haters) but never-the-less, I didn’t mind it. I believe Joomla does a good job for your standard website. Using joomla I would likely be able to develop a full-blown website with most (if not all) of the functionality needed within a week. Now, I’m not saying I would use Joomla for custom web applications, but for most content-based websites, it’s great!

 

Posted in: IT

Leave a Reply

Your email address will not be published.

Humanity Verification *Captcha loading...