Creating multiple content in a module

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
brippon
Forum Members
Forum Members
Posts: 18
Joined: Wed Feb 07, 2007 10:28 pm

Creating multiple content in a module

Post 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
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Creating multiple content in a module

Post 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.
Last edited by Wishbone on Tue Mar 17, 2009 8:52 pm, edited 1 time in total.
User avatar
plger
Forum Members
Forum Members
Posts: 196
Joined: Wed Oct 15, 2008 10:38 am

Re: Creating multiple content in a module

Post 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...
Last edited by plger on Sun Mar 22, 2009 9:36 am, edited 1 time in total.
Post Reply

Return to “Developers Discussion”