Wednesday, July 20, 2011

Why Joomla Override?

When i was working at Diligent Tech, i used to hack extensions files directly, might be my seniors did not about know the term 'Override' or they haven't informed me. When i joined Tekdi Web Solution, I come to know disadvantages of hacking core files. Override is the great solution for hacking core files. So I'm just posting about why override instead of hacking files.
When you want to upgrade Joomla component or module installed on your site. You uninstall it & install that component or module with latest version or you can directly install the upgraded version. This means that the changes you made in core files of the component or module will be lost if you don't have a back-up. It's also more difficult to keep track of the files that you have customized. With the override functionality you can place your customized files in a template folder which is of course outside of the component or module to keep all your customization in one place and safe from upgrade losses. So that your colleagues will get in which files you have made change.
But one more thing you should check the file differences when there is an upgrade, because there might be bug fixes in your modified files, but now you can easily keep track of which files to check. Instead i write about how to override joomla core files please check this link http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core.

Wednesday, July 13, 2011

JReview - How to unpublish the listing according to the end date

I am working on one of the site 2Lush Cru, a Joomla based site from last month. JReviews componet is used to show the liting of wines & there is a field 'offer end date'. Depend on the 'offer end date', listing should be closed automatically. Its not JReviews's built in functionality. The problem is Jreview store some data of listing as an article(content table). There is field for article end date(publish_down) in Joomla, so i wanted to store offer end date of JReviews in a article(content) table so that it closes according to the close date.
Initially i thought, view is already overidden, after written some query's it will work. Invested 3-4 hrs. but it didn't worked. Finally got a solution, oerride a JReviews listings controller(listings_controllers.php) where it stores data. I was not aware how to override JReviews controller, This page came to help me.
In listings_controller.php on line no 1343 pasted this code
$this->data['Listing']['publish_up'] = $this->data['Field']['Listing']['jr_opstartdate'];
$this->data['Listing']['publish_down'] = $this->data['Field']['Listing']['jr_openddate'];
Remember jr_opstartdate & jr_openddate parameters will be changed acccordingly the names you have set for the field(joomla admin site, field manager).

Monday, June 27, 2011

Chronoforms

Last couple of days was working on Chronoforms a Joomla extension used to create forms. I found something interesting as compared to other form extensions.
Using the form wizard one can create form easily, but you need to make change in form designing to fit the look of your form to the site. This is quite tedious task(atleast for me). Most things i like about the chronoform is the ability to setup the email & email template. You can execute bit of php code any time you want like before form submit, after form submit, before mail send, after mail sent. If you wanna store form details in database, chronoform provides ability to create table. I would to suggest, should use chronoform whenever email setup & email templates has higher priority. At the end its free.
Whenever need to create forms in joomla, you should have to think of Chronoforms.

Thursday, June 16, 2011

How to Create Joomla Select Box

How to create select box in joomla.
Simple Select box

$names = array(0 => "Select Name", 1 => 'Amit', 2 => 'Amit', 3 => 'Ajeet', 4 => 'Amar');
$options = array();
foreach($names as $key=>$value)
{
$options[] = JHTML::_('select.option', $key, $value);
}
$simple_dropdown = JHTML::_('select.genericlist', $options, 'name', 'class="inputbox"', 'value', 'text');
echo $simple_dropdown;

In joomla development, many time you need to show dynamic select box with the values from database.
Joomla drop down with values from database

$db = JFactory :: getDBO();
$query = "select * from #__users";
$db->setQuery($query);
$result = $db->loadObjectList();
$options = array();
$options[] = JHTML::_('select.option', '0', 'Select Name');
foreach($result as $row)
{
$options[] = JHTML::_('select.option', $row->id, $row->name);
}
$dropdown = JHTML::_('select.genericlist', $options, 'class="inputbox"', 'name', 'value', 'text');
echo $dropdown;

To select default option
$default = 62; // make sure this value must match
$dropdown = JHTML::_('select.genericlist', $options, 'class="inputbox"', 'name', 'value', 'text', $default);
echo $dropdown;

To use radio button instead of dropdown
$radio = JHTML::_('select.radiolist', $options, 'class="inputbox"', 'name', 'value', 'text', $default);
echo $radio;

To use radio button with newline.
add this line
$radio =str_replace('</label>','</label><br />', $radio); before echo $radio;
You can read more here.

Thursday, June 2, 2011

Best way to calculate the difference between date time

As a developer we always need to compare dates(with time or without) & get the no. of days, years, weeks, hours, minutes, seconds according to the requirement. So that why shoudn't a function which does all these. With the help of this function you can get the difference between two dates or times very easily. Whole code is written in php.

Saturday, May 28, 2011

How to disable Joomla Component

Well let me elaborate the difference between disable & uninstall Joomla component first.
Uninstall component means to remove the component from the Joomla site. If you don't want to use a component in your Joomla site then you have to uninstall it.
Disable component means you are not interested in the component right now but may be in future you want to use it, in such situation you have to disable it.
In short Joomla just restricts the disabled components from showing the output. Whenever you want to use the disabled component you just need to enable it.
Doing this doesn't require coding, there is option for this at the backend. Here is the image. When i wanted to disable the component first time, then i was wondering that i need to make the change in coding.

Wednesday, May 18, 2011

Easy way to get backup your joomla site

There are many other ways to get joomla backups but i think this is the easiest way. You need to install Akeeba Backup, don't worry its free. After that go to Configuration(Akeeba Backup) Change the Archiver engine from JPA format to Zip format from Advanced configuration, save this setting.
Click on the 'Backup Now' option n follow the procedure. At the end you will get backup. Download that zip file & keep it in root folder. After that open it in browser n follow the procedure you will get copy of your Joomla site. You will get a fresh backup at any time with help of this extension.