get custom fields in category default.php Topic is solved

For Joomla! 4.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
erick-b
Joomla! Explorer
Joomla! Explorer
Posts: 297
Joined: Tue Feb 17, 2015 10:25 am

get custom fields in category default.php

Post by erick-b » Tue May 03, 2022 8:19 am

hello

in my template com_content/category/default.php i want to get the custom fields

Code: Select all

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

$fields = FieldsHelper::getFields('com_content.category',$this->category->id, true);

var_dump($fields);
I get nothing (empty array)


is it possible that it is even worse than J3 ?

thanks for helping
Last edited by erick-b on Tue May 03, 2022 8:39 am, edited 1 time in total.

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2846
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: get custom fields in category default.php

Post by SharkyKZ » Tue May 03, 2022 8:31 am

Change context to com_content.categories and pass the category object, assuming you are talking about the category custom fields:

Code: Select all

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

$fields = FieldsHelper::getFields('com_content.categories', $this->category, true);

erick-b
Joomla! Explorer
Joomla! Explorer
Posts: 297
Joined: Tue Feb 17, 2015 10:25 am

Re: get custom fields in category default.php

Post by erick-b » Tue May 03, 2022 8:39 am

it works !!

i get it directly

Code: Select all

$fields[0]->rawvalue
thank you


Locked

Return to “Joomla! 4.x Coding”