New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding an alternate layout parameter to custom fields #18571
Conversation
@@ -22,6 +22,8 @@ COM_FIELDS_FIELD_DISPLAY_LABEL="Automatic Display" | |||
COM_FIELDS_FIELD_DISPLAY_NO_DISPLAY="Do not automatically display" | |||
COM_FIELDS_FIELD_GROUP_DESC="The group this field belongs to." | |||
COM_FIELDS_FIELD_GROUP_LABEL="Field Group" | |||
COM_FIELDS_FIELD_LAYOUT_DESC="Choose an alternate layout to be used with automatic display" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a sentence please add a . at the end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing!
One thing I noted is that when you choose an override from a template which isn't active, the field will not show. JLayouts only work from the active template. |
@@ -1,30 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8" ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this removal made on purpose in this pr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, no. That one sneaked it.
Hey there, I'm testing it and it does work correctly :) There are a couple of issues to address though:
Also, a question, why is it that a filename cannot have an underscore? So far I've been using underscores for the filenames of my layouts manually used with the Content Plugin and they've been working normally. Not a big deal, just wondering. Great job again! |
@AndySDH please mark your Test as successfully:
|
@franz-wohlkoenig Sure, thanks for the guidelines! I'll be waiting for @Bakual about the fixes above and then will do that :) |
Ah true, didn't think of that. My though was to prevent misunderstanding when someones wants to insert a single field manually. I think then the layout doesn't apply (but haven't tested) and that could be confusing.
That is then a lookup folder from JLayouts overriding mechanism itself. Looks indeed like I have to add that one as well. The com_fields one is because that is where the default layout actually is stored.
Yes, it should not. The "Use Default" should cover that. That was my plan. Do you have an override for that in your template (I think I didn't test that case)? Or why did it show up?
Not really a technical reason. I based the formfield on the component layout one. In view layouts, we use underscore in layout files which should not appear in the select list. That allows to have "children" layouts. If you for example look at the article view, you see the |
You have a point. Yeah, the layout indeed does not apply when you insert a single field manually. Maybe for clarity we could rename the option to "Automatic Layout", and in the option description, change it to "Choose an alternate layout to be used with Automatic Display or as part of a Field Group." Unless... we want to actually make it work also for when inserting a single field manually? (if that is even possible). This way, the option could act as "Default/Base Layout", which is always used for that field unless otherwise overridden in the single field via content plugin.
Yeah, figured so... One more folder to add, damn! Haha.
Yeah, I have an override for render.php now in
Gotcha, that makes sense to me too. Good idea/decision 👍 |
I took another approach. The layout now applies also when you insert a single field 😄
Done.
Took care of them as well now. |
@Bakual Fantastic! Saw all your latest commits, perfect stuff. Everything looks thorughly taken care of. I will test this all once again with the latest changes and officially mark as successful. |
I have tested this item ✅ successfully on 2d7e71e This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18571. |
Can others test this? :) |
|
||
return implode($html); | ||
} | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the else
clause and just have return '';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I get by copy-pasting from JFormFieldComponentlayout
😄
I have tested this item ✅ successfully on ea054e2 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18571. |
@AndySDH can you please retest? |
Ready to Commit after two successful tests. |
Sorry for being late to the party, but com_contact needs to be adjusted too https://github.com/joomla/joomla-cms/blob/staging/components/com_contact/layouts/fields/render.php#L70. |
Thanks for the reminder @laoneo ! |
I have tested this item ✅ successfully on 8ba9ff9 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18571. |
1 similar comment
I have tested this item ✅ successfully on 8ba9ff9 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18571. |
8ba9ff9
to
9fa014e
Compare
f8ae563
to
00ff66a
Compare
@zero-24 Rebased and fixed the conflicts |
By the way, @laoneo, your comments from: #20243
This PR actually wasn't specifically about what you mentioned over there. This PR here added the ability to add and choose a Custom Layout at a FIELD level (so before even knowing what field type it's going to render). (override for: "components/com_fields/layouts/fields/render.php") What you were proposing is to add and choose an even deeper Custom Layout at a VALUE level for specific field types, where you would be able to specify a layout for individual values for fields that have multiple values (such as list, checkboxes, repeatable) (override for "plugins/fields/list/tmpl/list.php"). Which is not possible right now and was not included in this PR, just so you know. |
@AndySDH Please don't post on closed/merged PRs. Nobody is going to read and answer that. |
Pull Request for Issue #18162 .
Summary of Changes
Adds a new parameter "Layout" to custom fields which allows to select a different field layout for the automatic display.
Testing Instructions
components/com_fields/layout/field/render.php
, it can be overriden at component and template level, so for com_content incomponents/com_content/layout/field/
,templates/your_template/html/layouts/com_content/field
andtemplates/your_template/html/layouts/com_fields/field
. The file isn't allowed to contain an underscore.Expected result
Layout is used as specified
Actual result
Not possible to choose a different layout
Documentation Changes Required
Since it is a new feature, it has to be documented.