Elxis CMS Forum

Support => Elxis 4.x/5.x DEV => Topic started by: speck on May 30, 2013, 07:35:00

Title: Calling module positions in a module.
Post by: speck on May 30, 2013, 07:35:00
I did a module tab slide where is possible to call other modules with module position.
the problem is:
using the instructiont if ($eDoc->countModules('user2') > 0) ............ it seems works,
but $eDoc->module('user2') it seems not works.

the lines used in the module are like these:
example
Code: [Select]
$eDoc = eFactory::getDocument();
echo '<div>';
$eDoc->module('user2');
echo '</div>';
Title: Re: Calling module positions in a module.
Post by: datahell on May 30, 2013, 08:29:29
When you call a single module you must call it by its name, not its position.

Load all modules of position "left":
$eDoc->modules('left');

Load single module "language" regardless its position:
$eDoc->module('mod_language');
Title: Re: Calling module positions in a module.
Post by: speck on May 30, 2013, 08:53:09
$eDoc->modules('left');

$eDoc->module('mod_language');
uffff
calling a module position in a module it seems not works  ???

the return result is: [:replmark14:]

the part of code used for experiment is this

Code: [Select]
/******************/
/* MAKE HTML CODE */
/******************/
private function maketabHTML() {
$eDoc = eFactory::getDocument();
echo "<div>\n";
echo '<h5>test</h5>';
echo '<div class="contenttab">'."\n";
$eDoc->modules('modtab1');
echo "</div>\n";
echo "</div>\n";

}


where at modtab1 is assigned a module like latest news
Title: Re: Calling module positions in a module.
Post by: webgift on May 30, 2013, 10:23:26
Hi Speck,
Is the modtab1 a module position? Have you created a new module position manually?
Title: Re: Calling module positions in a module.
Post by: speck on May 30, 2013, 10:50:13
yes, created in control panel of elxis  ;D

the problem is not works also with other existing positions, naturally not called in the templates.
Title: Re: Calling module positions in a module.
Post by: webgift on May 30, 2013, 16:39:13
I can distinguish some errors at the module you've attached. Don't send it like this  ;D ;D I am joking!
You have to renter modules by position. So we won't use the module method of elxisDocument class.

So remove the:
$eDoc->modules('modtab1');
with:
$eModule = eFactory::getModule();
echo $eModule->renderPosition($this->modpostab[$i], '', 0);

EDIT BY DATAHELL: The above is absolutely wrong and should not be used! "renderPosition" is a method used by elxisDocument internally. The output of the method should be saved into buffer and not echoed. Don't use that if you don't want to face serious issues!

where $this->modpostab is an array with all of the registered module positions.
I attach you the php file of your module. Use the kdiff3 (http://kdiff3.sourceforge.net/) program in order to find out the changes i have made for you.
Title: Re: Calling module positions in a module.
Post by: speck on May 30, 2013, 18:26:43
I can distinguish some errors at the module you've attached. Don't send it like this  ;D ;D I am joking!
I'm a noob  ;D big noob  ;D and the errors are my daily bread  ;D

Thanks.... now it works...   ::)
But don't worry .. i need time to finish the module  :) because as usual u need update the plug-in too ... i need eliminate jscript conflict for noobs like me  ;D
Title: Re: Calling module positions in a module.
Post by: datahell on May 30, 2013, 20:33:19
The above is absolutely wrong and should not be used! "renderPosition" is a method used by elxisDocument internally.
The output of the method should be saved into buffer and not echoed.
Don't use that if you don't want to face serious issues!

A module can not be executed inside an other module. It's a very bad idea.

[:replmark14:] is an internal mark put by the elxisDocument parser. It is totally correct and normally you should never see that as it is later been replaced by the module's content saved into buffer. The fact that you do see that is because the idea behind your code is wrong. When you execute a module within an other you confuse the Elxis parser the Elxis observer (https://www.elxis.net/docs/developers/core/observer.html), the cache, the head data handler and more... The proper way to add something like the one you want is in the template, not in a module. If you do that inside a module  you need to mimic the elxis parser to have the correct result.
Title: Re: Calling module positions in a module.
Post by: webgift on May 30, 2013, 20:47:36
 ;D ;D Misunderstanding... Sorry Speck!