Lovable Pro Key not working as expected

Hi,

we are using Wordpress in conjunction with Lovable. I have used Conditonjs to show/hide elements in the past but for some reason it is not working.

This is the key:
{{dc:post:meta key="_lovable_has_logo"}}

I have tried it the “traditonal way”
string(empty) is not {{dc:post:meta key="_lovable_has_logo"}}

lovable says to try this
{{dc:post:meta key="_lovable_has_logo"}} is 1
lovable setup a condition where 1 is the logo being present in the database

neither work to hide the surrounding div.

what am i missing?

in the screenshot the logo “is” present…so should not be hidden, but when i test on a page where no logo is present…the blank space of the div is there. There is NO min-width/height on that div

see screenshots below.

Hello @uxmediahouse,

Thanks for writing to us.

To help you with your concern, please share your details in a secure note. Please provide the following details

  • WordPress Login URL

  • Admin-level username and password

  • Exact page URL

    You can find the Secure Note button at the bottom of your posts

    Thanks

added secure note above. thanks!

Hello Riceman,

Normally, this should work:

{{dc:post:meta key="_lovable_has_logo"}} is 1

Could you tell us which vendor does not have a logo, so we can test a vendor with a logo and the one that does not have a logo?

Alternatively, you can use:

{{dc:post:meta key="_lovable_image_url"}} is not {leave this empty}

Best Regards.

Right! not sure why it isnt… here are the two pages:

No Logo:

Logo:

Hello Riceman,

The vendor, J E Redington Plumbing Co, has a logo. You can check it below:

The problem is that the logo image is not loading or just a dot.

  • See the secure note below.

Thanks.

ah, thanks! sorry… the team is updating assets on the backend. here is one without a logo:
https://theproguide.com/vendor/anchor-plumbing-inc/

Hey @uxmediahouse,

Your condition is the reverse of what it needs to be. Try moving the Dynamic Content to the left.

image

Thanks! yes, i originally did that, as this is how I have been doing it for years. but it didnt work. Lovable, for whatever reason, says to try it this way. So i did…and left it. did you try it reversed? did that work for you???

Thanks!

Thanks for testing. After further investigation, I’ve found that the reason the condition is not working is due to how WordPress handles serialized data and how PHP / Cornerstone converts arrays to strings:

  1. WordPress Unserialization: Because the meta key value is stored in the database as a serialized array array( 0 => '0' ), when Cornerstone retrieves it via get_post_meta( $post_id, '_lovable_has_logo', true ), WordPress automatically unserializes it and returns a PHP array instead of a single string.
  2. Array to String Conversion: Cornerstone’s String Condition requires a string for comparison. When PHP attempts to cast a PHP array to a string, it converts it to the literal string "Array" (and may trigger an “Array to string conversion” PHP notice).
  3. Comparison Failure: Since the parsed dynamic content evaluates to the string "Array", any comparison you set up in your String Condition (such as comparing against "0") will fail because "Array" does not equal "0".

You can tell Cornerstone to treat the returned array as an object and extract index 0 directly within the Dynamic Content tag.

The Dynamic Content should be updated to {{dc:post:meta key="_lovable_has_logo" type="object" _key="0"}}

The correct Condition to use is then is the Number. You need to check if {{dc:post:meta key="_lovable_has_logo" type="object" _key="0"}} == to 1.

image

The Div is now hidden as you can see the headline is completely flush within the container while you maintain the logo showing up if it’s available.

image

image

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.