On a site for certain articles (and not others!!)
I have the following error message *
This worked in j3/php7.4. Perhaps a problem comes from switching to j5 / php8.1
What's strange is that it works on some items but not others (I'm looking for differences but I don't see any!)
What is possible is that my test at the top is not good because if the fields are filled, I never have this problem.
I am told to take the array but how to define it?
I don't understand that it worked under Joomla 3 and that it works half-way on certain Joomla!5 articles.
Here is the code to ~221:
<?php
// Si les champs "champ(pro) ET champ(type pro)" ne sont pas vides
if ( ($this->item->jcfields[110]->value !== '') AND ($this->item->jcfields[111]->value !== '') AND ($this->item->jcfields[112]->value !== '') ): ;
//if (!empty($this->item->jcfields[110]->value)): ;
// initialise la table avant la boucle
$app = Factory::getApplication();
$factory = $app->bootComponent("com_content")->getMVCFactory();
$table = $factory->createTable("Article", "Table");
foreach ($this->item->jcfields as $field) {
if ("films-pros" === $field->name && "subform" === $field->type) {
echo "<br /><b><span><i class='fa fa-link fa-1x' aria-hidden='true'></i></span> Pro(s) en lien : </b>";
$field_value = json_decode($this->item->jcfields[111]->rawvalue, true);
foreach ($field->subform_rows as $subform_row) {
foreach ($subform_row as $subField) {
if ("film-pro-lie" === $subField->fieldname) {
$titre_art = $subField->value;
$article_id = $field_value["row0"]["field110"];
$table->load($article_id);
$item_catid = $table->catid;
$film_types_pro = implode(", ", $field_value["row0"]["field112"]);
echo HTMLHelper::link(
Route::_("index.php?option=com_content&view=article&id={$article_id}&catid={$item_catid}"),
$titre_art . " ( " . $film_types_pro . " )"
);
}
}
}
}
}
endif;
?>
Stack trace:
0 implode(): Argument #1 ($array) must be of type array, string given
Call Stack
# Function Location
1 () JROOT/templates/cassiopeia_alterweb/html/com_content/article/alterweb.info-ressources.php:221
2 implode() JROOT/templates/cassiopeia_alterweb/html/com_content/article/alterweb.info-ressources.php:221
3 include() JROOT/libraries/src/MVC/View/HtmlView.php:416
4 Joomla\CMS\MVC\View\HtmlView->loadTemplate() JROOT/libraries/src/MVC/View/HtmlView.php:204
5 Joomla\CMS\MVC\View\HtmlView->display() JROOT/components/com_content/src/View/Article/HtmlView.php:258
6 Joomla\Component\Content\Site\View\Article\HtmlView->display() JROOT/libraries/src/Cache/Controller/ViewController.php:95
7 Joomla\CMS\Cache\Controller\ViewController->get() JROOT/libraries/src/MVC/Controller/BaseController.php:692
8 Joomla\CMS\MVC\Controller\BaseController->display() JROOT/components/com_content/src/Controller/DisplayController.php:122
9 Joomla\Component\Content\Site\Controller\DisplayController->display() JROOT/libraries/src/MVC/Controller/BaseController.php:730
10 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/libraries/src/Dispatcher/ComponentDispatcher.php:143
11 Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() JROOT/components/com_content/src/Dispatcher/Dispatcher.php:56
12 Joomla\Component\Content\Site\Dispatcher\Dispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
13 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/SiteApplication.php:218
14 Joomla\CMS\Application\SiteApplication->dispatch() JROOT/libraries/src/Application/SiteApplication.php:261
15 Joomla\CMS\Application\SiteApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:306
16 Joomla\CMS\Application\CMSApplication->execute() JROOT/includes/app.php:58
17 require_once() JROOT/index.php:32
field112
value to an array?$film_types_pro = implode(", ", (array) $field_value["row0"]["field112"]);
I might rescript your nested condition block this way: 3v4l.org/aZufiAND ($this->item->jcfields[112]->value !== '') ): ;