Twigs for each html page of my UF?

My original site has about 50-60 html pages. So should I like make a twig template for each of these pages and do:

    {
        return $this->ci->view->render($response, 'pages/page.html.twig');
    }


in my Sprinkle controller for each page?

That’s a good question. I think in general a one-for-one mapping of static html for static twig file might be true if you are not re-imagining/re-working the design.

1 Like

I decided to completely re-design my original site from scratch to better utilize UF’s framework. So we’ll see! :slight_smile:

For people landing here, another solution would be to use a variable in the route to dynamically load HMTL pages. For example:

Route:

$this->get('/pages/{page_name}', 'UserFrosting\Sprinkle\MySite\Controller\MyController:staticPage');

Controller:

public function create($request, $response, $args)
{
    return $this->ci->view->render($response, 'pages/' . $args['page_name'] . '.html.twig');
}

Throw a little “if exist” in there, and you’re good to go.

2 Likes