Tuesday, April 21, 2015

Zend Auth example with extra columun

    $request = $this->getRequest();
            if ($request->isPost()) {
                $params = $this->filterInput($request->getParams());
                $db = Zend_Db_Table_Abstract::getDefaultAdapter();
                $auth = Zend_Auth::getInstance();
                $authAdapter = new Zend_Auth_Adapter_DbTable($db, 'mdl_registration_user');
                // extra validation
                $authAdapter->getDbSelect()->where('countrycode = +'.$params['country']);
                $result = $auth->authenticate($authAdapter);
                if ($result->isValid()) {
                    $user = $authAdapter->getResultRowObject();
                    $flash_obj->addMessage('You have loged-in successfully');
                } else {
                    $this->view->messages = "Invalid username or password. Please try again.";
                    return ;

Tuesday, October 23, 2012

Function to add variable to drupal template

Use following code to add new variables to Drupal template(page.tpl.php,node.tpl.php etc).

function dpg_preprocess(&$variables, $hook){
    $variables['newvar'] = "New var";

function phptemplate_preprocess_node(&$vars){
    $vars['newvar'] = "New var";

Thursday, September 20, 2012

PHP 5.4.0 new features:

  1. Support for traits has been added.
  2. Short array syntax has been added, e.g. $a = [1, 2, 3, 4]; or $a = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => 4];.
  3. Function array dereferencing has been added, e.g. foo()[0].
  4. Closures now support $this.
  5. <?= is now always available, regardless of the short_open_tag php.ini option.
  6. Class member access on instantiation has been added, e.g. (new Foo)->bar().
  7. Class::{expr}() syntax is now supported.
  8. Binary number format has been added, e.g. 0b001001101.
  9. Improved parse error messages and improved incompatible arguments warnings.
  10. The session extension can now track the upload progress of files.
  11. Built-in development web server in CLI mode.

Thursday, September 13, 2012

Add new regions into Drupal theme

Add the following line into your theme .info file to add new regions.
To do this go to site->all->themes->your_theme
open your_theme.info and add regions like this
regions[your_region] = Your region description

Now go to page.tpl.php
and add the following code where you want to add region

<?php print render($page['your_region']); ?>

Wednesday, September 12, 2012

Magento: Add Javascript and CSS to Home Page Only

Magento allow you to modify the layout XML specific to that page. So, all you need to do is :

1. Login into Magento admin
2. Go to CMS->static pages
3. Edit home page
4. Go to design tab, in Custom design tab, Add the following code into "Custom Layout Update XML" field to add css or javascript file.
<reference name="head">
  <action method="addItem">
  <action method="addItem">

Insert category product into static page magento

To insert category product into static page in magento follow these simple steps.
1. Create a category from Catalog->Manage Categories called "Featured Category".
2. Set this category as active and set "no" to "Include in Navigation Menu" label.
3. Go to display settings tab.
4. Select display mode as static page only.
5. Create static page from CMS->static pages
6. Add the following code into content tab
<code>{{block type="catalog/product_list" category_id="35" template="catalog/product/list.phtml"}}

How to change home page contents in Magento

To change home page content in Magento do the following steps.
1. Loged in admin of magento.
2. Go to "CMS->pages" menu.
3. Edit "Home page" list item.

Now you can edit home page as per requirement.