Skip Navigation

[Résolu] views result array as shortcode parameter

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
Since View 1.11 default HTMl is wrapped around the View's Loop and this makes it impossible to populate things like charts or other 3rd Party Plugins with Views generated data.

Solution (include the steps to folow here):
At your own risk you can use this Custom Filter:

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;
}
This support ticket is created Il y a 8 années et 5 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 36 réponses, has 2 voix.

Last updated by Steve Il y a 8 années et 5 mois.

Assisted by: Beda.

Auteur
Publications
#344998

I apologize, but it's not 🙂

What do you mean with?

#345009

it was just about different mail addresses and so on…

thanks a lot for the video! looks quite easy. 😉
for the moment i still need to concentrate on another project to get the presentation done, but i will give it another try later on.

best,
s

#345011

Sprichst Du Deutsch?

Ich "steige" nicht, was die 53 angeht. geht kein Lichtlein auf bei mir...

<==EDIT==>
Ja, hab's kapiert 🙂
Deine "andere Email" 😛

Nun, in Englisch wieder...

Hope it will work on your end.
Please don't hesitate to get back here, in case you find troubles with the setup.

Thank you for your patience.

#345561

hej beda.

thanks again for the tutorial. i was able to reproduce it with one field/loop of mine and got a working line chart.

what i am still struggling with is the syntax of the ids array in my functions.php:

 if ( $id == '1' )

… works fine.

 if ( $id == '1,2,3,4,5' )

… doesn't work at all!

how does the syntax work with multiple ids?

best,
s

#345598

You need an array.

Excluding

$exclude_ids = array( 123, 456, 789 ); //SET YOUR EXCLUDING IDS HERE
    if ( ! in_array( $view_id, $exclude_ids ) {
...
}

Including

if (in_array($view_id, array(12, 13, 14) ) )  { //set your View ID's here
...
}

Please do not hesitate to open a new thread if other issues or problems arise

Thank you for your patience.

#345627

hej beda.

that's the pre-final post just for anybody else who might follow at any time, here' s the final code for the functions.php …

add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 );
 
function prefix_clean_view_output( $out, $id ) {
	
	$exclude_ids = array( 12, 34, 56, 78  ); //SET YOUR EXCLUDING IDS HERE

    if ( !in_array( $view_id, $exclude_ids ) ) {

        $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;
}   

thanks a lot beda for your help!!!

best,
s

#345628

one more time: thanks a lot beda for your help!!!

best,
s

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