How does one add a ‘plain text node’ to a zend form?


Zend has a form note view helper (Zend_View_Helper_FormNote), which you can use to add text.

Just create a new form element (/application/forms/Element/Note.php):

class Zend_Form_Element_Note extends Zend_Form_Element_Xhtml { public $helper = 'formNote'; } 

In your form:

$note = new Zend_Form_Element_Note( 'test', array('value' => 'This is a <b>test</b>') ); $this->addElement($note); 
Advertisements

Pagination of cakephp


1. Digital Pagination:

<?php echo $this->Paginator->first(__('First', true), array('class' => 'disabled'));?>
|     <?php echo $this->Paginator->prev('<< ' . __('Previous', true), array(), null, array('class'=>'disabled'));?>
|     <?php echo $this->Paginator->numbers(array('class' => 'numbers', 'first' => false, 'last' => false));?>
|     <?php echo $this->Paginator->next(__('Next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
|     <?php echo $this->Paginator->last(__('Last', true), array('class' => 'disabled'));?>

2. Alphabetical Pagination:

Add input field in Zend Framework


Text Field:

$title = new Zend_Form_Element_Text('title');
$title->setLabel($this->_trans->translate('lblTenantRentalTitle').' * :')->setRequired()->setOrder(1)
->setAttribs(array('class' => 'post_input_text', 'id' => 'text_title'))
->addErrorMessage('Title is required!');
$this->addElement($title);

Text Area:

$detail = new Zend_Form_Element_Textarea('detail');
$detail->setLabel($this->_trans->translate('lblTenantRentalDetail').' * :')->setRequired()->setOrder(2)
->setAttribs(array('cols' => 50, 'rows' => 5, 'class' => 'post_input_textarea', 'id' => 'text_detail'))
->addErrorMessage('Detail is required!');
$this->addElement($detail);

Select Option:

$rental_type_id = new Zend_Form_Element_Select('rental_type_id');
$rental_type_id->setLabel($this->_trans->translate('lblTenantRentalType').' * :')->setRequired()->setOrder(3)
->addMultiOptions($rental_type_list)
->setAttribs(array('class' => 'input input_select select_rental_type_id', 'id' => 'select_rental_type_id'))
->addErrorMessage('Position is required!');
$this->addElement($rental_type_id);

Check Box:

$is_price_per_sqfeet = new Zend_Form_Element_Checkbox('is_price_per_squre_feet');
$is_price_per_sqfeet->setLabel($this->_trans->translate('lblRentPerSquareFeet').' :')->setOrder(27)
->setValue(array_search($boolean_options_no, $boolean_options))
->setAttribs(array('class' => 'input input_checkbox checkbox_is_price_per_sqfeet', 'id' => 'checkbox_is_price_per_sqfeet'));
$this->addElement($is_price_per_sqfeet);

Radio Button:

$is_security_deposit = new Zend_Form_Element_Radio('is_security_deposit');
$is_security_deposit->setLabel($this->_trans->translate('lblSecurityDeposit').':')->setOrder(35)->setSeparator(' ')
->addMultiOptions($boolean_options)
->setValue(array_search($boolean_options_no, $boolean_options))
->setAttribs(array('class' => 'input input_radio', 'id' => 'radio_is_security_deposit'));
$this->addElement($is_security_deposit);

Input Type File:

$image = new Zend_Form_Element_File('image');
$image->setLabel($this->_trans->translate("lblImage").':')
->setAttribs(array('class' => 'input input_file file_image', 'id' => 'file_image'))
->addValidator('Count', false, 1)->addValidator('Size', false, 52000000)->addValidator('Extension', false, 'jpg,jpeg,png,gif')
->addErrorMessage('Image is required!');
$this->addElement($image);

Input Type Submit:
$submit = new Zend_Form_Element_Submit('save');
$submit->setLabel($this->_trans->translate('btnSave'))->setDecorators(array('ViewHelper'))
->setAttribs(array('class' => 'input input_button btn_submit btn_black_normal', 'id' => 'btn_submit'));
$this->addElement($submit);

Input Type Button:
$cancel = new Zend_Form_Element_Button('cancel');
$cancel->setLabel($this->_trans->translate('btnCancel'))->setDecorators(array('ViewHelper'))
->setAttribs(array('class' => 'input input_button btn_cancel btn_black_normal', 'id' => 'btn_cancel'));
$this->addElement($cancel);

Date:

$lease_start = new Zend_Form_Element_Text('lease_start');
$lease_start->setLabel($this->_trans->translate('lblStartDate').' * :')->setRequired()->setOrder(50)
->setValue($today->format("Y-m-d"))
->setAttribs(array('class' => 'post_input_text_with_checkbox', 'id' => 'text_lease_start'))
->addFilter('StripTags')
->addErrorMessage('Start Date is required!');
$this->addElement($lease_start);

How to create virtual host using Apache


Just go to \xampp\apache\conf\extra\httpd-vhosts.conf and open the file. After open the file write a block of code just like this,

NameVirtualHost *:80
// default localhsot
<VirtualHost *:80>
DocumentRoot “c:/wamp/www/”
ServerName localhost
ServerAlias localhost
</VirtualHost>

// Virtual host
<VirtualHost *:80>
DocumentRoot “C:\wamp\www\projectName\public”
ServerName projectName.localhost
ServerAlias projectName.localhost
</VirtualHost>

After completing this section go to the host file to the path C:\WINDOWS\system32\drivers\etc

and open the file hosts  127.0.0.1       ZendFramework.com

set up zendframework on windows


Setting up XAMPP for Zend Framework Projects

step 1- Install xampp server on your local drive like. c:/xampp if you have installed xampp then leave first step.

step 2-Download the latest ZendFramework and extract it.

step 3- open Zendframework folder and open subfolder “library” and here you will find a folder named “Zend”, copy it
and past it to the location “c:/xampp/php/”, within “php” folder.

step 4-edit php.ini configuration file “c:/xampp/php/php.ini” , open it and find “include_path” for windows include_path = “.;c:\xampp\php\Zend”.

step 5-open console terminal, and go “c:\xampp\htdocs>” and type the following command
“c:\xampp\htdocs>c:\xampp\php\zf.dat create project mytestproject”. if no error message see. you project has been created.

step 6-check your “htdocs” folder for “mytestproject”. where all the necessary folders.

step 7- open this url in browser “http://localhost/mytestproject/public”

A ZF project would not run out of the box on a fresh installation of WAMP. The purpose of this guide is to act as a checklist for the experienced, and a step by step guide for the more inexperienced. Before we start, this article is written based on WampServer 2.0i with Zend Framework 1.10. If you are using earlier versions, the steps should work, but you might want to consider upgrading to the newest.

  1. Make sure Wamp is running ok
  2. Enable virtual hosts, mod_rewrite, and override in ‘httpd.conf’
  3. Set up virtual host in ‘httpd-vhosts.conf’
  4. Check include paths for  the Zend library
  5. Add Custom URLs in host file

1. Make sure Wamp is running ok

Navigate to http://localhost on your favorite browser, you should see the WampServer welcome screen with headings “Server Configuration”, “Tools”, “Your projects” etc. If not, check your Wamp installation before proceeding further.

2. Enable virtual hosts, mod_rewrite, and override in ‘httpd.conf’

For a default 2.0i installation, the apache configuration file can be found at ‘C:\wamp\bin\apache\Apache2.2.11\conf’. After making a backup, open it in notepad and search for “vhosts”. Make sure the line

# Include conf/extra/httpd-vhosts.conf

is uncommented by removing the “#” in front.

Next, look for the line

# LoadModule rewrite_module modules/mod_rewrite.so

and uncomment it too.

Lastly, look for

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    # Deny from all
</Directory>

and make sure AllowOverride is set to All instead of none. This prompts Apache to apply rules found in the .htaccess files in sub directories. Save and close.

3. Set up virtual host in ‘httpd-vhosts.conf’

Look for the file in ‘C:\wamp\bin\apache\Apache2.2.11\conf\extra’. Make a copy for backup and open it in notepad. The file should already have 2 dummy <VirtualHost> entries which you can safely remove. Now we will add the default virtual host and your own custom host:

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot “c:/wamp/www/”
ServerName localhost
ServerAlias localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot “C:\wamp\www\projectName\public”
ServerName projectName.localhost
ServerAlias projectName.localhost
</VirtualHost>

 

Update: if you get a “You don’t have permission to access” error when accessing the page, include the following directive right before the </VirtualHost> tag:

<directory "C:\My\Project\Path\public">
allow from all
</directory>

4. Check include paths for  the Zend library

Your app probably runs alright now. If you are getting the file not found error when including the Zend library, make sure you have copied the Zend library into your /library folder and your index.php actually combines it with the PHP include path:

set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path()
)));

