We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

include file path behaviour

Hello,

I've some troubles with include file path.

My footer file's path is : /.../www/App/View/partial/common/footer.

This code works fine :

{% include "common/header" with ['site': site, 'menu': menu] %}
<div class="container">
    {{ content() }}
</div>
{% include "common/footer" with ['site': site] %}

But if I wrote this, it's working no more. Error is : "Template file /.../www/App/View/common/footer does not exist" :

{% include "common/header" with ['site': site, 'menu': menu] %}
<div class="container">
    {{ content() }}
</div>
{% include "common/footer" %}

If I wrote include like this, this error warned but it's good full path : "Template file /.../www/App/View/partial/common/footer does not exist" :

{% include "partial/common/footer" %}

If I wrote this, it's work fine :

{% include "partial/common/footer.volt" %}

Is it normal behaviour changing path name if you have or not parameters ?

Thanks for your time.


Some file's extracts :

        'viewDir'               => '/App/View/',
        'viewCommonDir'         => '/App/View/partial/common/',
        'viewLayoutDir'         => '/App/View/layout/',
        'viewPartialDir'        => '/App/View/partial/',
        $loader->registerDirs([
            BASE_PATH . $config->application->controllerDir,
            BASE_PATH . $config->application->formDir,
            BASE_PATH . $config->application->libraryDir,
            BASE_PATH . $config->application->modelDir,
            BASE_PATH . $config->application->pluginDir,

            BASE_PATH . $config->application->viewDir,
            BASE_PATH . $config->application->viewCommonDir,
            BASE_PATH . $config->application->viewLayoutDir,
            BASE_PATH . $config->application->viewPartialDir,

            BASE_PATH . $config->application->cacheDir,
            BASE_PATH . $config->application->voltDir,
        ]);
$di->setShared('view', function () use ($config) {
                    $view = new View();
                    $view->setDI($this);
                    $view->setViewsDir(BASE_PATH . $config->application->viewDir);
                    $view->setLayoutsDir(BASE_PATH . $config->application->viewLayoutDir);
                    $view->setPartialsDir('partial/');
                    $view->setTemplateAfter($config->application->viewLayoutName);
                    $view->setMainView($config->application->viewLayoutName);

                    $view->registerEngines([
                        '.volt'  => 'volt',
                        '.phtml' => 'phpTemplating',
                    ]);

                    return $view;
});


3.4k
edited Jun '17

Temporary solution I use is :

{% include "common/footer" with [] %}