Category Archives: Blogroll

How to edit a Joomla template with Firefox

Important Notice: This blog is now going to be updated more often on www.conticreative.com. Come and visit my site at ContiCreative.com for blogs, software, books and utilities reviews, tips and tricks and more.
I am looking forward to your visits there – Conticreative

When I first discovered Joomla! when it was still Mambo, my first question was: “How the heck am I going to edit the template?”

I think this is pretty much the first question any traditional web designer has when they first try to work with a CMS. It’s natural. We are used to a Top down style of designing the page and then inserting the content, Joomla is the opposite. The content is there, but the design, even the excellently designed Ruck Solarflare, is the first thing we must change if we want to make an original website.

I came up with two distinctive systems for dealing with Joomla templates, one uses the excellent Firefox Web Developer plug in and the other is a more traditional approach using Macromedia Dreamweaver as a css editor. Both assume that the web designer reading this article is interested in having some sort of visual feedback when editing CSS files.

This article is about using Firefox and how it can be edit many aspects of a Joomla template. Using the Firefox Web Developer extension is, to me, a bit more laborious and confusing than using Dreamweaver, but it is more immediate and less convoluted at times. Let’s get going.

First you’ll need to install Firefox if you don’t have it. At the time of this writing version 2 has just been released. There is a “Developer Version” of Firefox available here. Next, if your Firefox version doesn’t come with the developer plug-in you should download it ;here.

A Joomla template is usually made up, at the very least, of a Folder containing an index.php file, a css file inside the css folder called template_css.css, a XML file and an images folder. If the template has any js files or any additional css file they will be respectively in the script and the css folders.

As much as possible, Joomla templates try to separate the content from the presentation and use DIVs and CSS files. Since Joomla pages are created dynamically and they don’t “exist” as separate HTML pages using css for style is a necessity, not a choice. Nevertheless, many Joomla templates use a fair amount of tables in the layout and Joomla itself uses quite a bit in the generation of the page elements.

Most of the changes in a Joomla template can be done using the css file. Because of the way that Joomla works, the index.php file, in its raw format before is processed by Joomla may look quite messy and often template designers use a fair amount of conditional PHP code to allow Joomla to place page elements in a certain position. This is not a difficult proposition as the following example illustrates.

<?php if ( mosCountModules (‘banner’) ) { ?> <div class=”classname”> Content or PHP module call</div> <?php } ?> <div class=”classname2″> Content2 </div> What this says in essence is: IF (the module is present in this position) THEN (display this here) ELSE (Display this content)

A good Joomla template, such as the ones offered by Joomlart.com, will have many conditional statements as well as several Javascript elements to facilitate the use of CSS menus and other features. They will also use CSS to style most of the containing <div> and other XHTML elements making the developer’s plug in in Firefox an ideal tool for CSS styling.
Once the plug in is active, load the home page of your site (or any other page you want to work on and got to Tools > Web Developer > CSS > Edit CSS (Ctrl-Shift-E) and the CSS file(s) for the web page will display in the left column.A Joomla template can have multiple CSS files attached to it, but the main file is template_css.css. In the edit CSS column of display div orderFirefox each CSS file has it’s own tab allowing you to edit any file you wish.Any changes to the CSS file are immediately reflected in the actual window, making the process very fluid and natural. An intimate knowledge of CSS syntax is necessary, since there aren’t yet any advanced tools such as the ones offered by Macromedia Dreamweaver or other CSS editing tools
displayblocksize. Every change has to be made by hand, including Hex color values. One other drawback, one that hopefully will change in the future, is the lack of any color coding of the syntax.Any change made in the CSS file is limited to the local copy of the page, and until the CSS file is saved, going to a new page in the site may clear any change made so far. It is easy to click on a link by mistake and lose an entire session. The CSS file should be saved often as a precaution.While this is a very nice way to edit the CSS file of your Joomla site, it has its drawbacks: It is hard to find the tag both on the page and in the CSS file. For this, the developer plug-in can come to the rescue once again. There are several tools that help greatly in identifying the various HTML elements in the page. Under the Information menu (Tools > Web Developer > Information) there are a number of useful tools such as: displayblocksize

  • Display Block Size
  • Display Element Information
  • Display ID and Class details
  • and more.

These are invaluable in identifying the block elements. Finding them in the CSS file is another story and again this is the weaker point of this system.Ultimately, we will want to save these changes to our Joomla Website, we can do that easily by simply uploading the CSS file on the server. The changes should reflect nicely and the file can be edited again and again.inspect elementFirefox has a number of plug-ins, beside the Web Developer toolbar that are useful for working with Joomla. There is a competent FTP plug-in, a DOM Inspector, a variety of CSS editors and other plug-ins that perform similar functions to the Web Developer Plug-in but with subtle differences that in same cases may be useful. One Plug-in I find very useful in conjunction with the WDT is Firebug. It is 2.0 compliant and it shows a hierarchical view of the page structure with collapsible elements in a pane below the main window.I hope you found this article useful and that you’ll let me know how I can improve it.Happy coding.The conticreative blog is also available at conticreative.com. Conticreative is a Web Agency specializing in Joomla, Zen Cart and OScommerce integration. We also provide professional product photography, SEO services,Managed hosting and training. This article available here

Advertisements

Memory_limit problem in Joomla with Community Builder

Check out my new website where I am now maintaining all my blogs.
Thank you.
Marco Conti

Working with Joomla! is very exhilarating and there is a tendency, when you work on your site, to want to test all the different modules available. Some of them have some really crappy code, others are simply not compatible with one of the other modules. Inevitably, problems will arise. I had almost finished building my site,  when it crashed big time. At that point I decided to install it again from scratch making sure to document and back up every step of the way, a practice I follow religiously when I work for a client but that I sometime ignore when working on my own site. Big mistake.

Everything was going fine until i installed Community Builder, a great app for building communities with Joomla, and I linked it with Joomlaboard, a light weight forum that is actually quite useful and even powerful if not the prettiest out there.

I tested the site and it worked fine until I went for dinner. At my return, trying to view my profile as a user in the front end gave me this error message:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to
allocate 184320 bytes) /-/-/-/-/mod_filename.php

