Display module output portion

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
nervino
Power Poster
Power Poster
Posts: 448
Joined: Sun Dec 28, 2008 12:15 pm
Location: Roma, Italy

Display module output portion

Post by nervino »

Hi, I have to display part of the content of my module output in a sidebar.

1) In the template defined in the admin panel of CMSMS, I have something like this:

<div id="central_content">{content}</div>

and

<div id="sidebar">(here I want to display a form)</div>

2) In a CMSMS page I call my module
{cms_module module="mymodule"}

At the moment, all the output generated by "mymodule" is displayed in the "content" DIV, of course.
I need to display in the "sidebar" only a little part of the entire output (a form).

I have read the forum and found that the {content_module} tag could maybe solve my problem; but I didn't understand how to use it.

I know I can call, for example:
{content_module block='form' module='mymodule'}
in the template. But, how can assign, in my module's php code, the form to block='form'?

Is there another, maybe better, way to acheive this?

(I hope I clearly explained what I need).

thanks
uniqu3

Re: Display module output portion

Post by uniqu3 »

You could add assign to your module template for example:

Code: Select all

{assign var='is_module' value='1'}
And edit that module template to contain </div><div id="sidebar">form code</div>

Then in your page template on start of it add:

Code: Select all

{content assign='my_content'}
Now in your page tempalte where your content is:

Code: Select all

{if isset($is_module)}
<div id="central_content">{$my_content}
{else}
<div id="central_content">{$my_content}</div>

<div id="sidebar">Some other sidebar content that is shown when no module</div>
{/if}
Hope you get the point.
nervino
Power Poster
Power Poster
Posts: 448
Joined: Sun Dec 28, 2008 12:15 pm
Location: Roma, Italy

Re: Display module output portion

Post by nervino »

uniqu3 wrote: Hope you get the point.
I think so. So I have to edit the module template (.tpl under templates dir of my module).
I hoped there was another way to have the form displayed in the sidebar, just editing the main template of the cms.

I also tried to use {capture}, but without success:
in module's template:
{capture assign='myform'}THE FORM {/capture}

then, in the head of the main cms template, I put:
{capture}{content}{/capture}

and tried to display the form in this way in the body.
<div id="sidebar">{$myform}</div>

But doesn't work.


Thank you uniqu3!
uniqu3

Re: Display module output portion

Post by uniqu3 »

What module do you try to use? Most of module templates can be edited in backend, no need to mess with original .tpl files these are used for sample templates.
nervino
Power Poster
Power Poster
Posts: 448
Joined: Sun Dec 28, 2008 12:15 pm
Location: Roma, Italy

Re: Display module output portion

Post by nervino »

It is a module I'm developing
Duketown

Re: Display module output portion

Post by Duketown »

nervino,

According to me it is better to prepare one php that displays the content. Yet another prepares the sidebar material. Next prepare a template (that will be connected to the page) and in the sidebar part of the template call your module using {cms_module module='MyModule' display=sidebar} and in the content part of the page use {cms_module module='MyModule' display=content}.

Duketown

PS. will it be a module for the community (or later on maybe)?
nervino
Power Poster
Power Poster
Posts: 448
Joined: Sun Dec 28, 2008 12:15 pm
Location: Roma, Italy

Re: Display module output portion

Post by nervino »

Thank you, I'll try your suggestions.

No, the module is an application for a customer of mine, very specific and of no interest for others.
Post Reply

Return to “Developers Discussion”