Warning : Undefine array key "type" on line 82

Hello,

I use this L&L template card to display WordPress card:

<ul class="db_cards">
  <Loop type=portfolio>
    <li class="db_cards_item">
      <div class="db_card">
       <a href="{Field url}">
        <div class="db_card_image">
          <If field="image" exists>
            <img src="{Field image_url size=medium}" alt="{Field image_alt}" >
          <Else>
           <img src="https://mysite.com/wp-content/uploads/2023/05/placeholder.jpg" alt="placeholder" >
          </Else>
          </If>
        </div>
            
        <div calss="db_card_content">
            <h3 class="db_card_title"><Field title /></h3>
            <p class="db_card_client">Client: <Field client /></p>
            <p class="db-card_description"><Field excerpt auto=true /></p>
             <button class="btn db_card_btn"><a href="{Field url}"></a>En savoir plus</button>
         </div>
        </a>
      </div>
    </li>
  </Loop>
</ul>

It works very well, but I have encountered 6 warnings on the frontend:

ā€œWarning: Undefined array key ā€˜typeā€™ in /home/clients/xco3x859x36816o68xax318011oxxx8d4/web/wp-content/plugins/tangible-loops-and-logic/vendor/tangible/template-system/loop/types/attachment/index.php on line 82.ā€

I have been troubleshooting this issue for three days, but I still havenā€™t been able to identify the error. Can anyone help me, please?

I use the twenty twenty-three wordpress child themeā€¦

Hi Delphine, welcome to the forum! Skimming through your template, Iā€™m noticing that you donā€™t seem to be using the right syntax for the Else tag. Could that be your issue?

Hello, thanks for your message Benjamin.

I removed the closing tag and followed the documentation as instructed. Unfortunately, I still have 6 warnings on the front end!

Hereā€™s the updated code:

 <If field="image" exists>
        <img src="{Field image_url size=medium}" alt="{Field image_alt}" >
    <Else />
        <img src="https://mysite.com/wp-content/uploads/2023/05/placeholder.jpg" alt="placeholder" >
 </If>

Interestingly, when I remove the condition entirely, I no longer receive any warnings. This indicates that the problem lies within the condition itself.

Furthermore, when I replace ā€œimage_urlā€ with ā€œacf_image_url,ā€ I only receive 2 warnings. However, the thumbnail image is not displayed. This is expected because the thumbnail image is sourced from WordPress and not from ACF.

Do you see another mistake in my code please ?

I think the problem come from my condition but I canā€™t find the good one !!!

I know in theory

<If subject comparison value>
  The condition is true.
<Else />
  The condition is false.
</If>

I try all those one, but nothing work !

<If field="acf_image" is value="db_image_mise_en_avant" >
   <img src="{Field acf_image=db_image_mise_en_avant field=url}">
 <Else />
   <img src="https://mysite.com/wp-content/uploads/2023/05/placeholder.jpg">
</If>
<If field=image is value="{Field acf_image=db_image_mise_en_avant}" >
<If custom_field="{Field acf_image=db_image_mise_en_avant}" exists >
 <If field=image is value="{Field acf_image=db_image_mise_en_avant}" >
<If field=image is="db_image_mise_en_avant" >
<If custom_field="{Field acf_image=db_image_mise_en_avant field=url}" exists >

How can I console.log or echo the value i received, please ?

So, I think this If condition is the good one :

<If field="db_image_mise_en_avant" exists >
       <Loop acf_image=db_image_mise_en_avant>
           <img src="{Field url}" srcset="{Field srcset}" alt="{Field alt}">
       </Loop>
 <Else />
   <img src="https://mysite.com/wp-content/uploads/2023/05/placeholder.jpg" alt="placeholder">
</If>

But i have steel one warning ! I guess is about the loop type attachement ! But I donā€™t understand wery well ! Do you have exemple to help me please ?

Hey there,

This seems like an odd issue. I will let the devs work on this bug, then I will come back to you when the issue is fixed!

Meanwhile, if you donā€™t want to see the warning, you can turn off WP Debug (which should be off on a production environment in most cases).

1 Like

Iā€™m experiencing the same error too.
I only found out this error when messing around with my production clone at localhost, coincidentally it was just a few hours after I updated to the latest 3.2.4 version.
After a brief inspection, Iā€™m pretty sure thereā€™s some bug in the <If> , the error only appears in those pages I use L&L, and with template that has <If>

Error displayed:

**Warning** : Undefined array key "type" in **XXX\wp-content\plugins\tangible-loops-and-logic\vendor\tangible\template-system\loop\types\attachment\index.php** on line **82**
1 Like

Thanks for letting the devs working on this because, when I turn WP Debug to true, Iā€™m experiencing the same error on, for example: Contact en locaties - Voetencentrum Flipse

Thanks to @emmaā€™s testing and @eliotā€™s quick work, it looks like a fix was released to this a few minutes ago in version 3.2.5

2 Likes

the 3.2.5 update has resolved this issue in my case.

2 Likes

Hello, me too, this 3.2.5 version has resolved this issue too. Many thanks !

But now I have a deprecated message for information.

Deprecated : str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in */wp-content/plugins/tangible-loops-and-logic/vendor/tangible/template-system/template/tags/link.php on line 118

Deprecated : str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in */wp-content/plugins/tangible-loops-and-logic/vendor/tangible/template-system/template/tags/link.php on line 119

Hey there,

Can you give me some more information about this? What does your code look like?

Hi @af1ne, thanks for posting the deprecation messages. It was about compatibility with PHP 8.1 and above - should be solved in L&L version 3.2.7.

1 Like