? ? ? Pending

User tests: Successful: Unsuccessful:

avatar Bakual
Bakual
31 Mar 2017

Pull Request for Issue #14753 .

Summary of Changes

This PR adds an additional, optional parameter to the field plugin tag: {field ID, LAYOUT}.
This allows to customize how a field gets rendered when included in the item body.

Testing Instructions

  • Copy and rename the file /components/com_field/layouts/field/render.php to /templates/protostar/html/layouts/com_fields/field/foo.php.
  • Adjust the layout so you can distinguish it from the original (eg remove the label or add some text to it)
  • Create a field and add some value to it.
  • Insert that field into the article body using the field button (or writing the plugin tag manually) and then add a comma after the ID and add the name of your custom layout (eg "foo"). Tag should look like {field 1, foo}
  • Check the article in frontend

Expected result

The field should be shown with your adjusted layout

Actual result

The standard layout is used always

Documentation Changes Required

Don't think there is one.
I've adjusted the plugin description text to include the possible syntaxes.

avatar Bakual Bakual - open - 31 Mar 2017
avatar Bakual Bakual - change - 31 Mar 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 31 Mar 2017
Category Administration Language & Strings Front End Plugins
avatar Bakual Bakual - change - 31 Mar 2017
Labels Added: ? ?
avatar Bakual
Bakual - comment - 31 Mar 2017

The plugin description will look like this
description

For testing, of course also try other combinations 😄

avatar laoneo
laoneo - comment - 31 Mar 2017

Just an idea, would it be hard to adapt the editor button as well to support layouts?

avatar Bakual
Bakual - comment - 31 Mar 2017

Just an idea, would it be hard to adapt the editor button as well to support layouts?

I thought about it but haven't had the time yet / wasn't bored enough 😄
The hardest thing is to fetch all possible layout for a dropdown (eg like the componentlayouts field). That dropdown could also be used in the plugin parameters to set a "default" layout.

We could also just add a text field. This would be simple, but also not very useful.

The JS part itself isn't that hard, I actually was able to do something similar in my SermonSpeaker component. Given my JS skills, that should tell you how easy it is 😆

avatar franz-wohlkoenig franz-wohlkoenig - test_item - 7 Apr 2017 - Tested unsuccessfully
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 7 Apr 2017

I have tested this item 🔴 unsuccessfully on 8ec549f

changed in foo.php

  • <span class="field-value"><?php echo $value; ?></span>
    to
  • <span class="strong"><?php echo $value; ?></span>

get in Source Code
<dd class="field-entry ">
<span class="field-label">Texttestfoo: </span>
<span class="field-value">alternate-layout</span>
</dd>

So alternate-layout isn't loaded.


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

avatar Bakual
Bakual - comment - 7 Apr 2017

In which component did you try this (com_content -> article? or something else?) and what is th path of the foo.php you adjusted?

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 7 Apr 2017

com_content, path to Template given in Instructions.

avatar Bakual
Bakual - comment - 7 Apr 2017

Strange

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 8 Apr 2017

will try again.

avatar franz-wohlkoenig franz-wohlkoenig - test_item - 8 Apr 2017 - Tested successfully
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 8 Apr 2017

I have tested this item ✅ successfully on 8ec549f


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

avatar Quy
Quy - comment - 11 Apr 2017

Will it be documented to create the alternative layout /templates/protostar/html/layouts/com_fields/field/foo.php in the Help page or in the plugin?

avatar Bakual
Bakual - comment - 11 Apr 2017

I'd expect it to be documented on docs.joomla.org if anything. Certainly not in the plugin.
The override method used here is a common Joomla feature, nothing special at all.

avatar Quy Quy - test_item - 11 Apr 2017 - Tested successfully
avatar Quy
Quy - comment - 11 Apr 2017

I have tested this item ✅ successfully on 8ec549f


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

avatar ot2sen ot2sen - test_item - 11 Apr 2017 - Tested successfully
avatar ot2sen
ot2sen - comment - 11 Apr 2017

I have tested this item ✅ successfully on 8ec549f


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

avatar franz-wohlkoenig franz-wohlkoenig - change - 12 Apr 2017
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 12 Apr 2017

RTC after 3 successful tests.

avatar rdeutz rdeutz - change - 12 Apr 2017
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-04-12 06:37:06
Closed_By rdeutz
Labels Added: ?
avatar rdeutz rdeutz - close - 12 Apr 2017
avatar rdeutz rdeutz - merge - 12 Apr 2017

Add a Comment

Login with GitHub to post a comment