Skip Navigation

[Resolved] Responsive grids and passing arguments into content templates

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
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+00:00)

This topic contains 5 replies, has 2 voices.

Last updated by alexG-4 3 years, 11 months ago.

Assisted by: Jamal.

Author
Posts
#1626261

There is a sequence of conditions that have led me to what I think us an impasse.

I'm trying to create a grid-based views layout that is responsive, without me having to load the bootstrap library. (I'm using Astra, which already uses their own version of bootstrap, so this would be doubling up the amount of css.)

This has required me to deactivate views and activate blocks instead so that I can create the view within the block editor using a grid block.

Because I wish to use that view in multiple locations, I've created it within a content template.

Depending on where I wish to display the view, I want to pass it an attribute with different values, and then use [wpv-attribute name="..."] to get the value.

But because I have to use the content template shortcode to display the view, rather than the View shortcode, I'm not able to pass it an attribute value. (I've tried this and it didn't work: please confirm that it is NOT possible.)

Currently, I see four options:

1) Don't use the attribute mechanism, but instead create 8 to 10 different versions of the content template and view - not a good choice for maintenance purposes.

2) Write some php code so that I CAN pass a parameter into the content template.

3) Abandon the use of blocks and use some jQuery library/CSS code. Urg!

4) Use Bootstrap anyway - probably the least work.

But am I missing another option?

Finally, the view also uses a content template within the loop to display the actual data: when I pass an attribute into the view I'm assuming I will be able to access its value using [wpv-attribute name="..."] from within the content template in the loop. Right?

Thanks for any clarification!

Alex

#1627219

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello Alex, and thank you for contacting the Toolset support.

Currently, the view and content template blocks do not offer a way to pass an argument similar to the legacy views editor. To work around it, you can use the shortcode, classic, or Fields and text block.

My question is why using a content template to display the view, why not inserting the view directly with a shortcode?

To better answer your last question, I prefer to take a closer look at your views to be sure. Would you allow me temporary access to your site? Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1630263

Hello Jamal

Thanks for responding. I didn't get an email notification of your response (I checked in Spam as well), which is why I didn't respond sooner.

You said:
Currently, the view and content template blocks do not offer a way to pass an argument similar to the legacy views editor. To work around it, you can use the shortcode, classic, or Fields and text block.

I DID use the Field and Text block. I CAN include an argument in the shortcode for a content template. What I meant to say was that the argument is being ignored. When I use [wpv-attribute name="..."] in the View to access the argument, it doesn't display anything. So I'm assuming that when you include an argument in a Content Template, it doesn't get passed into the View.

You said:
My question is why using a content template to display the view, why not inserting the view directly with a shortcode?

When I use the Content Template, I get the correct grid layout defined by the Content Template. When I use the View shortcode direct, I don't get the grid layout. See this video:
hidden link

Are there any options beyond the four I listed?

Alex

#1631053

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hi Alex and thank you for your feedback. I run a local test where I directly put a view inside a page using a shortcode and passed the value to [wpv-attribute name="..."] both inside the loop and inside a content template used within the view. Both the view and the content template are created using the classic editor.

I tried with a page using the classic and the bloc editor. In both ways, the value was correctly passed to [wpv-attribute name="..."].

Then I used a content template and put the view inside of it, the value was correctly passed to [wpv-attribute name="..."]

Would you allow me temporary access to check this further? Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1632305

Jamal

None of the things you tested were what I was doing.

It's not that I ADDED a view to a content template. I CREATED the view inside a content template using the Blocks plugin, and that's how I got the view to display a grid layout.

[ Note that, at the beginning of this thread, I stated...
This has required me to deactivate views and activate blocks instead so that I can create the view within the block editor using a grid block.]

And then I got into this catch-22 situation...
If I used the view's shortcode to display it - which would allow me to pass it an attribute - the view didn't display as a grid.
If I used the content template shortcode to display it, I DO get the grid layout, but when I add an attribute to the content template shortcode, it doesn't get passed down to the view that was created within it.

I think I'm going to have to disable Blocks and re-enable Views and use Bootstrap to create my responsive grid layout.

Thanks

Alex

#1632307

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.