Skip Navigation

[Resolved] Problem with View wrapper div override after Views 1.12 upgrade.

This support ticket is created 8 years, 1 month 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
- 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 -
- - - - - - -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

Tagged: 

This topic contains 7 replies, has 5 voices.

Last updated by Shawn 8 years, 1 month ago.

Assisted by: Adriano.

Author
Posts
#371829

Hey guys,

Following from https://toolset.com/forums/topic/disabling-new-view-wrapper-div-in-views-1-11/ the override I implemented based on that thread is now broken in Views 1.12.

I thought it was a bit of an ugly solution in the first place, so instead of trying to debug it first, I'd like to see if there's a better way of doing this yet.

The code that's stopped working is (results in no output from the view):

add_filter( 'wpv_filter_wpv_view_shortcode_output', 'thewebists_no_view_wrap', 5, 2 );
function thewebists_no_view_wrap( $out, $id ) {
    global $WP_Views;
    $view_shortcode_attributes = $WP_Views->view_shortcode_attributes;
    if($view_shortcode_attributes[count($view_shortcode_attributes)-1]["no-view-wrap"] == "true") {
        $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;
    }
}

So, can you either give me a better solution for selectively disabling the View wrapper div, or let me know what changes you've made in the latest plugin that would break this.

Regards,
Andy

#371865

Hello,

I’m Adriano, Toolset support lead and I have been escalated to this thread. I’ll give my best to help you to achieve your needs through Toolset components.

I've talked to our development team and nothing has been changed regarding to that. Although unfortunately we don't have any other way to do that, since we are not willing to hide this section. Avoiding this section may cause problem in Views that contains pagination, infinite scrolling and so on.

Anyway, it should be hidden on your site using this code. I need to look after your site, please provide credentials.

#372550

Hey Adriano,

Since you guys haven't made any changes recently that could affect this, I looked into the issue again from my end. Looks I made mistake in merging git branches and there's an actual logic error in the code... The lines with the "return" and the { have been swapped.

For posterity's sake, the code should be:

add_filter( 'wpv_filter_wpv_view_shortcode_output', 'thewebists_no_view_wrap', 5, 2 );
function thewebists_no_view_wrap( $out, $id ) {
    global $WP_Views;
    $view_shortcode_attributes = $WP_Views->view_shortcode_attributes;
    if($view_shortcode_attributes[count($view_shortcode_attributes)-1]["no-view-wrap"] == "true") {
        $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;
}

On a different note though, being able to reliably remove the div wrapper on Views is actually a really important piece of functionality for me. I've heard the same view expressed by other Toolset developers I work with.

Imho, this is only a requirement for advanced Toolset users, and as such I don't see any need for it to be implemented in the dashboard where it could cause problems for users that do not fully understand the consequences of using the option.

However a WordPress filter allowing the wrapper to be parsed/removed would be an ideal solution. Maybe as a bonus you could add a shortcode parameter to the wpv-view shortcode that uses the filter to remove the wrapper.

This is a really critical piece of functionality for me, which affects a large number of projects, so could I please ask you to follow up on this and try to get it pushed through with the dev team?

Regards,
Andy

#372557

Great! Yes, of course. I'll talk to the developers about that, thanks for suggesting this. For any other question please open a new thread.

#372797

Thanks.

#423068

I would really like a more clean way to remove those DIV's as well, they are often causing me styling headaches - especially when nesting views inside views. If you don't want to expose this through the main dashboard I think adding a parameter to the wpv-view shortcode would be an ideal solution.

#531272

Andrzej - do you know if this solution still works in the latest version of Views (2.4.0)? I am having real problems with these ******* Wrapper divs and this is the most up-to-date solution I can find, but I can't get it working.

Thanks for any input 🙂

#531504

+1

I think a shortcode param would be ideal for this. For a simple View with no pagination or scrolling features, the wrapping div is unnecessary and is causing me styling issues as well.

Please and thanks in advance.

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