Skip Navigation

[Resolved] Conditional on in View Output Section Not Working

This support ticket is created 3 years, 11 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 17 replies, has 2 voices.

Last updated by Steve Williams 3 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#1941729

Post type "Events" has a one-to-many relationship with Post type "Presentations." I want to build Conditional blocks to control the heading that appears at the top of the Content Template for Events:

- If the Event has 1 Presentations, display the post title from the Presentations. ( ( '[wpv-found-count ]' eq '1' ) )

- If the Event has != 1 Presentations, display the post title from the Event. ( ( '[wpv-found-count ]' ne '1' ) )

So in the Content Template, I inserted a view of the Event's related Presentations. I put the first Conditional block in the View Loop. I put the second Conditional block below the View Loop, in the View Output.

The first Conditional works as expected. The second never shows the Event's post title.

Example Event pages:

hidden link
hidden link

I would like to give you admin access to the site, so you can look at my content template.

Other questions about this site:

- How can I suppress the appearance of the Event's post title that appears above the rendering of the content template?

- "Events" isn't available as a menu item in Appearance/Menus. How can I fix that?

#1942325

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

- How can I suppress the appearance of the Event's post title that appears above the rendering of the content template?
==>
That title must be displayed from your theme.

If you can share admin access details I will look into it further.

Your aim is to display the Event title on the following post - correct?
- hidden link

#1942445

"Your aim is to display the Event title on the following post - correct? .../twopresentations/"

Yes, that's right.

#1942453

Thanks for explaining that the post title above the content template is displayed by the theme. I assumed the content template replaces all of the theme's content, but it makes sense that the content template only changes what the theme sees as the post body. Is that right?

Our site uses the Astra theme, since it is modeled after Toolset's "Events & Speakers" showcase. I was able to suppress the post title through Appearance/Customize/Blog/Single Post/Structure. I clicked on the little eye icon in "Title & Blog Meta" to disable it. The spurious post title is suppressed. That part of my question is resolved.

#1942457

Regarding my other question: "Events" isn't available as a menu item in Appearance/Menus. How can I fix that?

Still curious about that. I should mention that I created this site, in part, using Toolset Export/Import, Types Export and Types Import to bring over the custom post types and fields from our development site to reproduce the principal issue. I also used WordPress Tools/Export and Import to bring over the custom posts.

Maybe Toolset adds the custom post types to Appearance/Menus when it is created, but not when it's imported?

#1943345

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thanks for explaining that the post title above the content template is displayed by the theme. I assumed the content template replaces all of the theme's content, but it makes sense that the content template only changes what the theme sees as the post body. Is that right?
==>
Yes, thats correct, Toolset will have effect only on the_content() area. Toolset does not control headers/footers/side bars.

However, I see you are using the Astra theme and Astra is the integrated theme with Toolset so you will have few theme options that you should control. You can find that theme options with your content template's right side bar. Please check the following screenshot: hidden link

Regarding the title not get displays, please check how I arrange the conditionals and how I adjust the display of conditionals.
=> hidden link

I can see now it displays the correct title with both posts.

#1944273
Screenshot 2021-02-12 105506.png

Regarding the conditional title: I need some clarification.

I see you moved the conditional block from below the View Loop to above the View Loop. Is that necessary? Is the context above the View Loop different from below?

What else did you change? The block inside that conditional just looks broken now. (See screenshot.) The Block controls were missing, just a box that says "Fields and Text." They came back when I clicked in the broken block again. Something weird going on there.

The broken block is in HTML mode. Is that part of the solution? Why? When I switch back to Visual mode, it displays the post title of one of the Presentations, not the Event's post title.

