Create new article, withe some text:
In the Content Tab, press de Button "Fields".
Select a custom field and insert it
Yo see this html code:
<p>This is an article text with the {field 1} inserted within this paragraph.</p>
You expect to see this html code in the frontend:
<p>This is an article text with the <span class="field-value">field 1 value</span> inserted within this sentence.</p>
The actual result is a the inclusion of the description list tag
<p>This is an article text with the
<dd class="field-entry " id="field-entry-1">
<span class="field-value">field 1 value</span>
</dd>
inserted in an article.</p> </div>
joomla 3.7
Labels |
Added:
?
|
Maybe better alow to insert the "field title" and "field value" separated.
And insert them inside the article just the field value without tags, because the users know how we wants to implement it, so we will insert them inside a parragraf or a div o watever we need.
The plugin uses the JLayout that is used always when a field is rendered. Just override that one and you can adjust it to your needs.
For a single field, it's this layout: https://github.com/joomla/joomla-cms/blob/staging/components/com_fields/layouts/field/render.php
It can be overriden also on component level, eg if you want the fields to render differently in an article, you can do that.
Thanks for replaying
But seems that this layout renders the inclusion Inside de Article (great: you can remove tags from the render.php, and after insert them manualy inside the article text editor if you want), buuuut seems that also this layout renders the "Automatic Display" option (ups, here you need the predefined tags!).
Yep as said, it always uses the same layout, doesn't matter where it is rendered. From a code view there is no difference if it's in the "automatic display" or within an article.
Maybe we need to remove the
Edited my comment above so the tag shows
A solution can be to use a second layout for the inline fields or to switch to a template engine (eg. Mustache) like DPFields has and was included in the early stages of com_fields, more information why and why not can be found here joomla-projects/custom-fields#135.
I don't think it needs a second layout. The current one just has to much in it and that <dd>
tag should go to the calling layout instead.
Thanks @laoneo and @Bakual for replaying,
From my point of view, the objective of including selected fields inside the article content should be different from the "automatic display", so we need a different way to do it.
Case 1: "AUTOMATIC Display":
<dd>
or <div>
it is ok)....this is how joomla 3.7 is working now. Great. everything automatic, as expected!
Case 2: "MANUALLY display":
this is the {field x} way, but now J3.7 it is not working as expected (of course, from my point of view)
<b>
{field X}</b>
)For example:
Field 1 label: Year In
Field 1 data: 2013
Field 2 label: Year Out
Field 2 data: 2015
Automatic display:
I expect every fields automatic rendered like this:
<dd class="" id="field-entry-2">
<span class="field-label">year in: </span>
<span class="field-value">2013</span>
</dd>
<dd class="" id="field-entry-2">
<span class="field-label">year out: </span>
<span class="field-value">2013</span>
</dd>
Manual Display:
I expect i can do something like this:
<p>This article content is about something which
<b>{field 1:label}</b> was on the <i>{field 1:value}</i>,
and its <b>{field 2:label}</b> was on the <i>{field 2:value}</i>.</p>
<p>Remember: <span style="font-size: 14pt;">{field 2:value}</span>
and <span style="font-size: 14pt;">{field 2:value}</span></p>
Of course, it is just my point of view. Thanks for reading.
Category | ⇒ | com_fields |
See #15013 for fixing the <dd>
in the article body.
To select manually if we want to insert the field label or the field value. ({field 1:label} and {field 1:value})
We can improve on that later if someone wants to write the code for it. This should be possible in a B/C manner.
On the other hand you can already set the field label to hide and it will also not show in the article body (so it is possibly to only show the value). If you only want to show the label, you could as well just write it manually.
@bakual thank for replaying,
But reading what you said:
See #15013 for fixing the
<dd>
in the article body.
And
On the other hand you can already set the field label to hide and it will also not show in the article body (so it is possibly to only show the value)
I see i didnt explain well, because this is not the problen and either the solution.
Maybe my English is not good enough. I am trying to explain again:
Yes i know you can set the field label to hide . I have wrote about it in "Case 1: Automatic Display".
It is great to show a "<dd>field label: field value</dd>
" list of fields automatically.
<dd>
or whatever else (div, table, li...).
This part is working great.
But the problem i am trying to explain here is another:
If after that "automatic display", you want to also insert some fields manually inside the article content (Case 2 Insert manually):
<p>This is an article with this <b> {field 1 value} </b> inside the content.<p>
Hope i have explained better now.
Yep, that is true. If you want to have the field both in automatic display shown with the label and in the article without, that is not possible today.
But as said, this should be possible to do later as it has no B/C implications. I will likely not have the time to do it but if anyone else wants to do it should be possible.
I understand.
You dont have time and i dont have enough knowledge to do it. Hope someone have both...
Thanks for your time!
@Sukinoz @laoneo I was a bit bored today at work and got an idea: #15027
This will allow for alternative layouts to be used by the plugin tag. That would allow to customise the appearance of the field within an article body. So you could create a layout which only shows the label or only the value or whatever.
Can we close this issue as we have a pr?
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-04-01 12:53:03 |
Closed_By | ⇒ | brianteeman |
From my view it´s actually not really a bug but something that needs indeed huge improvement. The problem is, that you can´t know how the User wants to implement the specific fields so you can´t define a specific rendering. What if it´s not a paragraph but a container? What if the Field is not a value but a slideshow or something?
Maybe it´s a solution to offer a raw output of the field Value or text without any Label or Markup.
I see that your test, which was very important, shows that this needs some more thoughts.
It needs to be defined how all of the Joomla! Core custom fields would be rendered in Article, Category, Contactinformation and Contactcategory view when automatic display is off.