Skip Navigation

[Resolved] Use the same View producing other output based on ShortCode attribute

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

Problem:
I want to use the same View but show different content based on ShortCode attributes.

Solution:
You can use what we call "ShortCode Attributes", but you cannot use that in Toolset Blocks, in case you intended to.
You have to use Toolset Views (which you can also proceed using later when we release a more "block related" version Views 3.0).

Relevant Documentation:

https://toolset.com/documentation/user-guides/passing-arguments-to-views/

https://toolset.com/documentation/user-guides/passing-arguments-to-views/#controlling-the-filter-with-shortcode-attributes

This support ticket is created 4 years, 4 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by Bobby339 4 years, 4 months ago.

Assisted by: Beda.

Author
Posts
#1396727

Tell us what you are trying to do? Reuse a View in multiple locations around my site but have different elements appear based on a shortcode variable (not a CPT).

I have a View that is checking for X and displaying "A" when it finds any results... however to not create MULTIPLE Views with the same basic functionality just to output something slightly different, how can I reuse that that View but have it display "B".

I was thinking that there would be some shortcode variable (not a CPT) that would change the output.

For example: if the "normal" View shortcode is [wpv-view name="myview"] but when I put that on the homepage I want it to output message A I change the shortcode to [wpv-view name="myview" content="a"] but if I put that same shortcode with a different variable on another page with b as the variable, like this [wpv-view name="myview" content="b"] it would output message B. Of course there would need to be conditional statements in the output of the View...

[wpv-conditional if="( content() eq 'a' )"]This is the A message[/wpv-conditional]
[wpv-conditional if="( content() eq 'b' )"]This is the B message[/wpv-conditional]

So there isn't a CPT that is being pulled in, just a shortcode variable based on where I put the View to control the output.

#1396739

You can use what we call "ShortCode Attributes", but you cannot use that in Toolset Blocks, in case you intended to.
You have to use Toolset Views (which you can also proceed using later when we release a more "block related" version Views 3.0).

We explain the basics here
https://toolset.com/documentation/user-guides/passing-arguments-to-views/

You can notice there are many ways of passing the "arguments" to Views, but if you specifically look for a ShortCode attribute passing it, you can see here how it's set up and inserted:
https://toolset.com/documentation/user-guides/passing-arguments-to-views/#controlling-the-filter-with-shortcode-attributes

Let me know if I can help you with anything else!

#1398633

My issue is resolved now. Thank you!

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