The broken block contains <h2>[wpv-post-title]</h2>. If I understand, that refers to the post title of the Event (even though that's not what is displayed in Visual mode). Why is that necessary? I can't use the Parent: Event/Post Title in a Toolset Heading block?

Is this just buggy? I appreciate the workaround, but one reason we're using Toolset is so our less-technical volunteers can do more in the Block Editor. I fear the workaround will be just too confusing for them. Can you do any better?

#1944283

"Events" isn't available as a menu item in Appearance/Menus. How can I fix that?

#1948667

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I see you moved the conditional block from below the View Loop to above the View Loop. Is that necessary? Is the context above the View Loop different from below?
==>
Yes. The thing is that, you can access the currently displayed post's parent without view but if you want to query the child, you will require a view.

What else did you change? The block inside that conditional just looks broken now. (See screenshot.) The Block controls were missing, just a box that says "Fields and Text." They came back when I clicked in the broken block again. Something weird going on there.
==>
It's not broken but maybe due to your screen and as we added the conditional block within the View's output section.

The broken block is in HTML mode. Is that part of the solution? Why? When I switch back to Visual mode, it displays the post title of one of the Presentations, not the Event's post title.
==>
I can see when I change the "Fields and Text" block mode to visual, it displays the event Title. Please check the following screenshot: hidden link

The broken block contains <h2>[wpv-post-title]</h2>. If I understand, that refers to the post title of the Event (even though that's not what is displayed in Visual mode). Why is that necessary? I can't use the Parent: Event/Post Title in a Toolset Heading block?
==>
Yes - you can use the Toolset Heading block, I just added "Fields and Text" block so that if you want to add any customized HTML you can add it, if you do not want to go with "Fields and Text" block, you can obviously replace that with Toolset Heading block.

Is this just buggy? I appreciate the workaround, but one reason we're using Toolset is so our less-technical volunteers can do more in the Block Editor. I fear the workaround will be just too confusing for them. Can you do any better?
==>
You can either go with Heading block or Fields and Text block, it's your choice, I just shared the possibilities. 🙂

Lets fix the issue one by one and I'll split the ticket with your every new question you will have.

#1949783

I wrote, "I see you moved the conditional block from below the View Loop to above the View Loop. Is that necessary? Is the context above the View Loop different from below?"

Minesh replied, "Yes. The thing is that, you can access the currently displayed post's parent without view but if you want to query the child, you will require a view."

Sorry, my question was: In the View block, why did you move the conditional block from below the View Loop to above? Is that necessary?

#1949793

I wrote, "The block inside that conditional just looks broken now. (See screenshot.)"

Minesh replied, "It's not broken but maybe due to your screen ..."

In the screen shot, it's clearly broken. If it doesn't appear broken on your screen, then I suggest you may want to capture the HTML source to send to your developers to look further into it.

"... and as we added the conditional block within the View's output section."

I didn't understand that bit. If I understand, it's normal to add blocks, including a conditional block, to the View Output section of a View Block. Is that right? If so, it should not appear broken.

#1949799
Screenshot 2021-02-15 085242.png

I wrote, "The broken block is in HTML mode. Is that part of the solution? Why?"

Minesh did not reply to that part of my question. I remain curious whether using HTML mode is part of the workaround.

"When I switch back to Visual mode, it displays the post title of one of the Presentations, not the Event's post title."

Minesh replied, "I can see when I change the "Fields and Text" block mode to visual, it displays the event Title. Please check the following screenshot: hidden link"

No, it's not. Minesh's screen shot reads, "This is One of Two Presentations for Its Event." That is the post title of one of the *Presentation* posts, not the *Event* post as intended.

ALSO NOTE when the public post is viewed, the Event title *is* displayed. (See screen shot.) So the published post shows a *different* title from the Content Template editor. I think that's a bug.

#1949831
Screenshot 2021-02-15 090614.png
Screenshot 2021-02-15 090320.png

I wrote, "The broken block contains <h2>[wpv-post-title]</h2>. If I understand, that refers to the post title of the Event (even though that's not what is displayed in Visual mode). Why is that necessary? I can't use the Parent: Event/Post Title in a Toolset Heading block?"

Minesh replied, "Yes ... if you do not want to go with "Fields and Text" block, you can obviously replace that with Toolset Heading block."

Sorry, I was not asking whether I can use a Toolset Heading block instead of Fields and Text. I was asking whether I must use the shortcode [wpv-post-title] in HTML mode instead of selecting the dynamic source "Parent: Event/Post Title" in Visual mode.

I thought I'd try to do that myself. See screen shot of the Content Template editor. I left Minesh's workaround in place and added a Toolset Heading block just below it with dynamic source "Parent:Event/Post Title." So I expected the Event title to appear twice in that spot.

It didn't work. As you can see in the other screen shot, there *are* two <h2> elements, but the one I added is empty.

#1950897

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

It seems we have to improve bit more here. Toolset Heading block does not offer the current post option (the current post that is currently being displayed) that is why the title is not get displayed.

The option you selected with Heading block is Parent Event and you are currently being displaying the event post, so there will be no parent available. Parent Event will be available when you displaying the Presentation post (because Event post type is Parent of Presentation post type) and the view you added is set to query the Presentation post type but we do not require Presentation post type outside the loop because we want to display the event title when displaying the event post.

So, the workaround I shared is the optimum and I will check with our Devs how we can improve bit here and offer the option with Heading block to select Current post option.

#1951403

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I would like to inform you that we have added a new feature request so that using Toolset Blocks you can access the current post information.