The simplest way to get a url is using the Router.
Like that:
$url = Router::url('/controller/action', true);
/**
* Finds URL for specified action.
*
* Returns an URL pointing to a combination of controller and action. Param
* $url can be:
* + Empty - the method will find adress to actuall controller/action.
* + '/' - the method will find base URL of application.
* + A combination of controller/action - the method will find url for
it.
*
* @param mixed $url Cake-relative URL, like "/products/edit/92" or
"/presidents/elect/4"
* or an array specifying any of the following:
'controller', 'action',
* and/or 'plugin', in addition to named arguments
(keyed array elements),
* and standard URL arguments (indexed array
elements)
* @param boolean $full If true, the full base URL will be prepended to the
result
* @return string Full translated URL with base path.
* @access public
* @static
*/
[]'s
On Jan 23, 2008 10:06 AM, grigri <[EMAIL PROTECTED]> wrote:
>
> Based on your syntax, I think you want HtmlHelper::link() (makes a
> hyperlink), not Html::url() [just makes a proper url].
>
> If you do need just the url then you can do this:
> $this->set('myurl', Router::url('/controller/action/'));
>
> (HtmlHelper::url() just calls Router::url() under the hood anyway).
>
> If, for some really weird reason, you DO need to use
> HtmlHelper::link() in the controller, then use WebSpin.biz's
> suggestion. Just get the function name right!
>
> (Although I'd really like to know WHY you think you need to use a
> helper from a controller. I can't think of any situation where this
> might be necessary, although it's conceivable that there is one.)
>
> On Jan 23, 11:18 am, "WebSpin.Biz" <[EMAIL PROTECTED]> wrote:
> > First, you'll have to load the helper into your controller (has to be
> > a really good reason why you would want to do this)
> >
> > App::import('Helper', 'HtmlHelper');
> >
> > Then, make sure AUTO_OUTPUT is set to false in your core config file
> > (/app/config/core.php), then, capture the output of the helper, and
> > set it into the view
> >
> > $this->set('myurllink', $html->url('Linkname','/controller/
> > fun_name/'));
> >
> > Raphael Spindellhttp://www.webspin.biz
> >
> > On Jan 23, 2:18 am, "jenson" <[EMAIL PROTECTED]> wrote:
> >
> > > Hi Guys ,
> > > I have to assign $html->url('Linkname','/controller/fun_name/'); in
> controller page not
> > > in thtml page. plz help me regarding this as early as possible...
> >
> > > with regards ,
> > > jenson.
> >
> > > --
> > > This message has been scanned for viruses and
> > > dangerous content by MailScanner, and is
> > > believed to be clean.
> >
>
--
Renan Gonçalves - Web Developer
Cell Phone: +55 (11) 8633-6018
MSN: [EMAIL PROTECTED]
Web Site: renangoncalves.com
São Paulo - SP/Brazil
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---