The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

Parameters of config on Views

riotbr's Avatar

riotbr

18 Sep, 2015 04:12 PM

First of all, sorry about my english ;)

I have some parameters on my Slim config array (about the database, for example) that work properly, including my classes and methods. I wanna use the same array with some mundane parameters (assets directories). As I can see, that is possible using this values before I render something and passing the values in a data array:

$app->get('/page', function () use ($app) {
    $css = $app->config('css');
    $js = $app->config('js');
    $img = $app->config('images');
    $data = array('css' => $css,'js' => $js,'images' => $images);
    $app->render('page.php',$data);
});

Obviously I'll have a huge index.php in the end of my project. There's another way to load these parameters in my templates?

PS: I'm not using (and will not use) Twig or equivalent.

Thanks in advance ;)

  1. 1 Posted by riotbr on 18 Sep, 2015 04:41 PM

    riotbr's Avatar

    I'm really sorry... I've found the answer. I'll post here to help others who, like me, didn't read the documentation carefully:

    Appending Data (http://docs.slimframework.com/view/data/#appending-data)

    $app->view->appendData(array(
        'foo' => 'bar'
    ));
    

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac