Language Change ? ? Failure

User tests: Successful: Unsuccessful:

avatar ceford
ceford
8 Dec 2021

Pull Request for Issue #31385 and related to #31396. Revised version of #31408

Summary of Changes

Added code so that field groups can have alternatives to ul layouts and headings.

Testing Instructions

Apply the patch

Create two field groups:
Ingredients
Set Options / Render Tag to ul
Procedure
Set Options / Render Tag to ol

Create fields with Ingredients as Field Group
with Options / Render Options / Label set to Hide (Optional)
Item 1
Item 2
Item 3

Create fields with Procedure as Field Group
with Options / Render Options / Label set to Hide (Optional)
Stage 1
Stage 2
Stage 3

Edit an article
Fill out the Ingredients form Tab
Water
Tea
Milk
Fill out the Procedure form Tab
Boil the water
Pour the water on the tea
Add the milk

Actual result BEFORE applying this Pull Request

A single unordered list

Expected result AFTER applying this Pull Request

image

Documentation Changes Required

Yes - I will do that when merged.

avatar ceford ceford - open - 8 Dec 2021
avatar ceford ceford - change - 8 Dec 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 8 Dec 2021
Category Administration com_fields Language & Strings Front End
avatar ceford ceford - change - 8 Dec 2021
Labels Added: Language Change ?
avatar brianteeman brianteeman - test_item - 8 Dec 2021 - Tested unsuccessfully
avatar brianteeman
brianteeman - comment - 8 Dec 2021

I have tested this item ? unsuccessfully on 27299d6

Tested with blog sample data and the front end displays

Warning: Undefined property: stdClass::$group_params in C:\htdocs\joomla-cms\components\com_fields\layouts\fields\render.php on line 77


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36265.
avatar ceford
ceford - comment - 8 Dec 2021

Sorry, I am confused - is that extra tab before ->bind supposed to be there or not?

avatar ceford
ceford - comment - 8 Dec 2021

When fixing the white space in FieldsModel.php I inadvertently reverted the line that caused Brian's test to fail.

avatar dgrammatiko
dgrammatiko - comment - 8 Dec 2021

This is totally the wrong solution. A proper solution is to have Layouts that are selectable at the field group level. Then, since layouts are overridable, people could create a simple override for every case. In sort, please use the existing platform architecture instead of monkey patching things...

My 2c

avatar richard67
richard67 - comment - 8 Dec 2021

Sorry, I am confused - is that extra tab before ->bind supposed to be there or not?

See my new review comments, this time with suggestions.

avatar brianteeman
brianteeman - comment - 8 Dec 2021

The biggest problem with this PR is that by using default values it changes all existing field groups

avatar Quy
Quy - comment - 8 Dec 2021

Sorry, I am confused - is that extra tab before ->bind supposed to be there or not?

In general, please do not include unrelated changes such as coding style in order to not pollute the PR. It should be done in a separate PR. Thanks.

avatar ceford ceford - change - 8 Dec 2021
The description was changed
avatar ceford ceford - edited - 8 Dec 2021
avatar ceford
ceford - comment - 8 Dec 2021

I give up! What seemed like a simple problem a year ago, only having bulleted lists available for fields even when the field is an image, remains the status quo. See #31396


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36265.

avatar richard67
richard67 - comment - 8 Dec 2021

@ceford Please don’t give up. It was not my intention to block you, I only wanted the unrelated code style changes to be reverted so that drone passes. Sorry if I have confused you with that.

avatar Quy
Quy - comment - 8 Dec 2021

@ceford Please don't be discouraged and take it the wrong way. My suggestion is to only help you in your contributions which we appreciate very much!!!

avatar dgrammatiko
dgrammatiko - comment - 8 Dec 2021

@ceford so I checked the existing code and I found some interesting things

  • The templates overrides creator correctly lists the layouts for com_fields:

Screenshot 2021-12-08 at 21 46 46

  • so an override is just a click
    Screenshot 2021-12-08 at 21 47 01

  • then anyone can do whatever they want in that file.

Eg my test code on templates/cassiopeia/html/layouts/com_fields/fields/render.php was

