开发者

How to embed modules on pages?

I have created my own extension and modules. I can view the modules fine, by going to their URL. However, now I want to embed them on a page, much like a content class. How do I go about doing that?

开发者_运维知识库

Thanks!


You have to create template operator or function and use them in template.


It is not possible to "embed" a module in a page except if the module which is called do it at the PHP level.

For instance, it's possible to write this :

$module = eZModule::findModule( 'content' );
$result = $module->run( 'history', array( 1 ) );

But if you want to display anything related to your module, you should declare that your extension contains some templates and override some templates.

Let's say that you would like to make your own register module.

Step 1, you may have to add this in your_extension/settings/design.ini.append.php :

[ExtensionSettings]
DesignExtensions[]=your_extension

So you are now able to add your own user/register.tpl

This template contains a form like this :

<form action={'/user/register'|ezurl}...

So you just need to copy the template but with :

<form action={'/your_module/register'|ezurl}...

Now let's say that your template is supposed to display some informations related to your module. You may have to define some fetch functions so you would be able to write something like this:

{def $nb = fetch('your_module','beta_accounts')}

<h2>Hurry up! There are only {$nb|wash} available accounts for free!</h2>
<form action={'/your_module/register'|ezurl} method="POST">
   ...
</form>

I hope that it will help...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