• PHP
  • Ruby on Rails
  • MySQL
  • Linux
    • SELINUX
    • Fedora
    • debian
  • Apache
  • nginx
  • AJAX
Albertech.net

Tag Archives: Zend Framework

Zend Framework – Shorten the parameter URL by using custom routes

March 12, 2013 2:34 pm / Albertech.net

If you want to consolidate a single parameter into the URL path, it is possible via Zend Rewrite.

For instance, you currently have mysite.com/users/edit/userid/1234 and would like to use mysite.com/users/edit/1234.

To do this, edit the bootstrap.php file and include the following code:

    protected function _initRoutes()
    {
        $router = Zend_Controller_Front::getInstance()->getRouter();
        $route = new Zend_Controller_Router_Route('users/edit/:userid',array('controller' =>; 'users','action' => 'edit'));
        $router->addRoute('usersedit',$route);
        return $router;
    }

In your users controller – editAction() method, you will now be able to access the $userid variable with the shorter URL (mysite.com/users/edit/1234)
(Very basic example)

$request = $this->getRequest();
$userid = $request->userid;

Share this:

  • Facebook
  • Google
  • Twitter
  • Print
  • Email
Posted in: Zend Framework / Tagged: routes, zend framework

Zend Framework – Setting global variables in application.ini

August 17, 2012 5:13 pm / Albertech.net

Here are some basic instructions to setting up global variables in Zend Framework using the application.ini file (application/configs/application.ini):

1) Create a service name for your global variable in application.ini. Usually, you group them by the API name. 

For instance, if you have an API called “myapi” and you want to store a global variable myvar = “1234”.  Add the following line to your application.ini

myapi.myvar = 1234

2) In your controller, use the following code to access the global variable:
$myapi = $this->getInvokeArg('bootstrap')->getOption('myapi');
$myvar = $myapi["myvar"];


Share this:

  • Facebook
  • Google
  • Twitter
  • Print
  • Email
Posted in: PHP, Zend Framework / Tagged: config, global variables, zend framework

Categories

  • AJAX
  • Android
  • Apache
  • Canon Cameras
  • Cloud
  • CMS
  • Computer Mods
  • Conferences
  • Deals
  • debian
  • Fedora
  • Flash
  • Frameworks
  • git
  • Hardware
  • HTML
  • IDE
  • iPhone
  • iPhone App Review
  • jQuery
  • Linux
  • Mac OS X
  • MySQL
  • nginx
  • PHP
  • portfolio
  • Puppet
  • Ruby on Rails
  • Script Reviews
  • SELINUX
  • Software
  • Software Review
  • SQL Server
  • statistics
  • Tech
  • Tomcat
  • Uncategorized
  • VMWARE
  • VPS
  • Windows
  • wordpress
  • Zend Framework

Blogroll

  • DragonAl Flickr
  • Dropbox – Free 2GB Account
  • James' Blog
  • Javascript Compressor
  • PHP Builder Community
  • PHP-Princess.net
  • Rubular – Regular Expression Validator
  • The Scale-Out Blog
  • Tiny MCE

Tags

activation AJAX android antec Apache AWS awstats canon coda codeigniter debian enclosure external free G1 install vmware tools Internet Explorer iphone 5 jquery Linux mx-1 MySQL office 2007 OSX photoshop PHP plugin plugins portfolio redesigned website review rewrite script security SELinux ssh tinymce tutorial upgrade VMWARE vmware server wordpress wordpress mu XSS zend framework
© Copyright 2013 Albertech.net
Infinity Theme by DesignCoral / WordPress
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.