All pastes #940774 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-03-13 08:25 UTC
rendered paste body
Route:

 <route name="static" pattern="/(page:.+).html" callback="MyProjectStaticPageRoutingCallback" module="Public" action="ShowStaticPage" stop="false"/>

Autoload:

<autoload name="MyProjectStaticPageRoutingCallback">%core.lib_dir%/routing/GamesLobbyStaticPageRoutingCallback.class.php</autoload>

Callback:

class MyProjectStaticPageRoutingCallback extends AgaviRoutingCallback
{
        public function onMatched(array &$parameters, AgaviExecutionContainer $container)
        {
                if (isset($parameters['page']))
                        $page = $parameters['page'];
                else
                        return false;


                // Recognize the page's URL, fetch its ID and pass it back as a parameter to action ShowStaticPage

                $m = $this->context->getModel('Pages', 'Public');
                if ($page_object = $m->lookupPageBySlum($page))
                {
                        $parameters['page_id'] = $page_object;
                        return true;
                }

                return false; // page doesn't exist, so the route doesn't match
        }
}

Action is empty

View:

class Public_ShowStaticPageSuccessView extends ProjectBaseView
{
        public function executeHtml(AgaviRequestDataHolder $rd)
        {
                $this->setupHtml($rd);

                $page = $this->getAttribute('page');
                $layer = $this->getLayer('content');
                $layer->setTemplate($page->getTemplate());
        }
}