Monday, April 19, 2010

Joomla solutions extension for dreamweaver

http://www.joomlaspots.com/Addons/joomla-dreamweaver-extension.php

Monday, April 12, 2010

How to use DATE_FORMAT() in mysql

$query = "SELECT DATE_FORMAT(DATETIME,'%m/%d/%Y') as NewDate,id FROM TableName ORDER BY DATETIME DESC";

result:
month(numeric)/day(numeric)/year(numeric)..

cheers :)

How to decode json response in ExtJs

//when json response is in this format {"success":true,"data":{"id":11}}
Ext.Ajax.request({
url:'connect.php',
params:{moduleId:moduleId, status:'insert',activity:'save',action:'doAction'},
success:function(res){
var response = Ext.util.JSON.decode(res.responseText);
alert(response.data.id);
}
});

Thursday, April 8, 2010

paging in PHP


$count_rec=400; //give here the total number of records
if($count_rec>0) {
$total_pages=ceil($count_rec/20);
$page=$_REQUEST['page'];
$start=($page-1)*20+1;
$end=$start+19;
$x=$start;

//foreach ($photosetList[photoset] as $setList) {
//$sizes = $f->photos_getSizes($setList[primary]);

if($end%$x<=19) {
echo "";
}
//}
}
echo "
";

if($end>$count_rec)
{
$end=$count_rec;
}

if($page==1)
{
echo "<<";
}else
{
$back=$page-1;
?>

<a class="anchorlink" href="pagingPhp.php?page="><<<</a>



$val=ceil($count_rec/20);
echo "Page :- ".$_REQUEST['page'];
if($page==$val)
{
echo " >>";
}else
{
$next=$page+1;
?>
<a class="anchorlink" href="pagingPhp.php?page=">>></a>

Saturday, April 3, 2010

ExtJs dataview refresh problem

[code]Ext.getCmp(dataview id).getStore().load({params:{}});
or
Ext.getCmp(dataview id).getStore().reload();

By using this code your dataview automatically be refreshed.[/code]
[b]NOTE: The response only come in the pure json format[/b]

If you will use this in PHP for fetching the data for
dataview you must declare $json_data['templateItems'][]= $row;
in case of no result found. Otherwise your data view not working correctly.
[code]
$result= mysql_query($query);
$json_data['templateItems'] = array();
while($row= mysql_fetch_assoc($result)){
$json_data['templateItems'][]= $row;
}
echo json_encode($json_data);exit;[/code]

[b]Data view code[/b]
[code]new Ext.DataView({
store: new Ext.data.JsonStore({
url: 'connect.php',
baseParams: {moduleId:moduleId,action:'doAction',activity:'getTemplateCats'},
autoLoad:false,
root: 'templatecats',
fields: ['templatecat_name','id']
}),
tpl: new Ext.XTemplate(
'',
'
{templatecat_name}
',
'
'
),
listeners : {
click : function(dataView,index,node,e) {
var record = dataView.getRecord(node);
var cat_name =record.get("templatecat_name");
var cat_id =record.get('id');

Ext.getCmp('cat_id_temp_s').setValue(cat_id);
Ext.getCmp('newCardS').getLayout().setActiveItem(1);
Ext.getCmp('s-templates-items').getStore().load(
{params:{moduleId:moduleId,action:'doAction',
cat_id:cat_id,templatelocation:'subjective',activity:'getTemplates'}});
}
},
id:'s-templates',
autoHeight:true,
multiSelect: true,
overClass:'x-view-over',
itemSelector:'div.thumb-wrap',
emptyText: 'No templates to display'
})[/code]