Showing posts with label Joomla. Show all posts
Showing posts with label Joomla. Show all posts

If you'd like to let visitors select their language on your site, do the following in your index.php file



$lang_request = JRequest::getWord('lang');
$lang_choice = implode("-", str_split($lang_request, 2));
$currentSession = JFactory::getSession();

if(!empty($lang_choice))
{
$currentSession->set("langChoice",$lang_choice);
$lang =& JFactory::getLanguage();
$lang->setLanguage( $lang_choice );
$lang->load();
}
elseif($currentSession->getState())
{
$lang =& JFactory::getLanguage();
$lang->setLanguage( $currentSession->get("langChoice") );
$lang->load();
}



when user clicks on a link have your url like the following:
http://www.yoursite.com/?lang=de-DE or /?lang=en-GB

the lang would be stored in session so you don't need to worry about it anymore.

If you like to add 'Select Category' option to the option list you got from DB.



$db =& JFactory::getDBO();
$query = "SELECT id as value,name as text FROM categories WHERE parent_id > 0 ORDER BY name";
$db->setQuery($query);
$categories = $db->loadAssocList();
$begin_categories = array(array("value"=>0,"text"=>"Select Category"));
$categories = array_merge($begin_categories,$categories);
$lists['categories'] = JHTML::_('select.genericlist', $categories, 'categories', 'class="inputbox" size="1"', 'value', 'text', null);



I am not sure any better way to do with Joomla classes.

How to add jQuery to Joomla ?

The Joomla 1.5 is coming with Mootools therefore you might experience some conflict with jQuery now.
Just follow the way below to avoid any conflicts. Add the following lines to your view.html.php.



$document = &JFactory::getDocument();
$document->addScript( 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' );
$document->addCustomTag( '' );



The above code fragment would solve your problem.

How to add Javascript or css to your Joomla template?

Just do the following to get it working. Add the following lines to your view.html.php.



$document = &JFactory::getDocument();
$this->document->addStyleSheet('your path/style.css');
$this->document->addScript( 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' );


That would solve your problem.

This is how you add a calendar / date picker to Joomla form.

add the following code to your
xx.html.php class



$document = &JFactory::getDocument();
$document->addScript("includes/js/joomla.javascript.js");

JHTML::_('behavior.calendar');



and add the following code to the default.php template file








All those codes above will have a calendar / date picker close to the input field.

Enjoy your coding.

Modify User Registration of Joomla

If you'd like to change user registration page of Joomla, follow the following steps to accomplish it.

1) Change in template file (under components/user/)
2) modify /libraries/joomla/user/user.php
3) modify /libraries/joomla/database/table/user.php

and also modify users table of joomla using any db admin scripts eg:phpMyadmin

Modify those files as per your request, you will see a modified user registration page of Joomla.

htaccess issue with SEF URL in Joomla

On your developer box: You enabled SEF in Joomla by doing the following way:

1.rename htaccess.txt to .htaccess
2.Global Configuration -> SEO Settings (set yes to everything) and save it

Refresh your Joomla site
click on your site links - if the short url is working then everything is cool if NOT

open up your Apache config file and

add the following lines to your virtual host setup

        
AllowOverride all


save the config file and restart the apache.
DONE.



Some Links (off programming)