Skip Navigation

[Resolved] Only display Toolset field as a button in Elementor if field has value

This support ticket is created 3 years, 5 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.

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

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 6 replies, has 2 voices.

Last updated by jamesG-8 3 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#2404335

Tell us what you are trying to do?

We have created a custom field to add a URL for front end users to be able to download PDFs
We would like this field to display conditionall if the field has a value as a button.
We are using Elementor.

We have used this thread https://toolset.com/forums/topic/how-to-hide-elementor-button-with-empty-toolset-file-field/ as a guide
But all of the conditional content such as [wpv-conditional if="( '[types field='my-url-field'][/types]' ne '')"] displays on the front end.
We have also tried this https://toolset.com/forums/topic/empty-custom-fields/ but again all the conditional content displays.
We have tried using text modules, shortcode modules and HTML modules.

The other issue we have is your guide here https://toolset.com/documentation/legacy-features/views-plugin/using-shortcodes-in-conditions/ refers to: "To do so, visit the Toolset -> Settings page and click the Front-end Content tab. There, simply add your shortcode to the Third-party shortcode arguments section." We cannot see this option in Toolset settings.

The third problem we have is that we are using HTML to display the button:
[wpv-conditional if="( '[types field='my-url-field'][/types]' ne '')"]download [/wpv-conditional]
but an additional closing is being added to the front end content making the button unusable.

Is there a similar example that we can see?
You can see the front end output here hidden link

What is the link to your site?
Its a local staging site

#2404355

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

Thank you for getting in touch.

It would appear that these shortcodes are rendering as you say. DO you have our Views/Blocks plugin installed and activated? As this shortcode requires that our Blocks plugin be active.

Thanks,
Shane

#2404379

Thank you for your reply.

Adding the blocks plugin has indeed resolved the issue of the conditional shortcodes rendering.

However, our HTML to render the button is now not working, it was before we added the Blocks plugin, can you advise?

The other issue we have is your guide here https://toolset.com/documentation/legacy-features/views-plugin/using-shortcodes-in-conditions/ refers to: "To do so, visit the Toolset -> Settings page and click the Front-end Content tab. There, simply add your shortcode to the Third-party shortcode arguments section." We cannot see this option in Toolset settings.

#2404423

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

However, our HTML to render the button is now not working, it was before we added the Blocks plugin, can you advise?

Is it that the html is not displaying at all? Are you testing on a page that has a value in the custom field ?

Can you try adding debug='true' as an attribute for the conditional shortcode and then send me a screenshot of the output.

[wpv-conditional if="( '[types field='my-url-field'][/types]' ne '')" debug='true']<a class="my-button" href="[types field='my-url-field'][/types]">download</a> [/wpv-conditional]

We cannot see this option in Toolset settings.

This option only appears when the Blocks/Views plugin is enabled. Can you send me a screenshot of your Toolset Settings page.

Thanks,
Shane

#2406049

Hi Shane,

You are correct, now we have the Blocks add on we can see the additional option in settings.

For the button this is the solution we've used. Not very elegant! but it works.
[wpv-conditional if="( '[types field='new-test'][/types]' ne '')"]
<div class="my-btn">Open Link</div>
[/wpv-conditional]

Your debug info

[wpv-conditional if="( '[types field='my-url-field'][/types]' ne '')" debug='true']download [/wpv-conditional]

####################
Debug information
####################
--------------------
Original expression: ( 'lta href="/wp-content/uploads/2022/06/autozip" title="/wp-content/uploads/2022/06/automatewoo-4.zip">/wp-content/uploads/2022/06/auto.ziplt/a>' ne '')
--------------------
After replacing 1 general variables and comparing strings: ( 'lta href="/wp-content/uploads/2022/06/auto.zip" title="/wp-content/uploads/2022/06/auto.zip">/wp-content/uploads/2022/06/auto.ziplt/a>' ne '')
Comparing lta href="/wp-content/uploads/2022/06/auto.zip" title="/wp-content/uploads/2022/06/auto.zip">/wp-content/uploads/2022/06/auto.ziplt/a> to

#2406187

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi James,

This is actually the correct way to do it so there shouldn't be any issues.

Let me know if everything is ok now. If so then you can go ahead and close this ticket.

Thanks,
Shane

#2406285

My issue is resolved now. Thank you!