Skip Navigation

[Resolved] Is it possible to use the value received via VIEW_PARAM in a view?

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 3 replies, has 1 voice.

Last updated by davidL-7 1 month, 2 weeks ago.

Assisted by: Minesh.

Author
Posts
#2805813
Screenshot 2025-04-18 at 1.00.35 PM.png
Screenshot 2025-04-18 at 12.59.51 PM.png

I have a view that gets filtered by a value sent via a VIEW_PARAM(accountid). (Screenshot of the query below. )

I need to use the value of that accountid in a shortcode that is used outside of the <wpv-loop>, like so:
[show-total5 show_difference='1' accountid='[Value of VIEW_PARAM(accountid)]'][/show-total5]
(See screenshot below.)

Is there any possible way to do that?

Minesh has supported me on this project. The [show-total] shortcode he helped develop works beautifully on a page that shows a single account where the accountid is provided to the custom code function by the query string. But in this case (work-in-progress at hidden link), multiple accounts get shown on one page, so we don't have an accountid in the query string.

Instead, [show-total5], in use in view 39998 needs to get the accountid to the custom-code "calculate_yearly_totals", which defines the show-total5 shortcode. If we can get the accountid coming from the VIEW_PARAM into the shortcode, calculate_yearly_totals should be able to use it with $atts['accountid'] and will work.

If it's just not possible, let me know and I can explain more of the relationships so perhaps we can figure out another way to get that accountid into the function.

Thanks!
David

#2805951

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

You can access the URL param using the view's shortcode: [wpv-search-term param='accountid']

So your shortcode should looks something like this:

[show-total5 show_difference='1' accountid="[wpv-search-term param='accountid']"][/show-total5]

More info:
- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-214940

#2806052

Hi Minesh,

Thanks for the reply. In this case, we're trying to get the View parameter (provided via a shortcode attribute), not a URL parameter. I tried it out, but it looks like [wpv-search-term param=''] may only work for an URL parameter.

In our case, in case you want to look at it (you should still have access to hidden link), in View 39945 (toolest-test-show-view-in-form) we use a shortcode to insert View 39998, like so:

[wpv-view name="yearly-totals-amount-remaining-for-account" accountid="[types field='accound-id'][/types]

In View 39998 (Yearly Totals - Amount Remaining for Account), we are using the showtotal5 shortcode (outside the loop) and are trying to get that View parameter sent from the shortcode into it. Here's my most recent attempt based on your reply:

[show-total5 show_difference='1' accountid='[wpv-search-term param="accountid"]'][/show-total5]

But [wpv-search-term param="accountid"] isn't returning a value (see hidden link, where the value would show in purple if it worked). At first I thought it might be because I was calling it outside the loop, but I tried it in the loop as well and it doesn't return a value, so I'm thinking it only works for URL parameters.

Can you think of any way to get that View parameter? (Which is successfully getting sent and filtering the view.)

Thanks,
David

#2806236

Minesh
Supporter

Languages: English (English )

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

Ok - if you want to access the view's shortcode attribute, you can use the view's shortcode [wpv-attribute].

For example:
You have this shortcode:

[wpv-view name="yearly-totals-amount-remaining-for-account" accountid="[types field='accound-id'][/types]

And you can get the shortcode attribute "accountid" value as: [wpv-attribute name="accountid"]

So, finally, with your shortcode:

[show-total5 show_difference='1' accountid='[wpv-attribute name="accountid"]'][/show-total5]

More info:
- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-attribute

#2806290

That's what I needed Minesh, that worked like a charm.

And for the benefit of whomever else may read this in the future, in my testing the [wpv-attribute] shortcode successfully brought in the parameter value both inside *and* outside the loop.

Thanks again!