Drupal 特定术语自动词汇表

发布于 2024-08-17 23:31:04 字数 486 浏览 9 评论 0原文

问候所有帮助者!

我最近一直在阅读和测试 Drupal 功能,我发现这个 CMS 非常可扩展且有趣。我开始研究主题、视图、内容类型等……但我正在寻找在互联网上找不到的东西。

背景:我正在为我的一个非营利组织创建一个新网站,庆祝其成立 10 周年。主要是,这个网站是针对在其规则内具有不同能力的游戏的。我想为不同的能力创建一个术语表。这不是一个很大的挑战。

这就是我想要存档的内容: 有了这个术语表,我想在内容中每次遇到能力时都对其进行描述。

能力词汇表(列表): http://conflitseternels.net/index.php?id=habiletes

每次一内容中遇到能力,它链接到它的描述。

如果您能指导我完成这个要求,我将非常高兴!

谢谢你,威尔

Greetings all helpers!

I have been reading and testing Drupal features recently and I find this CMS very scalable and interesting. I began working with themes, views, content types and ect... but I am looking for something I cannot find on the internet.

Context : I am creating a new website for one non-profit organization of mine for the 10th anniversary. Mainly, this site is for a game that has different abilities within it's rules. I would like to create a glossary for the different abilities. That is not a great challenge.

This is what I want to archive :
With this glossary, I would like to like to the ability description each time it is encountered in a content.

Ability glossary (list) :
http://conflitseternels.net/index.php?id=habiletes

Each time one ability is encountered in the content, it links to it's description.

If you can guide me through the accomplishment of this ask, I would be greatly happy !

Thank you, Will

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

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

发布评论

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

评论(1

柠檬色的秋千 2024-08-24 23:31:04

我发现一个模块似乎可以做类似的事情:Glossify (http://drupal.org/project/glossify )。我自己从未使用过它,但值得一试。如果 Glossify 不适合您,请考虑帮助改进模块,或自己编写自定义模块。

理论上,有两种方法可以将单词转换为链接:保存节点时或显示节点时。在这两种情况下,您都将检查节点中的每个单词,看看它是否与其中一项能力匹配。两种解决方案都有优点和缺点。选择解决方案时,您必须关注性能,因为搜索和替换操作可能会占用大量系统资源,特别是当您有许多用户、长文本和大量功能时。

保存节点时更改内容可以在 Drupal 中通过实现 hook_nodeapi ($op=presave) 来完成。就在内容写入数据库之前,您的 nodeapi 函数发挥了它的魔力。优点:每个节点只执行一次搜索和替换。缺点:添加新能力时,不会在现有节点中添加新链接(除非重新保存节点)。

查看节点时更改内容可以通过实现 hook_nodeapi ($op=view) 或 hook_filter 来完成。这些链接不会保存在数据库中,而是在用户每次查看节点时即时添加。优点:新的能力也会链接到之前保存的节点中。缺点:性能,搜索和替换必须在每个节点视图上运行(尽管缓存可能会部分解决这个问题)。

I have found one module that seems to do something like that: Glossify (http://drupal.org/project/glossify). I have never used it myself, but it's worth a try. If Glossify doesn't work for you, consider helping to improve the module, or write a custom module yourself.

Theoretically, there are two methods to convert the words to links: when the node is saved or when the node is displayed. In both cases, you will be checking every word in a node and see if it matches one of the abilities. Both solutions have advantages and disadvantages. When choosing a solution, you have to keep an eye on performance because search-and-replace actions can take a lot of system resources, especially if you have many users, long texts and lots of abilities.

Altering content when a node is saved can be done in Drupal by implementing hook_nodeapi ($op=presave). Just before the content is written to the database, your nodeapi function does its magic. Advantage: the search-and-replace is performed only once for each node. Disadvantage: no new links will be added in existing nodes when you add a new ability (unless you re-save the node).

Altering content when a node is viewed can be done by implementing hook_nodeapi ($op=view) or hook_filter. The links will not saved in the database, but added on-the-fly every time a user views a node. Advantage: new abilities will also be linked in node saved earlier. Disadvantage: performance, the search-and-replace has to run on every node view (although caching would probably solve this partially).

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