Page 1 of 1

Creating multiple content in a module

Posted: Tue Mar 17, 2009 12:23 am
by brippon
I want my module to create multiple pieces of content on a linked page, to be output by various content blocks in my detailpage.

I think I've worked out that the $returnid on the CreateLink() needs to be the id of the detail page I want to use for output, but by default my output goes into {content}.

How do I create several contents? I assume I have to assign them to Smarty variables, but then can I get at them?

I'm sure I've seen something by Ted or CG about this, but I can't find it after an hour of searcching...

Also/alternatively... How can I get at the page URL params within my module - e.g. given
$link = CreateLink($id, 'action1', $returnid, 'Action 1', array('pid'=>$pid));

and on the action1 page a call of
{cms_module module='MyModule' action='action2'}
how in action.action2.php can I get the value of pid?

Thanks in advance, Brian

Re: Creating multiple content in a module

Posted: Tue Mar 17, 2009 8:48 pm
by Wishbone
You can create multiple content blocks by doing the following in your template:

Code: Select all

{content}

{content block="foo1"}

{content block="foo2"}
etc.

When editing/adding a page using that template, you will see a TinyMCE text box for each content block.

Re: Creating multiple content in a module

Posted: Sun Mar 22, 2009 9:30 am
by plger
brippon wrote: I think I've worked out that the $returnid on the CreateLink() needs to be the id of the detail page I want to use for output, but by default my output goes into {content}.
CreateLink (http://www.cmsmadesimple.org/api/class_cms_module.html#41eb0ceb35a9902845af261fa01564a5) has a $inline parameter that toggles whether the module action will replace the {content} tag or the link itself (it's cms_module tag).
Also/alternatively... How can I get at the page URL params within my module - e.g. given
$link = CreateLink($id, 'action1', $returnid, 'Action 1', array('pid'=>$pid));
and on the action1 page a call of
{cms_module module='MyModule' action='action2'}
how in action.action2.php can I get the value of pid?
I'm not sure I understand exactly what you mean, but if your question is how to retrieve parameters meant for another instance of your module, to my knowledge there is no very fast way. I would see two possibilities :
If your {cms_module module='MyModule' action='action2'} is after the module action, you can simply use action1 to assign your pid to smarty and afterwards pass it to the action2 as a parameter. In action1 you would have something like :

Code: Select all

$this->smarty->assign("pid", $phpvar_for_pid);
And your action2 tag would be :

Code: Select all

{cms_module module='MyModule' action='action2' pid=$pid}
Alternatively, in action1 you could store it in a module variable and retrieve it in action2 ($this->somevarname for both), but again this means that the call for action2 should be after.
Otherwise, you'd have to retrieve the pid from the url...