Skip Navigation

[Gelöst] using the views result as shortcode parameter inside other shortcode

This support ticket is created vor 5 Jahre, 9 Monate. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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: Asia/Hong_Kong (GMT+08:00)

Dieses Thema enthält 5 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Luo Yang vor 5 Jahre, 9 Monate.

Assistiert von: Luo Yang.

Author
Artikel
#1080733
view_array.PNG

Tell us what you are trying to do?

I'm trying to get the distinct list from wpv-view result.
ex)
the wpv-view result : a,a,a,a ,b,c,b,a => my expecting output : a,b,c

I made my own shortcode [ mydistinct mydata="a,a,a,a,b,c,b,a"].

I'd like to use wpv-view result as the parameter mydata.
But the wpv-view output looks to be formatted.

I found the resolved support : https://toolset.com/forums/topic/views-result-array-as-shortcode-parameter/
======================================================
add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 );

function prefix_clean_view_output( $out, $id ) {
if ( $id == '375' ) {
$start = strpos( $out, '<!-- wpv-loop-start -->' );
if (
$start !== false
&& strrpos( $out, '<!-- wpv-loop-end -->', $start ) !== false
) {
$start = $start + strlen( '<!-- wpv-loop-start -->' );
$out = substr( $out , $start );
$end = strrpos( $out, '<!-- wpv-loop-end -->' );
$out = substr( $out, 0, $end );
}
}
return $out;
}

========================================
I did
1) add the function to function.php in my theme .
2) change $id == '375' to my view id.

but the output is not working. still formatted. ( attached file )

My question is

Is the filter hook "wpv_filter_wpv_view_shortcode_output" working?
or
anything I have to do ?

Thanks , in advance for your help

Insoo

#1081116

Hello,

The workaround you mentioned above is outdated, I suggest you try another workaround here:
https://toolset.com/forums/topic/filtering-parent-options-by-custom-field/#post-361968

It needs only one custom shortcode to hide the extra DIV tag.

#1082719

Thank you.

I need more help.

1) I want to use my shortcode as parameter inside wpv-view . But the shortcode needs parameter ( [myshortcode param="(param value)"]).

So, I registered my shortcode in the third party attributes of toolset setting.
But because of the paramter inside my shortcode, it doesn't work.
I found in the debug mode that my shortcode was not parsed correctly .

How can I use my own shortcode with paramter inside toolset view?

Insoo.

#1082758

It seems to be a custom codes problem, how do you setup the shortcode [myshortcode]?
How do you use it as parameter inside wpv-view?
How do you setup the view?
Please describe detail steps to duplicate the same problem, I need test and debug it in my localhost, thanks

#1082811

Thank your for your reply again

This my real code

[wpv-view name="distinct-test2" local='[senavi_distinct mydata="[wpv-view name='distinct_test']"]']
=> Fail
display : ']

[senavi_distinct mydata=" "] is myshortcode

When the code is seperated into two steps as below code, the output is displayed well.

1)[senavi_distinct mydata="[wpv-view name='distinct_test']"]
2) [wpv-view name="distinct-test2" local='1) output ']
=> OK

#1082815

You are using three level nested shortcodes, it conduct the problem, I suggest you try these:
1) Create a content template "test-ct", with the custom shortcode:

[senavi_distinct mydata="[wpv-view name='distinct_test']"]

2) Use above content template as view's shortcode attribute, for example:

[wpv-view name="distinct-test2" local='[wpv-post-body view_template="test-ct"]']

And you will need to register your custom shortcode name "senavi_distinct" here:
Dashboard-> Toolset-> Settings-> Front-end Content,
Option "Third-party shortcode arguments"

Dieses Ticket ist jetzt geschlossen. Wenn Sie ein Toolset Kunde sind und Hilfe benötigen, eröffnen Sie bitte ein neues Support-Ticket.