The rest of the page was a blank. I did a quick search in the various forum, starting with joomlopolis, the makers of the Community Builder script for Joomla.

There I found several mentions of this problem but no solutions. In fact, the tech guys seemed to be annoyed at us posting about this problem Their not very useful replay was “Google it“.
From there a gathered that the CB scripts exceeds PHP assigned memory allocation on a given server, and the only cure it seems is to allocate more memory in the php.ini file of the server and restart.
For users on shared servers this is simply not an option. In some cases it may be possible to ask, but more often than not you’ll get a “buy a dedicated server” answer.
What makes this problem very bad is that my site currently is in testing and only my cat, Scruffy, and I know it’s operational. If it runs out of memory with one user, can you imagine what it will do with (Gasp!) 10 or 20 users concurrently?
Eventually I searched the Joomla forum and found out a bit more, but it was while searching Google for “Fatal error: Allowed memory size of 8388608 ” that I hit pay dirt.

I found a post that suggested increasing the memory allocation in the server to 12 MB in the .htaccess file with this script:

memory_limit = 12M

When I tried it my server crashed miserably, but eventually I came across a post on the Drupal forum where they suggested to either do the same thing with the .htaccess file or to place this line

ini_set(‘memory_limit’, ’12M’);

in Drupal’s sites/default/settings.php file (here is the link to the post )
Armed with that info, I decided to try something crazy and I inserted the same line of code in configuration.php file of my Joomla installation. What did I have to lose?
I was expecting some sort of server error again, but instead I reloaded the page in my browser and clicked on the “profile” page link that was giving me the error

Allowed memory size of 8388608 bytes exhausted

and it worked like a charm. Pure magic!
Just to make sure I wasn’t hallucinating, I commented out the line and tried again : the error appeared again, so my fix was working fine.

However, I was about to encounter another problem. Joomla rewrites the configuration.php file each time it is accessed from the Cpanel. That means that my little, miraculous line of code was getting erased on a regular basis.

Fortunately, in the same post there was another small hack: entering this line

memory_limit = 32M

in the php.ini file in the root folder of the Joomla installation. When I tried that the first time, like the .htaccess file it did not work. However, just in case I could have made a mistake, I tried again. This time it worked and what’s more it’s sticking.
Apparently, this error is quite frequent and I am surprised that, at least in the Joomla arena, I seem to be the only person to come up with a workable solution. This problem, according to the Joomla forums has gone unsolved for quite some time.

Below is the post I contributed to in the Joomla forum, in case you’d like to learn more about this bug.
I hope this article will help others find a quick solution to their Joomla memory error problems, but be warned: not all shared hosting servers administrator will be happy with you if you start messing up with their memory allocation.
I do have a feeling that his little fix my even have the result of speeding up your Joomla installation a bit. after all, it increases the memory allocation for every script, not just the CB Login ones.
Always make sure to back up any file you change or you are asking for trouble.
Original Joomla forum post:
About Memory_limit and fatal errors

Good Luck and thank you again for reading this blog

Marco is a Sacramento based web designer/developer.
Marco’s company is conticreative.com a full service
web agency specializing
in e-commerce and Content management system development, photography, web
marketing and copy writing.