i made in frontend nice url with symfony routing.yml. In frontend i can use for example:
url_for('@news', $news);
this generate for me:
http://mysite.com/frontend_dev.php/news/nice-title/1
but if i use this in backend i have:
http://mysite.com/backend_dev.php/news/nice-title/1
is possible generate these link in backend for frontend?
In apps/frontend/config/frontendConfiguration.class.php use something like this:
class frontendConfiguration extends sfApplicationConfiguration
{
protected $backendRouting = null;
public function generateBackendUrl($name, $parameters = array(), $absolute = false)
{
return sfConfig::get('app_site_url').$this->getBackendRouting()->generate($name, $parameters, $absolute);
}
public function getBackendRouting()
{
if (!$this->backendRouting )
{
$this->backendRouting = new sfPatternRouting(new sfEventDispatcher());
$config = new sfRoutingConfigHandler();
$routes = $config->evaluate(array(sfConfig::get('sf_apps_dir').'/backend/config/routing.yml'));
$this->backendRouting->setRoutes($routes);
}
return $this->backendRouting;
}
}
use it like this:
$sf_context->getConfiguration()->generateBackendUrl('my_custom_route', array('id' => 1), true)
More information here: http://symfony.com/blog/cross-application-links
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With