Skip Navigation

[Resolved] Conditionals don’t show the view

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

Problem:
The user created a conditional shortcode that was not working as expected.

Solution:
It turned out that the user was checking a custom field in a related post. This can't be done, we can only check for custom fields of the current post, or we need to use the item attribute to change the post that we are checking.
Or we can pass the custom field in a view shortcode argument then check it using the [wpv-attribute] shortcode.

Relevant Documentation:
- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-attribute

This support ticket is created 4 years, 1 month 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 – 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: Africa/Casablanca (GMT+01:00)

This topic contains 20 replies, has 2 voices.

Last updated by miquelF-2 4 years ago.

Assisted by: Jamal.

Author
Posts
#1887305

I am trying to:
Show diferent view based on a conditional value
Link to a page where the issue can be seen:
hidden link
I expected to see:
The related artworks defined in this view hidden link
The results of the condition works fine and show a debug value "in stock" or "out of stock" but dont show the embeded vie. The embededs views are showing correctly if no condition is applied.

#1887515

Hello and thank you for contacting the Toolset support.

Can you try something simple and short to put inside the conditional inside of the view and check? This will let us know if you are not encountering this known issue https://toolset.com/errata/shortcodes-in-conditionally-displayed-content-may-not-be-executed-on-the-front-end/

If the condition does not work, I'll need to take a closer look at your admin area. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1887869

Unfortunately, some firewall is blocking me, check this screenshot hidden link

Can you deactivate this for a while until I login and check?

#1887933

Hi Jamal,

It's my hosting provider that blocks foreigns IPs. Please, can you provide your IP in oder to allow access it.

Thanks,

Miquel

#1887993

I am afraid, my IP address will change in time. Let me check with our system team about a fixed IP using the company's VPN.
I'll get back to you as soon as I get it set up.

#1888545

Hello,

I just have talked with my hosting provider and he's said that you have to install Spanish language in your browser in order to access the web. Is not necessary that the Spanish language be the main language, it's just enough that the language exists in your browser

#1889357

Something new about my issue?

#1889663

I added Spanish to the languages of my browser and I was no longer blocked. I could go through the basic http authentication. Then I was able to login to the website. But, unfortunately, I faced two more blocking situations:
- I am unable to visit the page in Frontend, it asks for more http authentication, and it seems related to a different domain. Check this screenshot hidden link
- I am unable to access the WordPress admin. I get redirected to /my-account/ page. If I try to go the view in the backend, I get a restriction error hidden link

So, I thought about creating a new administrator user, programmatically. But the provided FTP access is not working for me too hidden link

#1891285

Hello, can you take a look to my issue?

Have a nice New Year!

#1892697

Thank you, I am now able to access the backend as an administrator. I did not test the FTP access though.

So, products are displayed using an Elementor single page template hidden link
This template uses the view "Other Artworks in Artwork PageEnter title hereSave the View
" hidden link
And inside of this view's loop, it uses the view "Other Available Artworks in Artwork Page 2". That does not display anything on the frontend hidden link

From what I gathered so far, it is expected that nothing appears. Because the view's Output Editor Section is wrapped inside a condition on the results count.

[wpv-conditional if="( '[wpv-items-count]' ne '0' )"]
    <div class="elementor-element" id="available"><h3 class="H3FullTitle">More Available Works</h3></div>
	[wpv-filter-meta-html]
    [wpv-layout-meta-html]
[/wpv-conditional]

The results count is always 0 because of how the query filters are built. Check this hidden link
Also this hidden link

Both views are configured to query Products, so, I am a bit confused. Can you explain what would you like these views to display?

#1892943

Hi Jamal.

There are two types of artworks. One of them are the artworks in sale and the other ones are the sold artworks. When you are visiting a artwork page in sale you can see the other artworks in sale, by the other side, if you are visiting a page from an sold artwork you can see the other sold artworks. This is the main purpose of the conditionals and the two embeded views.

If you don'u use the conditional this embeded view ([wpv-view name="available-artworks-in-artwork-page-2" cached="off"]) returns some values, but when you use the embeded view in a conditional there is no result

#1893933

Sorry but I still do not see what should be displayed.

Let's take this product/artwork hidden link
If we edit it hidden link
I can only see one relationship to the Artist "Andrew McIntosh", but the view is configured to query posts from a relationship which is confusing hidden link
It also confuses me that the view is querying both products and artists hidden link
Should this view queries artists that are related to the current product?

Then the nested view is querying products that are related to any relationship. hidden link
What relationship should it query from?

#1893951
Captura de pantalla 2021-01-04 a las 15.22.22.png

I want to do this:
In an artwork page, the view should show all the artworks for sale related to the Artist of the Artwork in the page (in this case Andrew McIntosh) in case that the artwork are in sale, OR show the sold artworks in case that the artwork in the page is sold.

If there is no conditional, the related artworks appear correctly. The problem when I use the conditional. See the attached image.

#1894217

The conditions in the content template of the view "Other Artworks in Artwork Page" won't work, because the content template is meant to display the parent Artist. Artist posts do not have the fields "wpcf-enquire" or "_stock_status".

The conditions should go in the content template of the view "Other Available Artworks in Artwork Page 2" as it is the one that will display products from the same parent Artist. It is this content template that should include the conditions to display "FOR SALE" and "OUT OF STOCK". Does it make sense?

#1894219

Yes, I think it's a good solution. Do you know if it works?