如何在页面中嵌入模块?

发布于 2024-08-12 06:59:38 字数 89 浏览 4 评论 0原文

我创建了自己的扩展和模块。我可以通过访问模块的 URL 来很好地查看模块。但是,现在我想将它们嵌入到页面上,就像内容类一样。我该如何去做呢?

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

娇女薄笑 2024-08-19 06:59:38

您必须创建模板运算符或函数并在模板中使用它们。

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

愁杀 2024-08-19 06:59:38

除非调用的模块是在 PHP 级别执行的,否则不可能将模块“嵌入”到页面中。

例如,可以这样写:

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

但是如果您想显示与您的模块相关的任何内容,您应该声明您的扩展包含一些模板并覆盖一些模板。

假设您想制作自己的寄存器模块。

第 1 步,您可能需要在 your_extension/settings/design.ini.append.php 中添加此内容:

[ExtensionSettings]
DesignExtensions[]=your_extension

这样您现在就可以添加自己的 user/register.tpl

该模板包含这样的表单:

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

因此您只需复制该模板,但使用:

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

现在假设您的模板应该显示一些与您的模块相关的信息。您可能必须定义一些获取函数,以便你可以写这样的东西:

{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>

我希望它会有所帮助......

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文