Author Topic: URL Generation in Zend Framework  (Read 822 times)

0 Members and 1 Guest are viewing this topic.

Offline phpdeveloper82Topic starter

  • Irregular
  • Posts: 45
    • View Profile
URL Generation in Zend Framework
« on: February 22, 2010, 05:42:02 AM »
hello,

I have started studying Zend Framework and have a doubt in creating urls.

Suppose I am visiting a page:

http://localhost/zend/bugs/page/1  (Using Pagination)

then the edit will be like this:

localhost/edit/1

So I wish to store the site url (http://localhost/zend/ ).. Any method is available in Zend for manage this ?

Offline phpdeveloper82Topic starter

  • Irregular
  • Posts: 45
    • View Profile
Re: URL Generation in Zend Framework
« Reply #1 on: February 22, 2010, 06:30:12 AM »
It is possible to create helper class to do this..

 
Code: [Select]
<?php
class Zend_View_Helper_GetSiteUrl
{

    function 
getSiteUrl()
    {
        
$site_url  'http://localhost/zend/';
        return 
$site_url;
    }
    
    
}


But is there any issue of using this Helper Function in the Controller & Views like :

Code: [Select]
<td><a href='<?php echo $this->getSiteUrl(); ?>pages/edit/id/<?php echo $this->id?>'>Edit</a>

Inside the controller:

Code: [Select]
$bugReportForm->setAction($this->view->getSiteUrl().'pages/edit');

Online ignace

  • Guru
  • Freak!
  • *
  • Posts: 5,093
  • Gender: Male
    • View Profile
Re: URL Generation in Zend Framework
« Reply #2 on: February 22, 2010, 09:00:14 AM »
Use the BaseUrl view helper

Code: [Select]
<link href="<?php print $this->baseUrl('styles/screen.css'); ?>" .. />
Developer from Belgium, Vlaams-Brabant