Awesome, that worked great. Now to tweak it to do more of what I want. Thanks kevin,
James On Sep 7, 2008, at 12:13 PM, kevinkevin wrote: > > Maybe this is useful - not sure... > http://www.symfony-project.org/snippets/snippet/115 > > > On Sep 6, 9:30 pm, James <[EMAIL PROTECTED]> wrote: >> Symfony 1.0.17 >> >> I have written a filter to change the site layout based on the URL. >> It works, mostly, but there are some issues, and I am wondering if >> maybe there's a better way to change to layout. >> >> Here is my filter... >> >> <?php >> >> class domainWatchFilter extends sfFilter >> { >> public function execute($filterChain) >> { >> // Execute this filter only once >> if ($this->isFirstCall()) >> { >> // Get the name of the master site from the app.yml config >> file >> $masterURL = >> sfConfig::get('app_domainWatchFilter_masterUrl',''); >> >> if($masterURL == $_SERVER['HTTP_HOST']) >> { >> define('MASTERSITE',true); >> } >> else >> { >> // Set the constant MASTERSITE >> define('MASTERSITE',false); >> >> // Get the layout name from the database so we >> can >> show >> $siteLayout = null; >> >> if($siteLayout == null) { $siteLayout = >> "defaultcon"; } >> >> // Now set the layout for the website. >> $actionStack = $this->getContext()- >> >getActionStack(); >> $actionStack->getFirstEntry()- >> >getActionInstance()- >> >setLayout($siteLayout); >> >> } >> >> } >> // Execute next filter >> $filterChain->execute(); >> } >> >> } >> >> ?> >> >> I have 2 URLs mysite.dev and testsite.mysite.dev mysite.dev is my >> MASTERSITE so when I go to this URL the default layout is used. when >> I testsite.mysite.dev the defaultcon template shows. This happens >> whenever I go to any module/action, so for the most part it's doing >> what I want. >> >> I have a route homepage which points to module "main" and action >> "index" inside this action I am checking to see if we are the >> MASTERSITE and forwarding to the proper module either the homepage >> for the MASTERSITE or the homepage for everyother domains that points >> to the application. The problem is $this->forward doesn't change to >> the proper template in the later case. >> >> I had tried to dynamically set the homepage route, but that didn't >> work either. >> >> Suggestions? >> >> Thanks >> James > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---
