Page 1 of 1

Custom Fields Improvement

Posted: Fri Mar 01, 2019 7:18 pm
by ies
Hi,

I just wanted to say that custom fields in Joomla is currently the biggest and most important feature.
I believe that custom fields with CSS grid will expand Joomla to a new level.

Actually custom fields have to be treated as equally important as the main text of the article and displayed in the same tab in the administration. This will lead to a multi type and multi structured content that is the main need for the modern websites. We can't just have only title, image (full and intro) and main text.

But custom fields need some improvements. For example:
  • Custom fields have to go out from the container 'fields-container'. At least an option should exist.
  • Custom fields have to be placed in div and not dl/dd. Possibly the option above to put them outside 'fields-container' would place automatically inside divs.
  • Custom fields should be placed in the same level in DOM as the title, image and main text. This is usefull for the CSS grid. At the moment I have to use Javascript in order to put them below the "item-page" element.
  • The main text should have a distinct class and not only itemprop="articleBody".
  • The checkboxes type of custom fields should place each value in a span in order to be able to add more design.
  • Maybe a field for custom html/php code could be added.
Actually Joomla is already some levels higher than other CMSs. :)
Lets increase the difference with one more level.
Maybe the above ideas could be applied in Joomla 4.

Re: Custom Fields Improvement

Posted: Sat Mar 02, 2019 9:22 pm
by annahersh
In agreement with checkboxes output.

The method used for article element styling has long been via the pseudo selector method, which no doubt you know of:
div[itemprop="articleBody"] {}
but I guess it wouldn't hurt to include a distinct class.

Adding custom html/php field to custom fields could be quite chaotic but certainly useful for a skilled user.

Re: Custom Fields Improvement

Posted: Mon Mar 25, 2019 4:13 pm
by stutteringp0et
You can create alternate output templates for almost everything in Joomla, in which you can place the field values anywhere you like, formatting them any way you like. Search "overrides" and that'll put you on the right track.

I do this in my site to better utilize custom fields for my extensions. I'd link it, but people in the forums are weird about that. I use the custom field values wherever I want. Joomla doesn't limit you to above or below the article content.

In your custom article override (name it something other than 'default.php'), you have access to the custom fields with just a little setup:

Code: Select all

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
JLoader::register('FieldsHelpler',JPATH_ADMINISTRATOR.'/components/com_fields/helpers/fields.php');
foreach($this->item->jcfields as $jcfield) { $this->item->jcFields[$jcfield->name] = $jcfield->rawvalue; }
Then you have access to their values at $this->item->jcFields['fieldname'];

At that point, you can do anything with the values that you like.

The person who led me to this information uses a half dozen custom fields to define colors for the product articles his customer creates. They have an area for writeup, then several dozen custom fields to select images and choose colors. The result is a series of product pages which are unique, but share a common layout.

Anyway, custom fields are way more powerful than most people realize

Re: Custom Fields Improvement

Posted: Tue Mar 26, 2019 9:38 am
by ies
This is a good idea stutteringp0et. I will have it in mind next time.
I think that the disadvantages of what you describe are:
- Your idea needs PHP and then CSS but what I describe needs only CSS.
- I (at least) usually have a fear about overrides. I fear that some important features will appear in the future that will be not included in the override.

Re: Custom Fields Improvement

Posted: Sat Apr 27, 2019 4:16 pm
by paulala
I agree with the sentiment expressed here. Custom fields have enormous potential and are probably not being talked about more because as you say not everybody is properly aware of them yet. I recently read this article which looks at them in some detail. Quite interesting....

https://magazine.joomla.org/issues/issu ... tom-fields

Re: Custom Fields Improvement

Posted: Sun Apr 28, 2019 9:04 am
by ies
I have seen the page you mentioned in the past and I was impressed.
Recently, I created a website that presented an article (with custom fields of course) like an eshop product page. Everything in the article page was looking like an eshop, except the add to cart button that was missing. This is the moment I realized, in action, the importance of custom fields. And the whole job was easier than I expected and I still don't know what I would have done if I couldn't use the custom fields.

Except of cases like mine or the cases described in the page you mentioned and many cases of special content representation, custom fields are very good just for giving more design to the simple article text.

Imagine the single article text to be broken to the custom fields (along with the main text) and each one of these parts to have a different design (like different font size, font color, background color or image, position etc.). The possibilities for the template makers are becoming enormous and easier and we don't need to break the content in modules in order to separate its design from the main content.

But the changes described in the first post have to be done in order to avoid using Javascript for the 'fields-container' group and additional CSS for handling the dl/dd tags.

Re: Custom Fields Improvement

Posted: Sun Apr 28, 2019 9:07 am
by paulala
stutteringp0et wrote:
Mon Mar 25, 2019 4:13 pm
You can create alternate output templates for almost everything in Joomla, in which you can place the field values anywhere you like, formatting them any way you like. Search "overrides" and that'll put you on the right track.

I do this in my site to better utilize custom fields for my extensions. I'd link it, but people in the forums are weird about that. I use the custom field values wherever I want. Joomla doesn't limit you to above or below the article content.

In your custom article override (name it something other than 'default.php'), you have access to the custom fields with just a little setup:

Code: Select all

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
JLoader::register('FieldsHelpler',JPATH_ADMINISTRATOR.'/components/com_fields/helpers/fields.php');
foreach($this->item->jcfields as $jcfield) { $this->item->jcFields[$jcfield->name] = $jcfield->rawvalue; }
Then you have access to their values at $this->item->jcFields['fieldname'];

At that point, you can do anything with the values that you like.

The person who led me to this information uses a half dozen custom fields to define colors for the product articles his customer creates. They have an area for writeup, then several dozen custom fields to select images and choose colors. The result is a series of product pages which are unique, but share a common layout.

Anyway, custom fields are way more powerful than most people realize
Just read this properly, great tip

Re: Custom Fields Improvement

Posted: Sun Apr 28, 2019 9:49 am
by ies
I always felt, all these years using Joomla, that overrides are the last (but good) solution to a problem.

But what I am talking about is not only a solution. It is about making it better.
After all, why to improve a CMS if we can always override it?

Re: Custom Fields Improvement

Posted: Fri Jul 12, 2019 8:57 am
by romaan
I use custom fields in content overrides very successfully. It opens tons of possibilities for me.
But I cannot make them working in search result override (defult_result.php).
Is there any way?

$this->item->jcfields NOT WORKING
$this->result->jcfields NOT WORKING
$result->jcfields NOT WORKING

Please help!