![]() |
|
Snippets |
|
Here is a usefull helper to calculate url for another application :
function baseurl_for($application, $absolute = false) { $url = $absolute ? 'http://' . $_SERVER["HTTP_HOST"] : ''; $url .= '/' . $application . (SF_ENVIRONMENT != 'prod' ? '_' . SF_ENVIRONMENT : '') . '.php/'; return $url; }
in the action :
<?php echo link_to('Whatever', baseurl_for('application', true) . 'module/action') ?>
I really feel like this feature is missing, hope this could added soon ;) ... example corrected (but sadly not so usefull) according to francois's comment.
Comments on this snippet
There is something I don't understand. How can the
url_for()work for another application? One application doesn't have knowledge of another application's routing rules. So the only way you can link to another application is by specifying the external url (not the internal uri). For this reason, your example looks wrong.Besides, your helper works only for one type of configuration. How about applications which front controllers are in subdirectories?
Yes, people don't seem to understand that if you need links from one application to another then you should merge your two applications in one. There is no other way. As i see it, this snippet is a trick, that will not work in most of the cases.
My greatest hope is that it be possible in symfony 1.0 to split an application in several sub-applications with sub-application settings.
I have specified baseurl and favicon vars in my app.yml:
all: head: base: http://127.0.0.1:81 favicon: /images/favicon.ico
In my global template where the head section is built, I put: <?php echo tag('base', array('href' => sfConfig::get('app_head_base')))."\n" ?>
This way you can leave al your links alone. Only problem the baseurl is hardcoded ... it would be perfect if it is genereated inside the yml or something. Deployment is tricky this way.