Friday, August 12, 2011

Jomsocial checkbox, radio buttons tooltip & validation bugs & solution

Have Joomla site?
Installed Jomsocial Component?
Created checkboxes or radio buttons using custom fields?
Suffering from checkboxes & radio buttions tooptip & Validatation of these fields wokring after submitting form(basically functionality should be to have alertbx with error message like other inputs). Then you must read this post & follow all the steps.

These are the Jomsocial bugs. You can find these bugs in latest verison(2.2.4) also don't know why these guys haven't sorted out yet. We were suffering from this problem for 2Lush cru site. We told client its Jomsocial bug but as usual, he was not ready to accept & told to do whatever to solve these issues. I know, this issue was in PMS from last 1-2 months no one was able to solve it.

If you want to sort out these bugs the you need to hack the jomsocial files cause you can't override these files which you need modified. Dont worry it won't affect your jomsocial at all.

To remove empty tooltips from check box fields.
go to file components/com_community/libraries/fields/checkbox.php
line no. 36
$cclass = ($field->required == 1) ? ' required validate-custom-checkbox' : '';
line no. 60
Change only class name
$html .= 'input type="checkbox" name="field' . $field->id . '[]" value="' .
$option . '"' . $selected . ' class="checkbox '.$class.'" style="margin: 0 5px
5px 0;" />';
change to
$html .= 'input type="checkbox" name="field' . $field->id . '[]" value="' .
$option . '"' . $selected . ' class="checkbox '.$cclass.'" style="margin: 0 5px
5px 0;" />';

Validation of checkbox
line no. 44
$class = !empty( $field->tips ) ? 'jomTips tipRight' : '';
change to
$class .= !empty( $field->tips ) ? ' jomTips tipRight' : '';
public_html/components/com_community/libraries/fields/radio.php

Same for radio button validation
go to the file components/com_community/libraries/fields/radio.php
Just update file as above.

Sunday, July 31, 2011

no configuration file found and no installation code available. exiting...

Yesterday i was installing joomla here. First i pasted the joomla installation files on server & extracted that folder. I have already created database cause i know at the time of installation it asks for the database details. After that i opened the url in a browser for further procedure. After all installation removed installation file. When i try to see the joomla site, saw this error message " no configuration file found and no installation code available. exiting..." but there was a configuration file & installation folder which i had deleted. I opened cofig file & check the database details into the file. Database details entered, during installtion procedure were not updated into cofig file(permission 644) thats why it was showing error. Finally i corrected file with database details & it worked. A simple way you can rename the file configuration.php-dist to configuration.php. A browser tab was opened with the search list of this error, after finishing my work i try to search for the solution where i could not get easy & exact answer even on joomla forum also. So i have posted regarding this. Hope this helps somebody..

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.