Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-10-2008, 05:17 AM
Junior Member
 
Join Date: Jul 2008
Posts: 27
Default getUrl not prepending appropiate URL

Hey, not sure where to ask this question, but...

I'm trying to use the following function to prefix Url's dynamically within my application, both for use in Smarty templates and in breadcrumbs, etc:

Code:
public function getUrl($action = null, $controller = null)
        {
            $url  = rtrim($this->getRequest()->getBaseUrl(), '/') . '/';
            $url .= $this->_helper->url->simple($action, $controller);

            return $url;
        }
I'm also using a Smarty pluggin, which contains basically the same function listed here above, to output the Url's using: {geturl controller='events'} or {geturl controller='account' action='logout'}, etc. The smarty class looks like this:

Code:
<?php
    function smarty_function_geturl($params, $smarty)
    {
        $action     = isset($params['action']) ? $params['action'] : null;
        $controller = isset($params['controller']) ? $params['controller'] : null;

        $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('url');

        $request = Zend_Controller_Front::getInstance()->getRequest();

        $url  = rtrim($request->getBaseUrl(), '/') . '/';
        $url .= $helper->simple($action, $controller);

        return $url;
    }
?>
I'm not sure how or why, sometimes it outputs correctly, but often is doesn't and the Url will be:

http://events/

Etc...

I'm using a virtual host to locate my root directory, maybe this has something to do with it?

But given the output http://events/, it seems like the call to getBaseUrl() isn't returning correctly...any ideas?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 01:02 AM.