Edit: As Fernando pointed out, take note to use slashes “\” instead of back slashes “/” on windows. Also, include your custom urls in your host file if they are not a subdomain of localhost:

5. Add Custom URLs in host file

Your host file is located at ‘C:\Windows\System32\drivers\etc’. Its a file without extension, but you can open it with notepad just the same. Add the following line to the end:

127.0.0.1 [Custom URL here]

That’s it. If you are unsure of the steps or meet any other problems feel free to email me. Tested using WampServer 2.0i with Zend Framework 1.10.

Magento theme development


Menu


Top user menu

<?php echo $this->getChildHtml('topLinks'); ?>

To main menu

 

<?php echo $this->getChildHtml('topMenu'); ?>

Top shopping cart

<?php echo $this->getChildHtml('headerCart') ; ?>

Top search

<?php echo $this->getChildHtml('topSearch'); ?>

Add extra link in top user menu:

<reference name="top.links">
    <action method="addLink" translate="label title"><label>Shop</label><url>abc</url><title>Shop</title><position>1</position></action>
</reference>
<reference name="top.links">
    <action method="removeLinkByUrl"><url helper="customer/getAccountUrl"/></action>
</reference>

Add extra link in bottom menu

 

<reference name="footer">
    <block  as="footer_link_cms"  type="cms/block" name="cms_footer_links" before="footer_links">
        <action method="setBlockId"><block_id>footer_links</block_id></action>
    </block>
</reference>

 

<reference name="footer_links">
    <action method="removeLinkByUrl"><url helper="catalog/map/getCategoryUrl"/></action>
</reference>

Remove block

<default>
    <remove name="footer_links"/>
</default>

Add static block

 

<reference name="footer">
    <block  as="callstaticblock" type="cms/block" name="callstaticblock" before="footer_links">
        <action method="setBlockId"><block_id>footer_links</block_id></action>
    </block>
</reference>

Tree menu

<reference name="footer">
    <block type="catalog/navigation" before="nab_pict" name="treemenu" template="catalog/navigation/tree_menu.phtml" />
</reference>

Add static block anywhere

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('footer_links')->toHtml() ?>

Add block anywhere

<?php echo $this->getLayout()->createBlock('catalog/product_new')->setTemplate('catalog/product/new.phtml')->toHtml(); ?>