Monday, April 30, 2012

Create collapsible content area in joomla


open selected template index.php file and put below code where you want to collapse div.

<div id="content">
     <?php if($this->countModules('content_right')) : ?>
       <div id="content_left"><jdoc:include type="message" /><jdoc:include type="component" /></div>
     <?php elseif(!$this->countModules(' content_right ')) : ?>
       <div id="content_full"><jdoc:include type="message" /><jdoc:include type="component" /></div>
     <?php endif; ?>

Friday, April 27, 2012

Some Important syntax of Joomla

Here are the some codes to help the joomla developer..


login user details 


$user =& JFactory::getUser();
echo $user->id;
echo $user->username;
echo $user->name;
echo $user->email;
echo $user->usertype;
echo $user->guest;
echo $user->get('aid'); // access Guest 0, register 1

Display JSON data

Create a function to get data json data.

function getjson(){
var url = "https://sitename/getdata.php";
requestCrossDomain(url, function(results)
{


// result = {" resultdata ":[{" imgname ":"2147512358.jpg"," name ":"bhumika"},{"imgname
//                  ":"2411827535.jpg"," name ":"rahul"}]}

var myJSONObject1 = eval('(' + results + ')');
if(myJSONObject1== null)
{
return false;
}
$('#content_home').html(CreatedataView(myJSONObject1.resultdata)).fadeIn();
});
return false;
}

Monday, March 19, 2012

Pass all the Form elements to call JSON


If you call any server file on the live server to get json data, then may be you need to transfer some variables with value. for ex. if you need to insert data to your server then you must haveto post all data to server file.

First you need to follow my previous blog(get-data-using-cross-domain-request).

Create one form element and create all the variable into the form tag that you want to post on the server.
Create below function in the .js file.

function createQuery(fname)
{
     var formname= fname;
     var elements = document.getElementById(formname).elements;
     var pairs = new Array();
var next_el = "";
var checkdetail=""
    for (var i = 0; i < elements.length; i++)
   {

Saturday, March 10, 2012

Get Data using Cross-Domain Request

There is a two methods to get data from the url. one is XML and second is the Json. the xml methods is very complicated and large. that's why I started to use json format for the cross-domain request.

Create cross_domain.js file

function requestCrossDomain( site, callback ) {
     if ( !site ) {
          return false;
     }
     var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from html where url="' + site + '"') + '&format=xml&callback=?';
  $.getJSON( yql, cbFunc);

  function cbFunc(data) {
     if ( data.results[0] ) {