Joomla! Template Override:

Custom Fields unter "Inhalt" im Backend


Hierbei handelt es sich um ein Override vom Administrationstemplate "ISIS". 

Es ermöglicht es, die angelegten Custom Fields nicht in eigenen Reitern innerhalb eines Artikels aufzulisten, sondern verlagert diese direkt auf den ersten Reiter "Inhalt". Dies hat den Vorteil, dass der Kunde alle wichtigen und auszufüllenden Informationen gebündelt auf einer Seite angezeigt bekommt.

Abzulegen sind die Dateien wie folgt:

  • / administrator / templates / isis / html / com_content / article / edit.php
  • / administrator / templates / isis / html / layouts / joomla / edit / customFields.php
  • / administrator / templates / isis / html / layouts / joomla / edit / params.php

Benötigte Override-Dateien


  • <?php
    /**
     * @package     Joomla.Administrator
     * @subpackage  com_content
     *
     * @copyright   Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
     * @license     GNU General Public License version 2 or later; see LICENSE.txt
     */
    
    defined('_JEXEC') or die;
    
    use Joomla\Registry\Registry;
    
    // Include the component HTML helpers.
    JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
    
    JHtml::_('behavior.formvalidator');
    JHtml::_('behavior.keepalive');
    JHtml::_('formbehavior.chosen', '#jform_catid', null, array('disable_search_threshold' => 0 ));
    JHtml::_('formbehavior.chosen', 'select');
    
    $this->configFieldsets  = array('editorConfig');
    $this->hiddenFieldsets  = array('basic-limited');
    $this->ignore_fieldsets = array('jmetadata', 'item_associations');
    
    // Create shortcut to parameters.
    $params = clone $this->state->get('params');
    $params->merge(new Registry($this->item->attribs));
    
    $app = JFactory::getApplication();
    $input = $app->input;
    
    $assoc = JLanguageAssociations::isEnabled();
    
    JFactory::getDocument()->addScriptDeclaration('
    	Joomla.submitbutton = function(task)
    	{
    		if (task == "article.cancel" || document.formvalidator.isValid(document.getElementById("item-form")))
    		{
    			jQuery("#permissions-sliders select").attr("disabled", "disabled");
    			' . $this->form->getField('articletext')->save() . '
    			Joomla.submitform(task, document.getElementById("item-form"));
    
    			// @deprecated 4.0  The following js is not needed since 3.7.0.
    			if (task !== "article.apply")
    			{
    				window.parent.jQuery("#articleEdit' . (int) $this->item->id . 'Modal").modal("hide");
    			}
    		}
    	};
    ');
    
    // In case of modal
    $isModal = $input->get('layout') == 'modal' ? true : false;
    $layout  = $isModal ? 'modal' : 'edit';
    $tmpl    = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? '&tmpl=component' : '';
    ?>
    
    <form action="<?php echo JRoute::_('index.php?option=com_content&layout=' . $layout . $tmpl . '&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="item-form" class="form-validate">
    
    	<?php echo JLayoutHelper::render('joomla.edit.title_alias', $this); ?>
    
    	<div class="form-horizontal">
    		<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'general')); ?>
    
    		<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'general', JText::_('COM_CONTENT_ARTICLE_CONTENT')); ?>
    		<div class="row-fluid">
    			<div class="span9">
    				<fieldset class="adminform">
    					<?php echo JLayoutHelper::render('joomla.edit.customFields', $this); ?>
    					<?php echo $this->form->getInput('articletext'); ?>
    				</fieldset>
    			</div>
    			<div class="span3">
    				<?php echo JLayoutHelper::render('joomla.edit.global', $this); ?>
    			</div>
    		</div>
    		<?php echo JHtml::_('bootstrap.endTab'); ?>
    
    		<?php // Do not show the images and links options if the edit form is configured not to. ?>
    		<?php if ($params->get('show_urls_images_backend') == 1) : ?>
    			<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'images', JText::_('COM_CONTENT_FIELDSET_URLS_AND_IMAGES')); ?>
    			<div class="row-fluid form-horizontal-desktop">
    				<div class="span6">
    					<?php echo $this->form->renderField('images'); ?>
    					<?php foreach ($this->form->getGroup('images') as $field) : ?>
    						<?php echo $field->renderField(); ?>
    					<?php endforeach; ?>
    				</div>
    				<div class="span6">
    					<?php foreach ($this->form->getGroup('urls') as $field) : ?>
    						<?php echo $field->renderField(); ?>
    					<?php endforeach; ?>
    				</div>
    			</div>
    			<?php echo JHtml::_('bootstrap.endTab'); ?>
    		<?php endif; ?>
    
    		<?php $this->show_options = $params->get('show_article_options', 1); ?>
    		<?php echo JLayoutHelper::render('joomla.edit.params', $this); ?>
    
    		<?php // Do not show the publishing options if the edit form is configured not to. ?>
    		<?php if ($params->get('show_publishing_options', 1) == 1) : ?>
    			<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'publishing', JText::_('COM_CONTENT_FIELDSET_PUBLISHING')); ?>
    			<div class="row-fluid form-horizontal-desktop">
    				<div class="span6">
    					<?php echo JLayoutHelper::render('joomla.edit.publishingdata', $this); ?>
    				</div>
    				<div class="span6">
    					<?php echo JLayoutHelper::render('joomla.edit.metadata', $this); ?>
    				</div>
    			</div>
    			<?php echo JHtml::_('bootstrap.endTab'); ?>
    		<?php endif; ?>
    
    
    		<?php if ( ! $isModal && $assoc) : ?>
    			<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'associations', JText::_('JGLOBAL_FIELDSET_ASSOCIATIONS')); ?>
    			<?php echo $this->loadTemplate('associations'); ?>
    			<?php echo JHtml::_('bootstrap.endTab'); ?>
    		<?php elseif ($isModal && $assoc) : ?>
    			<div class="hidden"><?php echo $this->loadTemplate('associations'); ?></div>
    		<?php endif; ?>
    
    		<?php if ($this->canDo->get('core.admin')) : ?>
    			<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'editor', JText::_('COM_CONTENT_SLIDER_EDITOR_CONFIG')); ?>
    			<?php echo $this->form->renderFieldset('editorConfig'); ?>
    			<?php echo JHtml::_('bootstrap.endTab'); ?>
    		<?php endif; ?>
    
    		<?php if ($this->canDo->get('core.admin')) : ?>
    			<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'permissions', JText::_('COM_CONTENT_FIELDSET_RULES')); ?>
    				<?php echo $this->form->getInput('rules'); ?>
    			<?php echo JHtml::_('bootstrap.endTab'); ?>
    		<?php endif; ?>
    
    		<?php echo JHtml::_('bootstrap.endTabSet'); ?>
    
    		<input type="hidden" name="task" value="" />
    		<input type="hidden" name="return" value="<?php echo $input->getCmd('return'); ?>" />
    		<input type="hidden" name="forcedLanguage" value="<?php echo $input->get('forcedLanguage', '', 'cmd'); ?>" />
    		<?php echo JHtml::_('form.token'); ?>
    	</div>
    </form>
  • <?php
    /**
     * @package     Joomla.Site
     * @subpackage  Layout
     *
     * @copyright   Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
     * @license     GNU General Public License version 2 or later; see LICENSE.txt
     */
    
    defined('JPATH_BASE') or die;
    
    $app       = JFactory::getApplication();
    $form      = $displayData->getForm();
    $fieldSets = $form->getFieldsets();
    
    if (empty($fieldSets))
    {
    	return;
    }
    
    $ignoreFieldsets = $displayData->get('ignore_fieldsets') ?: array();
    $ignoreFields    = $displayData->get('ignore_fields') ?: array();
    $extraFields     = $displayData->get('extra_fields') ?: array();
    $tabName         = $displayData->get('tab_name') ?: 'myTab';
    
    // These are required to preserve data on save when fields are not displayed.
    $hiddenFieldsets = $displayData->get('hiddenFieldsets') ?: array();
    
    // These are required to configure showing and hiding fields in the editor.
    $configFieldsets = $displayData->get('configFieldsets') ?: array();
    
    // Handle the hidden fieldsets when show_options is set false
    
    
    // Loop again over the fieldsets
    //var_dump($fieldSets);die;
    foreach ($fieldSets as $name => $fieldSet)
    {
    	// Ensure any fieldsets we don't want to show are skipped (including repeating formfield fieldsets)
    	if ((isset($fieldSet->repeat) && $fieldSet->repeat === true)
    		|| in_array($name, $ignoreFieldsets)
    		|| (!empty($configFieldsets) && in_array($name, $configFieldsets, true))
    		|| (!empty($hiddenFieldsets) && in_array($name, $hiddenFieldsets, true))
    	)
    	{
    		continue;
    	}
    
    	// Determine the label
    	if (!empty($fieldSet->label))
    	{
    		$label = JText::_($fieldSet->label);
    	}
    	else
    	{
    		$label = strtoupper('JGLOBAL_FIELDSET_' . $name);
    		if (JText::_($label) === $label)
    		{
    			$label = strtoupper($app->input->get('option') . '_' . $name . '_FIELDSET_LABEL');
    		}
    		$label = JText::_($label);
    	}
    
    	// Start the tab
    
    	// Include the description when available
    	if (isset($fieldSet->description) && trim($fieldSet->description))
    	{
    		echo '<p class="alert alert-info">' . $this->escape(JText::_($fieldSet->description)) . '</p>';
    	}
    
    	// The name of the fieldset to render
    	$displayData->fieldset = $name;
    
    	// Force to show the options
    	$displayData->showOptions = false;
    
    	// Render the fieldset
    
    
    	if($fieldSet->name != 'basic'){
    		echo JLayoutHelper::render('joomla.edit.fieldset', $displayData);
    	}
    
    
    	// End the tab
    }
    
  • <?php
    /**
     * @package     Joomla.Site
     * @subpackage  Layout
     *
     * @copyright   Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
     * @license     GNU General Public License version 2 or later; see LICENSE.txt
     */
    
    defined('JPATH_BASE') or die;
    
    $app       = JFactory::getApplication();
    $form      = $displayData->getForm();
    $fieldSets = $form->getFieldsets();
    $view = $app->input->get('view');
    
    if (empty($fieldSets))
    {
    	return;
    }
    else{
    	if($view == 'article'){
    		$filtered = array();
    
    		foreach($fieldSets as $key => $value){
    			if(preg_match('/fields-\d/',$key))
    				$filtered[] = $value;
    		}
    		foreach($filtered as $singleField){
    			unset($fieldSets[$singleField->name]);
    		}
    	}
    }
    //var_dump($fieldSets);
    $ignoreFieldsets = $displayData->get('ignore_fieldsets') ?: array();
    $ignoreFields    = $displayData->get('ignore_fields') ?: array();
    $extraFields     = $displayData->get('extra_fields') ?: array();
    $tabName         = $displayData->get('tab_name') ?: 'myTab';
    
    // These are required to preserve data on save when fields are not displayed.
    $hiddenFieldsets = $displayData->get('hiddenFieldsets') ?: array();
    
    // These are required to configure showing and hiding fields in the editor.
    $configFieldsets = $displayData->get('configFieldsets') ?: array();
    
    $view = $app->input->get('view');
    // Handle the hidden fieldsets when show_options is set false
    
    // Loop again over the fieldsets
    foreach ($fieldSets as $name => $fieldSet)
    {
    	// Ensure any fieldsets we don't want to show are skipped (including repeating formfield fieldsets)
    	if ((isset($fieldSet->repeat) && $fieldSet->repeat === true)
    		|| in_array($name, $ignoreFieldsets)
    		|| (!empty($configFieldsets) && in_array($name, $configFieldsets, true))
    		|| (!empty($hiddenFieldsets) && in_array($name, $hiddenFieldsets, true))
    	)
    	{
    		continue;
    	}
    
    	// Determine the label
    	if (!empty($fieldSet->label))
    	{
    		$label = JText::_($fieldSet->label);
    	}
    	else
    	{
    		$label = strtoupper('JGLOBAL_FIELDSET_' . $name);
    		if (JText::_($label) === $label)
    		{
    			$label = strtoupper($app->input->get('option') . '_' . $name . '_FIELDSET_LABEL');
    		}
    		$label = JText::_($label);
    	}
    
    	// Start the tab
    	echo JHtml::_('bootstrap.addTab', $tabName, 'attrib-' . $name, $label);
    
    	// Include the description when available
    	if (isset($fieldSet->description) && trim($fieldSet->description))
    	{
    		echo '<p class="alert alert-info">' . $this->escape(JText::_($fieldSet->description)) . '</p>';
    	}
    
    	// The name of the fieldset to render
    	$displayData->fieldset = $name;
    
    	// Force to show the options
    	$displayData->showOptions = true;
    
    	// Render the fieldset
    	echo JLayoutHelper::render('joomla.edit.fieldset', $displayData);
    
    	// End the tab
    	echo JHtml::_('bootstrap.endTab');
    }


whykiki




Fehler melden

Bitte beachte unsere Datenschutzerklärung

Alle mit * markierten Felder werden benötigt um eine E-Mail zu senden.