Tag Archives: Joomla 1.5

Inserting and Updating Records Using JDatabase in Joomla

When your doing simple single table inserts and updates you can use the JDatabase methods to do so. The advantages of using the JDatabase methods is it saves you time from hand coding your sql and will escape and correctly quote your inputs for you. The following will insert a new record into a table: […]

Loading an User Object with User Name or User ID in Joomla

You can load a specific user object with just the user name or user ID when using the getUser() method. $user = JFactory::getUser(‘username’); $user = JFactory::getUser(55);

Making custom drop down list using JHTML in Joomla

You can use the JHTML helper library to draw a custom drop down lists. JHTML::_(‘select.genericlist’, $dataArray, $name, $attributes, $valueField, $textField, $selectedValue); The $dataArray must be an associative array like this $arr[] = Array(‘val’=>1,’text’=>’Jan’); $arr[] = Array(‘val’=>2,’text’=>’Feb’); The $name is the name you want to give the drop down list. The $attributes are the list properties […]

Displaying Raw Output in Joomla 1.5 by Setting Format in the Component

The most common way to produce raw output in Joomla is to pass the format= raw parameter in the url. Joomla has four supported document type objects: html, pdf, feed and raw. When passing no format parameter the default is html. Html format is just the normal html output. This article covers the use of […]

Loading Joomla Modules in the View

You can render modules within a view layout file. Rendering a module position The following will load a module into a layout file. e.g. views/category/tmpl/default.php It will honor whatever parameters have been set for this module in the backend and whether or not it is activated for the current menu item. $document = &JFactory::getDocument(); $renderer […]

Auto Loading Classes in Joomla

Joomla has its own way of including class files when needed. You can use the JLoader::register() function to register your class files. When you need to create an instance of the class it will load the class file using the file information in the register. You can register your class files like this JLoader::register(‘MyClass’, ‘somepath/myclass.php’); […]

Creating Custom Titles for Your Joomla Pages

In the templates that are included with Joomla the title in the title bar is taken from each page menu item page title property. You can override this behavior within the template’s index.php file by using the JDocument setTitle() function. Right after where the head section is included you can add these following lines to […]

Modifying the Head Section In Your Joomla Page

There are two ways you can modify what is written to your head section. Use the JDocument methods to insert meta and script tags in the head section. Hard code the meta and script tags directly in the template index.php file. This article is about option number one. You first need to get an instance […]

Preventing Sql Injection in Joomla

Joomla JDatabase class provides the quote() method that will correctly quote and escape your sql input strings. This method will prevent sql injection attacks. You can write your sql injection safe statements like this: $sql = ‘INSERT INTO table (field) VALUES (‘.JDatabase::quote($param).’)';

Get Joomla 1.5 User Access Level

This will get the user object which can be used to retreive user’s access level code. This code is in the gid field in jos_users table. $user = &JFactory::getUser(); $access = $user->get(‘gid’,0); Group access level codes: Backend Admin Access 25 – Super Administrator 24 – Administrator 23 – Manager Front End Access 21 – Publisher […]