如何在我们自己的插件 elgg 中覆盖用户个人资料视图

发布于 2024-09-05 10:42:56 字数 488 浏览 3 评论 0原文

我在我的 elgg 网站中创建了一个名为“adv”的新插件。

在这个插件中,我列出了用户。它使用其他 elgg 插件“配置文件”中的视图

,即页面 profile/views/default/profile/listing.php。

现在我需要在每个用户的现有视图。所以我必须编辑配置文件插件,主要是页面 profile/views/default/profile/listing.php

但我怎样才能做到这一点,而不修改 elggs 默认插件“配置文件” '。

我尝试过一种方法,从 profile/views/default/profile 复制文件夹“profile”并将其放入 adv/views/default/ 中。但它没有]

是否有通过编辑其他插件向用户视图添加新链接的解决方案,仅编辑我们自己的插件示例“adv”。

I have created a new plugin named 'adv' in my elgg site.

And in this plugin iam listing the users.Which using the view from other elgg plugin 'profile

ie the page profile/views/default/profile/listing.php.

Now i need to set a link in the existing view of each user.So i have to edit the profile plugin , mainly the page profile/views/default/profile/listing.php

But how can i do this, without modifying elggs default plugin 'profile'.

I have tried a method that i have copied the folder 'profile' from profile/views/default/profile and put it in adv/views/default/.But it donot working.]

Is any solution for adding new link to the user view with editing other plugin, only editing our own plugin example 'adv'.

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

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

发布评论

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

评论(2

呆头 2024-09-12 10:42:56

您需要覆盖配置文件/列表视图,但仅当 Elgg 渲染插件页面时才需要,而不是干扰可能想要使用核心配置文件/列表视图的其他插件。

我解决这个问题的方法如下:

  1. 创建一个新目录来保存您想要覆盖的视图。
    对于您的情况,我将在 your_site_root/mod 中创建“adv/views/mod”目录。

  2. 将您想要覆盖的视图添加到此目录中。
    同样,根据您的情况,将 profile/views/default/profile/listing.php 复制到以下位置:adv/views/mod/default/profile/listing.php

  3. 对新创建的视图进行修改。
    您现在可以根据自己的喜好安全地修改 adv/views/mod/default/profile/listing.php 文件

  4. 告诉 Elgg 在插件渲染页面时使用特殊视图。这意味着您必须从 page_handler 函数或 page_handler 引用的 php 文件中调用 set_view_location(..) 方法,并且通常为视图准备数据(例如 index.php 或 read.php,但是我不知道你的插件的文件层次结构)
    因此,在您的情况下,您可以致电 set_view_location('profile/listing', $CONFIG->pluginspath . 'adv/views/mod/');来自您的 page_handler 或来自上述文件之一。
    确保 $CONFIG 存在并且通过引用它可用(全局 $CONFIG)。

You'll need to override the profile/listing view, but only when Elgg is rendering your plugin's pages, not to interfere with other plugins that might want to use the core profile/listing view.

My approach to this problem is the following:

  1. Create a new directory that will hold the views that you want to override.
    In your case, I'd create the "adv/views/mod" directory within your_site_root/mod.

  2. Add the view you'd like to override into this directory.
    Again, your case, copy the profile/views/default/profile/listing.php to the following location: adv/views/mod/default/profile/listing.php

  3. Make your modifications to the newly created view.
    You can now safely modify the adv/views/mod/default/profile/listing.php file to your liking

  4. Tell Elgg to use the special view when your plugin is rendering the page. This means you'll have to call the set_view_location(..) method either from your page_handler function, or the php files that are referenced by your page_handler and usually prepare the data for the views (like index.php or read.php, but I don't know your plugin's file hierarchy)
    So in your case you'd call set_view_location('profile/listing', $CONFIG->pluginspath . 'adv/views/mod/'); either from your page_handler or from one of the above files.
    Make sure that $CONFIG is present and available by referencing it (global $CONFIG).

错々过的事 2024-09-12 10:42:56

请检查站点管理中是否禁用了“使用视图文件路径缓存(推荐)”。因为elgg使用硬视图缓存。或者从数据目录中删除view_cache文件。并且还让用户您的插件位于插件列表中的“配置文件”下方。

Please check if "Use view filepath cache (recommended)", is disabled in the site administration. Because elgg uses hard view cache. Or delete the view_cache file from the data directory. And also make user your plugin is below the "Profile" in the plugin list.

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