使用 Joomla 1.7 通用类别函数

发布于 2024-12-17 10:35:10 字数 1686 浏览 4 评论 0原文

我相信,从 1.6 开始,有一种通用方法可以在您自己创建的组件中使用“类别”。默认的 Joomla 组件也使用这个。例如:联系人、新闻源和网络链接组件都使用通用 com_categories 功能来实现分类内容。

目前我正在创建一个也有类别的组件,因此我想使用通用的 Joomla 类别函数来实现此目的。

状态:目前我有以下信息:

  1. 我的组件中有一个子菜单“类别”,它链接到通用类别组件,其中有一些额外的选项。这些选项就在那里,因此页面将在保存时重定向回我的组件。这很容易!但是..

我的问题:现在我想向我的类别添加特定字段,比方说:“类别管理员”。

因此,我转到 com_categories 的代码,在以下文件“administrator\components\com_categories\models\category.php”中,有代码(第 270 行)用于查找特定组件代码,如下所示

// Looking first in the component models/forms folder
$path = JPath::clean(JPATH_ADMINISTRATOR."/components/$component/models/forms/$name.xml");

: (就我而言)在文件夹:administrator/components/mycomponent/models/forms/category.xml 中获取特定组件信息。

现在,在 com_categories 的默认category.xml 中有有关编辑屏幕的信息,如下所示:

<field
    name="title"
    type="text"
    label="JGLOBAL_TITLE"
    description="JFIELD_TITLE_DESC"
    class="inputbox"
    size="40"
    required="true"/>

所以类别的标题显然是必需的。

所以我想我向此文件添加一行:

<field
    name="moderator"
    type="text"
    label="JGLOBAL_MODERATOR"
    description="JFIELD_MODERATOR_DESC"
    class="inputbox"
    size="40"
    required="true"/>

除了这还不足以添加输入.. 所以我在administrator/components/com_categories/views/category/edit.php模板中查找提示,了解如何实现这一点。但是没有代码可以为我的组件添加特定的输入(或者我错了;))..

字段添加得非常具体,例如:

<li><?php echo $this->form->getLabel('title'); ?>
<?php echo $this->form->getInput('title'); ?></li>

我还查看了是否可以以某种方式覆盖 edit.php ,但不幸的是我还没有找到了..

简短:有人知道如何将通用字段添加到类别编辑页面吗?

Since 1.6, I believe, there's a generic way to use 'categories' in your own created components. The default Joomla components also use this. For example: the contacts, newsfeeds and weblinks components all use the generic com_categories functionality to achieve categorized content.

Currently I'm creating a component which also has categories so I'd like to use the generic Joomla category functions to achieve this.

The status: Currently I've got the following:

  1. I've got a submenu 'categories' in my component which links to the generic categories component which some extra options. The options are there so the page will be redirected back to my component on save. This was pretty easy! But..

My problem: Now I'd like to add specific fields to my category, let's say: 'Category Moderator'.

So I've walked to the code of com_categories and in the following file 'administrator\components\com_categories\models\category.php' there is code (line 270) to look for specific component code, like the following:

// Looking first in the component models/forms folder
$path = JPath::clean(JPATH_ADMINISTRATOR."/components/$component/models/forms/$name.xml");

So the components looks (in my case) in the folder: administrator/components/mycomponent/models/forms/category.xml for specific component info.

Now, in the default category.xml of com_categories there's information about the edit screen, like the following:

<field
    name="title"
    type="text"
    label="JGLOBAL_TITLE"
    description="JFIELD_TITLE_DESC"
    class="inputbox"
    size="40"
    required="true"/>

So the title of the category is apparantly required..

So I thought I add a line to this file:

<field
    name="moderator"
    type="text"
    label="JGLOBAL_MODERATOR"
    description="JFIELD_MODERATOR_DESC"
    class="inputbox"
    size="40"
    required="true"/>

Except that's not enough to add the input..
So I've looked in the administrator/components/com_categories/views/category/edit.php template for hints, how to achieve this. But there's no code to add specific inputs for my component (or I'm wrong ;))..

Fields are added pretty specific like:

<li><?php echo $this->form->getLabel('title'); ?>
<?php echo $this->form->getInput('title'); ?></li>

I've also looked if I can overide the edit.php somehow, but unfortunately I haven't found it..

Short: Anyone knows how to add generic fields to the category edit page?

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

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

发布评论

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

评论(1

淡紫姑娘! 2024-12-24 10:35:10

您可以通过使用插件来完成此操作(您可以查看内置的用户配置文件插件作为示例: /plugins/user/profile )。但如果您想添加“类别主持人”,我认为您可以使用 ACL 来实现。

You can do it by using plugins ( you can take a look at the built-in user profile plugin for an example: /plugins/user/profile ). But if you want to add a "Category Moderator", I think you could achieve it using ACL.

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