'how to ?' Category

  • How to count days between 2 dates in php

    March 11, 2013

    A simple solution to count days between 2 dates is using DateTime method since php 5.3 function getDaysBetweenDates($from,$to,$addLastDay = false){ $d1 = new \DateTime($from); $d2 = new \DateTime($to); if($addLastDay){ $d2->add(new \DateInterval('P1D')); } return $d1 -> diff($d2)->days; } echo getDaysBetweenDates('2013-03-01','2013-03-11'); //10 echo getDaysBetweenDates('2013-03-01','2013-03-11',true); //11 If you need to count the last day too , just pass […]

  • How to get zend framework 2 base path with domain name in layout ?

    March 5, 2013

    There is a easy way to get zend framework 2 base path with domain name in layout. 1. In layout.phtml $homeUrl = $this->url('home',array(),array('force_canonical' => true)); 2.Adding home route in module.config.php 'home' => array( 'type' => 'Zend\Mvc\Router\Http\Literal', 'options' => array( 'route' => '/', 'defaults' => array( 'controller' => 'Application\Controller\Index', 'action' => 'index', ), ), ), Simple […]

  • php how to calculate system processor/s load in percent

    February 7, 2013

    This simple function will allow us to control php performance at level we need. /** * Calculates the processor load in % * @see sys_getloadavg * @author Ivan Gospodinow * @site ivangospodinow.com * @date 07.02.2013 * @param int $coreCount * @param int $interval * @return float */ function systemLoadInPercent($coreCount = 2,$interval = 1){ $rs = […]

  • Change layout template based on controller in Zend Framework 2

    January 18, 2013

    In Zend Framework 2 , layout can be easily changed from module based on controller(name).   Step 1. Add in module.config.php file 'controller_layouts' => array( 'MyControllerName' => 'layout/MyControllerName', ), and 'view_manager' => array( //more options 'template_map' => array( 'layout/MyControllerName'=> PATH_TO_TEMPLATE ), ), Step 2. Add in module.php $e->getApplication()->getEventManager()->getSharedManager() ->attach('Zend\Mvc\Controller\AbstractActionController', 'dispatch', function($e) { $controller = $e->getTarget(); […]

  • How to destroy all dojo widget nodes

    November 26, 2012

    Simple and working solution. ThisĀ  code snippet will help you to destroy all dojo widgets. window.widgetsDestroy = function(){ require(['dijit/registry','dojo/query'],function(registry,query){ query('*[id]').forEach(function(node){ var widget = registry.byId(node.id); if(undefined !== widget){ widget.destroy(); } }); }); } Use it with : window.widgetsDestroy(); Suggestions or problems ? Write a comment.

  • Adding Custom View Helper In Zend Framework 2

    September 30, 2012

    Here is example implementation of a custom view helper script. Step 1. Creating Zend Framework 2 Helper. //file : App_folder/module/Module_name/src/Module_name/View/Helper/SayHello.php namespace Application\View\Helper; use Zend\View\Helper\AbstractHelper; class SayHello extends AbstractHelper{ public function __invoke($name = 'Unnamed'){ return “$name , this is Zend Framework 2 View Helper”; } } Step 2. Registering the Zend Framework 2 Helper. //file : […]

  • Running multiple wordpress blog copies from different locations.

    September 30, 2012

    This is something that was bugging me for a while. How can multiple developers work on same wordpress without messing up the code ? The answer came from two wordpress variables : WP_SITEURL and WP_HOME. If the two variables are set , wordpress blog do not get them from the database. Step 1. Adding this […]

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org