Skip Navigation

[Resolved] place value in inline style, by condition “has parent or hasn’t parent”

This thread is resolved. Here is a description of the problem and solution.

Problem:

Use [wpv-conditional] shortcodes as HTML tag attributes within Fields-and-Text block, it does not work.

Solution:

According to our developers feedback, it seems to be an issue of WordPress core:

This is probably due to some sanitization done by WP over its content on post save.

So in your case, please try to use shortcode block.

Relevant Documentation:

This support ticket is created 3 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 9 replies, has 2 voices.

Last updated by TorstenR3514 3 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#1904563

toolset:test2021 <--please mark this as privat

I am trying to place a min-height inline style by condition to rd-header-row-layout

It works in the body:
[wpv-conditional if="( '[wpv-post-id item="$parent"]' ne '' )"]has parent[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-id item="$parent"]' eq '' )"]has no parent[/wpv-conditional]

But it doesn't work in the inline style (actually not placed in the website)
<div ... style="max-width: 1290px; min-height: [wpv-conditional if='( "[wpv-post-id item='$parent']" ne "" )']30vh[/wpv-conditional][wpv-conditional if='( "[wpv-post-id item='$parent']" eq "" )']50vh[/wpv-conditional]; >

#1904765
sub-page.JPG

Hello,

Where did you put those codes?
I have tried the same codes in my localhost with a fresh WP installation + the latest version of Toolset plugins, it works fine.

for example, add a shortcode block, using below codes:

<div style="max-width: 1290px; min-height: [wpv-conditional if='( "[wpv-post-id item='$parent']" ne "" )']30vh[/wpv-conditional][wpv-conditional if='( "[wpv-post-id item='$parent']" eq "" )']50vh[/wpv-conditional]; ">12345</div>

It outputs different min-height value in different pages, see my screenshot: sub-page.JPG

#1904943

I put it in a Fields-and-Text block on a single page template.

Tried it on my toolset test server, got the same problem with your code?
Tried adding it in an HTML block and it worked!?

I inserted the conditional for the rd-header-row-layout into the Fields-and-Text block and did a copy into an HTML block below.
hidden link

Also see my toolset testserver:
hidden link

Is the Fields-and-text block the problem?

#1905005

Thanks for the details, I can duplicate the same problem, and have escalated this issue, will update here if there is any news.

#1905041

yes please. Having lot's of issues I can't explain, always thinking that I am doing the probs, like pages that I can't update after changes, or the disappearing css bug at the buttons https://toolset.com/forums/topic/custom-toolset-styles-for-buttons-disapear-at-first-reload/page/2/. Would be great if it's not allways my issue 😛

#1905147
Revisions.png

Just realised that he also "crashes" the html-block if I reedit the template. If I reopen it twice (without saving the first time) he shows me that there is a backup with changes at the second time, without having changed anything myself. There you can see that he edits the html block in the backedup version (red outline) like he probably did with the Fields-and-Text block by saving at the first time.

Maybe that helps

#1905967

Your screenshot isn't in English, it does not help.

Please provide detail steps to reproduce the same problem in a fresh WP installation.

#1906489

Hi Luo Yang,

please see Video for detail steps to reproduce the same problem in a (quite) fresh WP installation.
hidden link

Hope this helps and that it is ok by video because that's much, much faster for me than explaining it by words...

Greetings Torsten

#1908645

Since you are using shortcodes + HTML codes, please try as my first answer: use shortcode block:
https://toolset.com/forums/topic/place-value-in-inline-style-by-condition-has-parent-or-hasnt-parent/#post-1904765

It works fine in my localhost.

And for the HTML block and Fields-and-Text block issue, I have checked it in our to-do list, according to our developers feedback, it seems to be an issue of WordPress core:

This is probably due to some sanitization done by WP over its content on post save.

So in your case, please try to use shortcode block.

#1909005

Well that was clear that it's because of sanitization of WP.
Hoped that there was some work-around for that.

As there isn't iI will keep rewriting the code into a HTML block every time I save the template.
Not the best solution but at least a solution.

Thx for your support!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.