Skip Navigation

[Gelöst] Custom Field Conditions with Elementor

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
How to conditionally display Elementor modules?

Solution:
That is not currently supported, but you can conditionally display content based upon field values using the wpv-conditional shortcode, as described in the documentation below.

The Elementor UI doesn't allow inserting such shortcodes, it will be necessary to copy and paste into the Elementor template or manually write the shortcode.

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

This support ticket is created vor 6 Jahren, 3 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Dieses Thema enthält 3 Antworten, hat 3 Stimmen.

Zuletzt aktualisiert von digiumM vor 6 Jahren, 3 Monaten.

Assistiert von: Nigel.

Author
Artikel
#1083154

Hi Toolset-Team,

My Basic Setup:
Astra Theme (Pro-Version)
Elementor (Pro-Version)
Toolset Types Plugin

i've added a custom field to posts via Toolset. In this custom field you can now upload a PDF.

In the respective elementor template for single posts, I have now created a download button and connected this via dynamic content with the custom field created in Toolset. But this download button now appears in every post - regardless of whether a PDF was selected in the backend or not.

How can I set it up that this download button is only displayed in posts when a PDF was linked in the backend?

Thank you in advance for your help!

Kind regards

Manuel

#1083600

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

Hi Manuel

I think conditional display of Elementor modules is on the roadmap but it is not currently possible.

If you are not familiar with it, you can conditionally display content based upon field values using the wpv-conditional shortcode, as described here (https://toolset.com/documentation/user-guides/conditional-html-output-in-views/) and, specifically, here (https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/).

So try creating a Views Content Template (rather than an Elementor template) to do this first.

Once you have it working, copy and paste the markup (with your types field shortcode wrapped in wpv-conditional shortcodes) into an html module in your Elementor template.

You won't be able to use the button module with dynamic content, you'll have to add the markup to display your PDF link as a button yourself.

#1091485

Hi Nigel,

thank you for your help. I will try the way which you described.

Kind regards

Manuel

#1306897

There's one way to do some conditionals in elementor, but I'm not sure if it'll work in this case.

in elementor when you set the dynamic content to a toolset item there is a fallback field for when it doesn't find data, in there you can add html, use some styling to hide the item that you don't want to show. It's not the best solution, but it works. Here's an example where i used it.

CPT that has multiple text fields. I have template that displays that CPT. Each of those text fields has a Title block in elementor preceding it. Some of the text fields don't get used, so it would show the title, with no content under it on display.

I just added .title-people in the class field on the elementor item that will need to be hidden when there is no content for the section. (make sure it's unique or you will hide all the items using that class)

Then on the elementor item that is calling the toolset items dynamically, in the fallback field I put this:

<style> .title-people{display: none;}</style>

So now the css is added conditionally