Render single module or module with specific template


#1

Hi guys,

I’m struggling the whole afternoon and try to solve one issue with modules plugin. I work with 2 multiple module section on 1 page. That means I want use modules for the content area and other modules for so called sidebar area. In the panel everything works quite well and has the structur (like this)

content/
       page-a/
               _modules/
               _sidebar/
               default.txt

I want to control the render process now and print the content-modules separately to the sidebar-modules. With $page->modules() i can print only everything, and render() gives me an error. What’s the best way to print multiple module sections on 1 pages?

Thanks!


#2

Hm, I’m a bit surprised that the plugin also fetches the modules from the _sidebar subfolder, because as far as I know, you can only have a single folder that contains submodules :thinking:


#3

the setting

c::set(‘modules.parent.uid’, array(’_modules’, ‘_sidebar’));

make it happen. take a while to find it out


#4

Since modulelist() gives you a collection of modules, you can filter them like any collection, I assume. Haven’t tested this, but something like

$modules = $page->modulelist()->filterBy('parent', '_sidebar');

could probably work, or filter by templates or whatever these have in common.

With your array as config setting, you might however run into issues, at least the page method

	public function page() {
		if($this->parent()->uid() === Settings::parentUid()) {
			return $this->parent()->parent();
		} else {
			return $this->parent();
		}
	}

will not work, because the if statement will never be true, because you will compare a string to an array.


#5

Hmn,

thats true - and the array in modules.parent.uid is the reason why render() dit not work too.

Thanks to find my mistake :wink:


#6

But why can’t you put all modules into one subfolder and give them template names to differentiate them? Or use two subfolders (main and sidebar) as parents with the modules inside them.


#7

I need to separate it to fill them with different modules. If i storage all modules in one subfolder i have to chance the prefix, that i can select different modules. If i don’t do it, a selected module will insert in both module sections.

its the same problem like with parent.


#8

Then I’d go with the two parents solution.