简体   繁体   中英

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

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

After some searching in Joomla's php-files, I have found the solution myself. 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

or in earlier versions of Joomla:

/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":

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

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; 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:

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.

As a result, the "Publishing" fieldset in your frontend editing form will look like修改了发布字段集,添加了一个字段 so:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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