logo

$5
Why does url_for() mangle URLs when used in a yaml file?

This is a follow-up to the question I just asked. It was suggested that I can use url_for() in yaml files if I load the helper. So I did. But now url_for() is giving me mangled urls.

I'm doing this in app.yml:

  urls:
janrain_rpx_login_processing: '<?php echo url_for('user/rpxLogin', true) ?>'



and in the template I call it like this:

<?php echo sfConfig::get('app_urls_janrain_rpx_login_processing') ?>


and I'm getting this:

http://dev.dev.com/dev.phpmodule=user/action=rpxLogin



Any thought why it would mash the URL like that?


And this:

 urls:

janrain_rpx_login_processing: '<?php echo url_for('user/rpxLogin') ?>'




gives me this:

/cao_dev.phpmodule=user/action=rpxLogin



Why? Is there a better function to use than url_for()?

Lawrence Krubner | 07/27/10 at 1:34pm | Edit


(2) Possible Answers Submitted...

  • avatar
    Last edited:
    07/27/10
    6:23pm
    Pierre Minnieur says:

    Just store the name of the route in your YAML file. You can then use url_for(sfConfig::get('app_urls_janrain_rpx_login_processing')) to render the link in your templates. That's a common approach and is widely used (e.g. sf*GuardPlugin).

    • 07/27/10 3:00pm

      Lawrence Krubner says:

      So I can not use URL methods in the yaml file? You are suggesting that this is impossible?

  • avatar
    Last edited:
    07/27/10
    3:38pm
    Kiril Angov says:

    Pierre is right, why would you store the result of url_for, when you can just store the route name and generate the URL in the template PHP files.

This question has expired.





Current status of this question: Completed