151 Posts
jimenaes
1 year ago
8
Topic

Hi, I can´t find any guide on how to use de Upload jQuery (5 plug-ins). I made an image field to link it on the Upload Jquery field. Both fields are on my site form view but I get this error message:

0 count(): Argument #1 ($value) must be of type Countable|array, null given

Could you please help me?

Thanks

Get a VIP membership
151 Posts
jimenaes
1 year ago
3
Level 1

Hello,

I really need to use this extension. Is there someone who can help me figure out what could be the problem? I have the same problem on two different installations of Joomla4/Seblod 4.0.6 php 8.1, different servers. If my content form contains the Upload jQuery field, my site breaks and get the error:

0 count(): Argument #1 ($value) must be of type Countable|array, null given

The debug shows the error is in JROOT/plugins/cck_field/upload_jquery/upload_jquery.php:257

which correspond to this function:

// Set Order @count
$items = $value;
$value = array();

if (@count ( $items[$field->storage_field] ) ) {
foreach ( $items[$field->storage_field] as $key => $item ) {
$value[] = $item['aid'];
}
}
$value = implode( ',', $value );

1 year ago
2
Level 2

The error message you are encountering, "0 count(): Argument #1 ($value) must be of type Countable|array, null given," is related to a change in PHP 8.1's behavior regarding the `count()` function. Starting from PHP 8.0, the `count()` function expects its argument to be countable, which means it must be an array or an object implementing the `Countable` interface. In your case, it appears that `$items[$field->storage_field]` is not an array or a countable object, which is causing the error. To resolve this issue, you can modify the code in the `upload_jquery.php` file to ensure that you are passing a countable value to the `count()` function. 

Here's a revised version of the code that should work: 

$items = $value;
$value = array();
if (is_array($items) && isset($items[$field->storage_field]) && is_array($items[$field->storage_field])) {
foreach ($items[$field->storage_field] as $key => $item) {
$value[] = $item['aid'];  }
}
$value = implode(',', $value);

This code first checks if $items is an array and if $items[$field->storage_field] is also an array before attempting to loop through it. This will prevent the "0 count(): Argument #1 ($value) must be of type Countable|array, null given" error when $items[$field->storage_field] is null or not an array.

151 Posts
jimenaes
1 year ago
0
Level 3

Many thanks for answer, I will try that fix.

151 Posts
jimenaes
1 year ago
0
Level 3

Hello. I made the adjustments you mentioned on upload_jquery.php file but no, it still shows an error, now this is what appears:

0 Call to undefined method Joomla\CMS\Application\SiteApplication::isAdmin()

Thanks

151 Posts
jimenaes
1 year ago
2
Level 1

Hello Octopoos Team

It's been several months since I paid for this extension and I can't get it to work. Please, is there someone who can give me some guidance?

Thanks

248 Posts
Giuse
1 year ago
1
Level 2

Hi Jimenaes, unfortunately that's the major problem with Seblod: a very flexible product but almost no support. You can try to open an issue on GitHub, but there are issues open since a long time ago that do not have yet a solution and sometimes you need to fix the problem (or make a workaround) on your own. It's a pity since it is still technically the best CCK for Joomla in my opinion.

About the last error you encounter, it's because isAdmin() is no more a function in Joomla 4 (it was in Joomla 3), it has been replaced by

    JFactory::getApplication()->isClient( 'administrator' )

you can try to modify the code with that and see if it solves the problem

cheers

Giuse

59 Posts
kobalt
1 year ago
0
Level 3

Hej Giuse,
thumbs up!

  • isSite() replace with isClient('site'), and
  • isAdmin() replace with isClient('admin').

It was well explained at the following link: isSite() and isAdmin() fatal errors after updating to Joomla 4 or directly under: Potential backward compatibility issues in Joomla 4 () search for: CMSApplication::isAdmin

Thanks

21 Posts
Mikeherbo
11 months ago
0
Level 1

Hi everybody,

Actually with all the changes made, the field almost work...

The file is loaded but i have an error "unknow error" when it finish to be loaded and no file is uploaded.

Does someone have this field working good on joomla 4 ? 

Get a VIP membership