|
|||
|
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;
}
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;
}
?>
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? |
![]() |
| Thread Tools | |
| Display Modes | |
|
|