Writing a Joomla! Module

There is a lovely extension out there for adding attachments to an article. It lets you upload/download files from an article. You install the component and a plugin, and the plugin displays the list of attachments at the base of the article content. You can find that extension here.

There are quite a few tutorials on how to write a Joomla! extension of the HelloWorld variety. I thought it would be amusing to write one with a practical application, for a change. I want the list of downloadable attachments to appear in a module location rather than in the article content.

If you are logged in to this site, you can download the module we will be writing in this article.

Continue reading “Writing a Joomla! Module”

AJAX in Joomla!

You want a form that updates one selector based on the selection made in another selector. For example, in your form, the user might click on a link to generate a select of all the site users so he can choose one user to interact with. You don’t want the list of users on the form, initially, for whatever reason.

The obvious solution comes to mind – AJAX. How do you accomplish that in Joomla?

First, you’ll need a component to listen for the AJAX requests and supply the updated HTML information to the form. While you’re at it, you probably want to make the form part of the component, just to be elegant.

Joomla! 1.5+ is built on a Model-View Controller concept, which basically means we want to keep our data (the model) separated from the display of it (the view). The MVC paradigm is a way of breaking an application, or even just a piece of an application’s interface, into three parts: the model, the view, and the controller.

 

MVC

 

 

Continue reading “AJAX in Joomla!”

How do i enable page caching in Joomla?

Enabling page caching in Joomla!

Go to Site->Global Configuration-System.

Using file cache is the most efficient since it is faster to load a file than make a database call.

Be advised that some modules will appear to quit working when enabling cache. You can rectify this by telling each module to not use cache in the parameters for the module (on the right, in the bottom parameters box).

Enabling page caching

How do I recover my admin password?

Help! I can’t log in as admin!

or

I’ve been hacked! What do I do?

If you find yourself unable to log in to Joomla! as the super administrator, either because you’ve forgotten your login or because your system was compromised, don’t panic. If you have access to your database with phpMyAdmin (or any other interface) you can reset the password.

Browse to your phpMyAdmin screens and find the jos_users table. Look for the row that holds your Super Administrator. The default user id for a Joomla! Super Administrator is 62.

Finding the Super Administrator in phpMyAdmin

 Now, that you’ve located the Super Administrator user, click the little pencil icon (marked with the blue arrow in the image above) to open that row for editing. The password in the password field is actually a combination of three things: your md5 hashed password, a colon (:), and your md5 hashed salt. As a technical aside, the password is stored as a 32 character hexadecimal number corresponding to the password you entered when you (or in some cases your hacker) set the password. The password is encoded with the php md5() function. Follwoing the password and the colon is the salt, another hexadecimal number generated when you set the password initially, which is used to protect the system. A hacker my break the encdoing on a single password, but it would likely be impossible for him or her to do so on a salted password. The salt is a small string, not created by the user but rather by the system, so no one will know what it is.

Fortunately, the salt is not required to be part of the password for logins to work, but it is generated by the system when you create or change a password through joomla. What we will do is reset the administrator password to be the word “admin”. The md5 has for admin is “21232f297a57a5a743894a0e4a801fc3”. Once we change the admin password, we will want to log in and immediately change the password through Joomla! to anything else.

So, click that pencil icon and edit the row for the Super Administrator. Paste 21232f297a57a5a743894a0e4a801fc3 in the password field. Also, check the block field and make sure it is set to 0. You might double check the gid (group id) is still set to 25, while you’re there.

Changing the Super Administrator Password

 Now, click the Go button and browse to your /administrator location. You should be able to login using the username admin and the password admin. 

IMMEDIATELY- that means RIGHT NOW – change your password!!

 Go to Site->User Manager and select your administrator login from the list and open it to edit.

Changing a User's Password in Joomla!

 

Put in a new password and click the big Save button at the top right.

Now, if you were hacked, rather than if you just forgot the password, go back to your phpMyAdmin and look for any OTHER Super Administrator users that may have been inserted in the database and delete them.

Finally, if you’ve been to the jos_users table, and you don’t find ANY row that contains a Super Administrator account, then perhaps it got deleted. Don’t worry, you can create a new one.

Inside phpMyAdmin, click the SQL button where you can type in actual SQL commands.

Some phpMyAdmin’s will let you run commands in a sequence, separated by ; and some require this to be done in three steps. Paste these commands in that window to create a new Super Administrator user with password set to admin.

INSERT INTO `jos_users` VALUES (62, ‘Administrator’, ‘admin’, ‘your-email@email.com’, ‘21232f297a57a5a743894a0e4a801fc3’, ‘Super Administrator’, 0, 1, 25, ‘2005-09-28 00:00:00’, ‘2005-09-28 00:00:00’, ”, ”);

INSERT INTO `jos_core_acl_aro` VALUES (10,’users’,’62’,0,’Administrator’,0);

INSERT INTO `jos_core_acl_groups_aro_map` VALUES (25,”,10);

 

Manually Adding a Joomla! User

How do I install a new Joomla! template?

Installing a New Joomla! Template and Setting It As Default

From your /administrator link, go to Extensions->Install/Uninstall

In the Upload Package File area, click the Browse button to locate your new template on your local computer. Then, click the Upload File & Install button.

 Installing a New Joomla! Template

Now, browse to Extensions->Template Manager, and you should see your newly added template in the list. Check the tick box next to it, and click the Default button at the top right to set this new template to display on all pages (or rather all pages to which other templates are not specifically assigned)

Setting the Default Joomla! Template

 

If for some reason your server will not allow you to upload templates through the installer, you can simply unzip the template on your local machine somewhere and then ftp it up to your server into the /templates directory.

Adding Content in Modules in Joomla!

Creating a 2 Column Compare and Contrast Site

Perhaps you have a political discussion site, and you want to showcase articles in the Democrat camp on the left of your front page and articles from the Republican camp on the right. You want something similar to the Latest News and Popular modules but constrained to display content from only one category (or section).

I will demonstrate how to achieve this using a fresh Joomla 1.5.6 install and the default layout. We will also need an extension that allows us to constrain articles by category (or section).

Continue reading “Adding Content in Modules in Joomla!”

BreezingForms and Internet Explorer – Error

I recently had a form created with BreezingForms that worked perfectly in Firefox but failed to display in an Internet Explorer browser. The area of the page that should have displayed the form was blank, and the lower left corner showed the page was “Done” loading with an error on the page.

The error message read, “Can’t move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.”

Continue reading “BreezingForms and Internet Explorer – Error”

Integrating Joomla and SMF

I used the J2smf component from GMITC.

I modified the advanced.php to create an smf_member if no corresponding smf_member exists for the registered Joomla! user visiting the forum.

I had to modify the LogInOut.php to know what to do with the Joomla! password and salt.

Now it works like a champ! A registered Joomla! user who logs in and browses to the forums is silently logged in. If no corresponding forum account exists, one is created for the user. If a registered Joomla! user is not logged in and browses to the forums, and logs in through the forum login screen, he is silently logged in to Joomla!

Continue reading “Integrating Joomla and SMF”