Code snippets for symfony 1.x


Refine Tags

Snippets tagged "phorum"

Generating Symfony URLs in other projects and subdirectories

Integrating Phorum into a Symfony project at, I wanted to use my existing Symfony URLs in my Phorum templates:

// This path should be the path to your config/ProjectConfiguration.class.php file
// in your Symfony project
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', sfConfig::get("sf_environment"), true);
$instance = sfContext::createInstance($configuration);
$routing = $instance->getRouting();
// Our URLs may have a prefix (eg /forum/index.php).  Remove this
$routingOptions = $routing->getOptions();
$urlPrefix = (array_key_exists("prefix", $routingOptions["context"]) ? $routingOptions["context"]["prefix"] : "");
$myURL = $routing->generate("default", array("module" => "foo", "action" => "bar"));
$myURL = str_replace($urlPrefix, "", $myURL);
by Rich Sage on 2010-05-06, tagged phorum  route  url