Pages

Showing posts with label Using. Show all posts
Showing posts with label Using. Show all posts

Sunday, August 24, 2014

Zend-Using ZendX library in Zend

Recently I had to use Jquery UI components in one of my applications.I used ZendX Library to counter the same and I worked upon the same as the same as follows

 In bootstrap.php

       protected function _initJquery() {  
     $view = Zend_Layout::startMvc()->getView();  
     $view->addHelperPath("ZendX/JQuery/View/Helper",  
                 "ZendX_JQuery_View_Helper"  
                );  
     Zend_Controller_Action_HelperBroker::addHelper(  
               new ZendX_JQuery_Controller_Action_Helper_AutoComplete()  
                );  
     $view->jQuery()  
        ->enable()  
        ->setVersion('1.11.0')  
        ->setUiVersion('1.10.4')  
        ->addStylesheet('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css')  
        ->uiEnable();  
   }  

In View

 <?php  
 $this->jQuery()->addJavascriptFile($this->baseUrl().'/assets/js/validation/jquery.validate.min.js');  
 $this->headScript()->prependFile($this->baseUrl().'/assets/js/validation/myvalidation.js');  
 ?>  

Layout

 <?php   
 echo $this->jQuery();  
 echo $this->jQuery()->uiEnable();  
 echo $this->headScript();  
 echo $this->headLink();  
 echo $this->headTitle('My Website');  
 ?>  

Sunday, June 9, 2013

Cakephp-using Timthumb in cakephp

Using TimThumb in cakephp

Timthumb library is used to generated required sized images on the fly..it produces images of required size which are stored in its cache as such page is loaded much faster...

Timthumb can be easily downloaded from

http://timthumb.googlecode.com/svn/trunk/timthumb.php

Download the file and place it in

/webroot/files/timthumb.php

create a folder called cache with permissions "777" under the same folder.

now use the following code to echo images via timthumb

 echo $this->Html->image('/files/timthumb.php?src='.WWW_ROOT.'/img/imgname.jpg&w=63&h=63');  


this will convert any size image to 63X63 on the fly...you see more options of this library to make a better use of the same.

Sunday, July 8, 2012

cross domain request using jquery

Unfortunatly cross domin access is not available to functions placed in other domain in a json file that return data.

One way out is to show the same in a .php file or an .asmx page but what if we want the interface to be platform independent...



The way out is to host JSON services using jsonp or "JSON with padding"



http://en.wikipedia.org/wiki/JSONP



To make a cross domain Json request use the following Jquery function



http://api.jquery.com/jQuery.ajax/

Tuesday, July 3, 2012

Jquery conflicts with Prototype

Use $$=jQuery.noConflict();

that's all

and then for all JQuery $ use $$

example

for $("#sdf")  use $$("#sdf")

Generate Excel Report with Php and Mysql using code

Step 1. Include phpexcel class file along with your config file and make its object with excel file name passed parameter in constructor. You can check for  error in next line as shown

1require_once("excelwriter.class.php");
2
3$excel=new ExcelWriter("report.xls");
4
5if($excel==false)
6echo $excel->error;


Step 2. Now time to fetch data from mysql database. Before fetch data, call excel header having columns as values of array.

01// this will create heading of each column in excel file
02
03$myArr=array("S.No.","Company Name","Email","City","Username","Reg. Date");
04$excel->writeLine($myArr);
05
06// now fetch data from database table, there is a new line create each time loop runs
07
08$qry=mysql_query("select * from customer");
09if($qry!=false)
10{
11 $i=1;
12 while($res=mysql_fetch_array($qry))
13 {
14 $myArr=array($i,$res['company_name'],$res['email'],...);
15 $excel->writeLine($myArr);
16 $i++;
17 }
18}


Step 3.  Create link to generate excel file.
1<a href="javascript:void(0);" onClick="download();">Download Excel Reporta>
and here download function pointing to excel file
1
 Download Code Here