templates/cassiopeia/html/layouts/com_fields/fields/render.php
<?php
/**
 * @package     Joomla.Site
 * @subpackage  com_fields
 *
 * @copyright   (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;

use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;

// Check if we have all the data
if (!array_key_exists('item', $displayData) || !array_key_exists('context', $displayData))
{
	return;
}

// Setting up for display
$item = $displayData['item'];

if (!$item)
{
	return;
}

$context = $displayData['context'];

if (!$context)
{
	return;
}

$parts     = explode('.', $context);
$component = $parts[0];
$fields    = null;

if (array_key_exists('fields', $displayData))
{
	$fields = $displayData['fields'];
}
else
{
	$fields = $item->jcfields ?: FieldsHelper::getFields($context, $item, true);
}

if (empty($fields))
{
	return;
}

$output = array();

foreach ($fields as $field)
{
	// If the value is empty do nothing
	if (!isset($field->value) || trim($field->value) === '')
	{
		continue;
	}

	$class = $field->name . ' ' . $field->params->get('render_class');
	$layout = $field->params->get('layout', 'render');
	$content = FieldsHelper::render($context, 'field.' . $layout, array('field' => $field));

	// If the content is empty do nothing
	if (trim($content) === '')
	{
		continue;
	}

	$output[] = '<div class="field-entry ' . $class . '">' . $content . '</div>';
}

if (empty($output))
{
	return;
}
?>
<div class="fields-container">
	<?php echo implode("\n", $output); ?>
</div>

Which produces:
Screenshot 2021-12-08 at 21 50 59

Source HTML code:
Screenshot 2021-12-08 at 21 51 09

In short, the proper way already exists...

avatar ceford
ceford - comment - 9 Dec 2021

White space problem fixed.

@brianteeman the title tags were those for which I could see a use case. hx would be complicated by the need to get the hierarchy right and almost certainly extra css. Existing field groups use ul, which is why it is the default. dl would take us back to J3!

@dgrammatiko thanks for the extra explanation. In this case I do not see how using a template override can reproduce the Ingredients / Procedure lists in my testing instructions because there is nothing in the Field Group parameters to tell the layout which tag to use.

avatar dgrammatiko
dgrammatiko - comment - 9 Dec 2021

Just add in the fields group one, one field named layout where you can select one of the available layouts. That’s the solution, adding fields in the field level is not the right approach

avatar brianteeman
brianteeman - comment - 9 Dec 2021

@ceford the same argument about the title tags heirarchy could have been made about modules yet we have the option there. Trust me if you offer one then you can guarantee users will ask why not the other - especially when it is called a title and yet there are no traditional title tags in the list

avatar brianteeman
brianteeman - comment - 9 Dec 2021

@ceford You have identified a very valid issue and we do need the ability to select a layout for a field group.

image

You can then include some standard group layouts eg ul, dl as you have already created AND the site owner has the ability to create their own layouts for the group

avatar brianteeman
brianteeman - comment - 9 Dec 2021

@dgrammatiko just needs a new field - basically a clone of https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Form/Field/ComponentlayoutField.php

and then add the layouts

avatar laoneo
laoneo - comment - 9 Dec 2021

@laoneo can you have a look here. The aim is to have a layout field in the group level

On the front there is no distinction to render the fields per group yet. Groups are only used in forms for different tabs. This would be a new way to render fields per group and not just flat as it is now.

avatar dgrammatiko
dgrammatiko - comment - 9 Dec 2021

This would be a new way to render fields per group and not just flat as it is now.

Could you implement it? My objection here is that the fields try to control the container, which should be considered the wrong approach in any well-designed system. Usually, we want to follow the hierarchy, outer -> inner

Anyways there's #36275 as an alternative

avatar laoneo
laoneo - comment - 9 Dec 2021

@ceford would it be ok to switch to ##36275 which is more inline with the Joomla4 way to have as less parameters as possible and do more stuff in layouts?

avatar dgrammatiko
dgrammatiko - comment - 9 Dec 2021

@ceford I don't want to take over your PR therefore you can use the code from my PR and continue here. I just open the other one to showcase a possible solution (obviously the code needs some more refinement)

avatar ceford
ceford - comment - 9 Dec 2021

Take over / switch to #36275 - my first reaction is yes, I would be content for someone else to take this forward. On the other hand I guess you could all do without the distraction. I can see that there is a layout for each tag type so end users don't have to create overrides. I applied the patch and my fields disappear! So there is still some work to do. Give me a day to see how far I get.

avatar ceford
ceford - comment - 9 Dec 2021

@laoneo @dgrammatiko
Can I have some advice please? Look at lines 440 onwards in plugins/system/fields/fields.php - at that point there is a single list of fields and they are all rendered with the same layout as the first item in the list. So if there are two field groups involved the list needs to be split into two lists that will be rendered separately. Seems a bit clunky but I do not see where else the list might be encoded as an array. So at the moment I propose to split the list there. Good/bad proposal?

avatar joomla-cms-bot joomla-cms-bot - change - 10 Dec 2021
Category Administration com_fields Language & Strings Front End Administration com_fields Language & Strings Front End Plugins
avatar laoneo
laoneo - comment - 10 Dec 2021

@ceford would be better you leave your pr in the initial state, so people can decide which way to go. And help bringing #36275 to a stable state. So we do not have two pr's with the same code. No need to make your pr a copy of the other. So can you revert your last commit?

avatar ceford
ceford - comment - 10 Dec 2021

Revised to use code provided by @dgrammatiko - currently waiting for automated tests to complete. Example outcome:

image

In this example I have left in the label of the first item in each group, just to show items with and without labels. The group title is set as h3. The last item, the image, is a field not in a field group. It uses ul by default. If the bullet is not wanted it could be styled out. Or the image could be put in a group. The default ul appearance, which is a change since J3, is what started this PR a year ago.

avatar ceford
ceford - comment - 10 Dec 2021

@laoneo I don't know what to make of your last comment! It was my understanding that @dgrammatiko was leaving this to me with the suggestions that I use his code. That is what I have done. Are you suggesting that I revert to my monkey-patched version? For me, that was more satisfying but it would leave dgrammatiko to complete his version - it does not include group titles.

avatar AndySDH
AndySDH - comment - 17 Dec 2021

@laoneo can you have a look here. The aim is to have a layout field in the group level

On the front there is no distinction to render the fields per group yet. Groups are only used in forms for different tabs. This would be a new way to render fields per group and not just flat as it is now.

Not true, you can do {fieldgroup 5} in your editor to render fields from fieldgroup with ID 5.

avatar ceford
ceford - comment - 27 Dec 2021

I am not sure what to do about the This branch is out-of-date message. Should I be fixing that on my clone and then pushing that to my fork? I merged the latest into my clone and then switched to this pr branch. Should I have merged into my local pr branch instead?

avatar richard67
richard67 - comment - 27 Dec 2021

@ceford As long as there are no conflicts shown in addition, you can ignore that branch out-of-date message.

avatar ceford
ceford - comment - 29 Dec 2021

Are the drone errors something I can fix? Is that the result of the out-of-date message?

avatar richard67
richard67 - comment - 29 Dec 2021

Are the drone errors something I can fix? Is that the result of the out-of-date message?

@ceford The answer to both questions is: No. I restart drone now to see if it passes this time.

avatar richard67
richard67 - comment - 29 Dec 2021

@ceford Drone restart did not help .. now I have used the button to update the branch. Let's see if that helps.

Possibly you created your branch at a time (or when it was once for the 4.0-dev branch then time when it was rebased to 4.10-dev) when in the 4.1-dev branch there was an error in an SQL script for new installations? At least the output from the system tests look as if that was the case.

So or so it was not your fault or your mistake.

avatar richard67
richard67 - comment - 29 Dec 2021

@ceford After having kicked the drone a few times, it passed. Now in case if you need to make some modifications to that PR, pull the changes from remote before working in order to get the updates from the branch update.

avatar HLeithner
HLeithner - comment - 27 Jun 2022

This pull request has automatically rebased to 4.2-dev.

avatar joomla-bot
joomla-bot - comment - 27 Jun 2022

This pull requests has been automatically converted to the PSR-12 coding standard.

avatar HLeithner HLeithner - change - 27 Jun 2022
Labels Added: ?
avatar brianteeman
brianteeman - comment - 30 Sep 2022

@crystalenka something for you. We talked about this last week iirc

avatar drmenzelit
drmenzelit - comment - 22 Oct 2022

Thank you for your ideas.

We discussed it in CMS Maintenance Team and we think that the way is to use overrides / alternative layouts.

avatar drmenzelit drmenzelit - change - 22 Oct 2022
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2022-10-22 13:44:26
Closed_By drmenzelit
Labels Added: ?
Removed: ?
avatar drmenzelit drmenzelit - close - 22 Oct 2022

Add a Comment

Login with GitHub to post a comment