This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

alex
alex

[Look in the next comment for the solution]

Good evening guys.

I installed the RainLab.Translate Plugin and everything is working as expected. But I have a problem with content-pages that are in multiple subdirectories. My current folder-structure is like this:

/content/de/main/page.de.htm

/content/en /main/page.en.htm

Now to support the two root folders (de and en) I've added the simple line in the RainLab.Translate Plugin.php:

Event::listen('cms.page.beforeRenderContent', function($controller, $fileName) {
       ...
        /*
         * Splice the active locale in to the filename
         * - content.htm -> en/content.en.htm
         */
        $locale = Translator::instance()->getLocale();
        $fileName = substr_replace($fileName, '.'.$locale, strrpos($fileName, '.'), 0);
        $fileName = substr_replace($fileName, $locale.'/', 0, 0); // This one is new
        ...
    });

Like I said before, this works just fine only one level deep. After adding the directory "main" and using {% content "main/page" %} I've always get the following Exception:

An exception has been thrown during the rendering of a template ("Invalid file name: en/main/page.en.htm. File names can    contain only alphanumeric symbols, underscores, dashes and dots. Some examples of correct file names: page.htm, page, subdirectory/page").

I'm going slowly crazy with this issue, please help (:

PS: I think it's probably not the fault of OctoberCMS, and much more on Twig's end. It probabably sees the path/to/the/file.htm more as a whole filename rather than a location. Which is super weird.

Last updated

alex
alex

modules/cms/classes/CmsObject.php

/**
 * Returns the maximum allowed path nesting level. 
 * The default value is 2, meaning that files
 * can only exist in the root directory, or in a subdirectory.
 * @return mixed Returns the maximum nesting level or null if any level is allowed.
 */
protected static function getMaxAllowedPathNesting()
{
    return 2;
}

The method only allows for maximal 2 levels of nesting (root counts as one). To use my desired soltion having multiple sub-directories like

* content\de\subd1
* content\de\subd2
* ...
* content\en\subd1
* content\en\subd2
* ...

you have to change the methods return type to: return null

Last updated

valerio.coltre23312
valerio.coltre23312

Nice, is it possible to override this function inside a plugin? How?

trollkotze
trollkotze

And will this be overwritten by an October upgrade?

On another note: Has this forum been officially declared dead yet? Am I in a ghost town?

Also: Doesn't seem to work anymore. That function does not exist anymore. Instead, I found a setting inside modules/cms/classes/ComponentPartial.php

    /**
     * @var int The maximum allowed path nesting level. The default value is 2,
     * meaning that files can only exist in the root directory, or in a
     * subdirectory. Set to null if any level is allowed.
     */
    protected $maxNesting = 2;

But I guess, as the filename says, that must be concerning only component partials. Changing it has brought me no success. :/

Last updated

john34161
john34161

@trollkotze, looks like it is moved to a parent class:

October\Rain\Halcyon\Model

into a class property

protected $maxNesting = 2;

So you can try changing it there, or in a child class:

Cms\Classes\CmsObject

by adding:

protected $maxNesting = 5; // or whatever number you want

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.