简体   繁体   English

前端的 Joomla JCE 编辑器:如何将“创建日期”字段添加到“发布”字段集中?

[英]Joomla JCE Editor in frontend: how to add "Create date" field to the "Publishing" fieldset?

In a Joomla website (Joomla 2.5), with JCE Editor, I want to offer more comfort for frontend editing.在 Joomla 网站 (Joomla 2.5) 中,使用 JCE 编辑器,我想为前端编辑提供更多舒适度。 Specifically, I want to give my editing staff the option to set the "Create Date" value of articles manually.具体来说,我想让我的编辑人员可以选择手动设置文章的“创建日期”值。

Background: In the backend, "Create Date" can be set manually anyway.背景:在后端,无论如何都可以手动设置“创建日期”。 In the frontend, there is so far no such option, because the frontend editing form does not include the "Create Date" field.在前端,目前还没有这样的选项,因为前端编辑表单不包括“创建日期”字段。 It includes, however, the "Start publishing" field and the "Finish publishing" field.但是,它包括“开始发布”字段和“完成发布”字段。

(I also know that it is possible the add the "Create Date" field to the frontend editing form, because I had a similar website tweaked to provide this feature years ago, but I cannot remember how I did this, or who did it for me.) (我也知道可以将“创建日期”字段添加到前端编辑表单中,因为几年前我有一个类似的网站经过调整以提供此功能,但我不记得我是如何做到的,或者是谁为谁做的我。)

The fieldset in question is part of the front end editing form:有问题的字段集是前端编辑表单的一部分:

编辑表单的“发布”字段集

And this is the fieldset's source code in the browser:这是浏览器中字段集的源代码:

在此处输入图片说明

The way to go will be, of course, to add here one more line for the "Create Date" field, such as:当然,要走的路是在“创建日期”字段中再添加一行,例如:

<div class="formelm><label id="jform... >Create Date</label></input id="jform... ></div>

I need:我需要:

  • A tip where to find this in the php files on the server, to tweak it在服务器上的 php 文件中找到它并对其进行调整的提示

  • A tip what has to be added to other php files there , because I suppose just adding the field in the php-file that creates the edit form is not enough, and I have to tweak other files so that the form is able to communicate with the database on the server...必须添加到其他 php 文件的提示,因为我认为仅在创建编辑表单的 php 文件中添加字段是不够的,我必须调整其他文件,以便表单能够与服务器上的数据库...

After some searching in Joomla's php-files, I have found the solution myself.在 Joomla 的 php 文件中进行了一些搜索后,我自己找到了解决方案。 Here it is:这里是:

The fieldsets that are presented to the frontend visitor at the time of frontend editing, are defined in the following file:在前端编辑时呈现给前端访问者的字段集在以下文件中定义:

/components/com_content/views/form/tmpl/edit.php /components/com_content/views/form/tmpl/edit.php

or in earlier versions of Joomla:或在早期版本的 Joomla 中:

/components/com_content/views/article/tmpl/form.php /components/com_content/views/article/tmpl/form.php

Here is what is to be added (including some context code);这是要添加的内容(包括一些上下文代码); look out for my comments "Addition by CG":请注意我的评论“CG添加”:

<fieldset>
    <legend><?php echo JText::_('COM_CONTENT_PUBLISHING'); ?></legend>
    <div class="formelm">
    <?php echo $this->form->getLabel('catid'); ?>
    <span class="category">
        <?php   echo $this->form->getInput('catid'); ?>
    </span>

    </div>
    <div class="formelm">
    <?php echo $this->form->getLabel('created_by_alias'); ?>
    <?php echo $this->form->getInput('created_by_alias'); ?>
    </div>

<?php if ($this->item->params->get('access-change')): ?>
    <div class="formelm">
    <?php echo $this->form->getLabel('state'); ?>
    <?php echo $this->form->getInput('state'); ?>
    </div>

    <div class="formelm">
    <?php echo $this->form->getLabel('featured'); ?>
    <?php echo $this->form->getInput('featured'); ?>
    </div>

<!-- Addition by CG to make the "Create Date" field available --> 

    <div class="formelm">
    <?php echo $this->form->getLabel('created'); ?>
    <?php echo $this->form->getInput('created'); ?>
    </div>

<!-- End of addition by CG -->

    <div class="formelm">
    <?php echo $this->form->getLabel('publish_up'); ?>
    <?php echo $this->form->getInput('publish_up'); ?>
    </div>
    <div class="formelm">
    <?php echo $this->form->getLabel('publish_down'); ?>
    <?php echo $this->form->getInput('publish_down'); ?>
    </div>

<?php endif; ?>
    <div class="formelm">
    <?php echo $this->form->getLabel('access'); ?>
    <?php echo $this->form->getInput('access'); ?>
    </div>
    <?php if (is_null($this->item->id)):?>
        <div class="form-note">
        <p><?php echo JText::_('COM_CONTENT_ORDERING'); ?></p>
        </div>
    <?php endif; ?>
</fieldset>

That's it, actually.实际上就是这样。 More is not necessary.更多是没有必要的。 The new field is fully usable and communicates with the website database.新字段完全可用并与网站数据库通信。

However, if used so, the frontend user will get displayed in the form an ugly "JGLOBAL_FIELD_CREATED_LABEL" string instead of a reasonably named label.但是,如果这样使用,前端用户将以丑陋的“JGLOBAL_FIELD_CREATED_LABEL”字符串的形式显示,而不是合理命名的标签。

In order to get displayed a nice name (eg "Create date"), I recommend creating a language override in Joomla's Language Manager in the backend;为了显示一个好听的名字(例如“创建日期”),我建议在后端的 Joomla 语言管理器中创建一个语言覆盖; or you can override the values manually in the respective language files (eg en-GB.ini, or, if stored in the "override" folder: en-GB.override.ini), eg so:或者您可以手动覆盖相应语言文件中的值(例如 en-GB.ini,或者,如果存储在“覆盖”文件夹中:en-GB.override.ini),例如:

JGLOBAL_FIELD_CREATED_LABEL="Create date, or date of the event"

Note that there are two places in Joomla 2.5 where language settings are stored, one in the main folder/language, the other in administrator/language.请注意,Joomla 2.5 中有两个地方存储语言设置,一个在主文件夹/语言中,另一个在管理员/语言中。

As a result, the "Publishing" fieldset in your frontend editing form will look like因此,前端编辑表单中的“发布”字段集将如下所示修改了发布字段集,添加了一个字段 so:所以:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM