Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Omit domain from anchor
  • Hello,

    Is it in any way possible, without making modifications to the FuelPHP core, to let

    Html::anchor()
    generate an URL without the http://domain.tld/ in it? as in

    Html::anchor('auth/login', 'login');  #returns <a href="/auth/login">login</a> ?
  • philipptempelphilipptempel
    Accepted Answer
    Hi sdekkers,

    to my knowledge there's no way to do this using ```Html::anchor()``` but you should be able to do the following

    echo str_replace(\Config::get('base_url'), '', \Html::anchor('auth/login'));
  • Alright, well we're not looking to edit all files that have a Html::anchor() in it, so I suppose we'll just extend the core in that way then..

    Perhaps we can add this to the feature-request list ? :)
  • HarroHarro
    Accepted Answer
    You can set the 'base_url' in your app/config/config.php to a relative path like "/". Then all methods that use the base URL will generate relative links.

    By default the base_url is not set and will be auto-detected, which means it's always absolute.

    Alternatively you let Fuel determine the base url (which happens in your app bootstrap by the Fuel::init() call), then after that retrieve it from config, strip the hostname (so make it relative), and save that back.

    The advantage of that is that it is not hard-coded.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion