Skip Navigation

[Resolved] Can I remove the DIV that is wrapped around VIEWS

This support ticket is created 7 years, 3 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.

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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 4 replies, has 2 voices.

Last updated by Shane 7 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#482837

Hello,

I'm trying the create a grid based upon different views, but the div's wrapped around the views output do interfere...

Let me explain the issue and approach.

I do have 9 different Custom Post Types
All those Custom post types share the same Custom Taxonomy.

Per Taxonomy entry i'm creating an overview grid with links to Custom Post Type Archives

Lets say the Taxonomy is called "Sector" and contains the items [Tourism / Agri / Logistic ]

Then i'm creating a grid for Tourism, a grid for Agri and a grif for Logistic.

This grid displays Links to the Custom Post Tope Archives. But i only want a Link to a CPT archive if there is at least one entry for the selected Taxonomy.

e.g.: Sector->Tourism
Only CPT1, CPT2 and CPT5 comtain a post with the tourism sector checked.

Then I only want a link the the archives of CPT1, CPT2 and CPT5

Per CPT i'm using a view to check if there are posts based upon the taxonomy using a views parameter.

Everything works, only the problem is that every view is wrapped in a DIV. I only want to output a link when there is at least one item. The other views should not output anything.

is this possible... removing the wrapper Div of the views?

#482949

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Herre,

Thank you for contacting our support forum.

Actually we have a custom filter to help with this.

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

Just change the 375 to the ID of the view that you are using.

Please let me know if this helps.
Thanks,
Shane

#483615

Hi Shane,
first of all, thank you for your quick response.

This solution seems to be working partly. Views that do contain results, are being stripped clean.
But views that do result in no items found are still being wrapped in divs.

What would be the best solution?

It would be great in one of the future releases of views to have the option to enable / disable this wrapper on a view basis with a checkbox or radiobutton.

#483698

I believe i've tackled this one...

Added an ELSE statement when $start variable or the strrpos() function returns false.

There I reused the same code but checkking on content between <!-- wpv-no-items-start --> and <!-- wpv-no-items-end --> in my no results section of the Views.

Guess this will be sufficient for my use... but i'm wondering why this isnt an option in Views as a selector. And why is Views standard outputting the Div? Is there a certain reason?

#483738

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Herre,

This was added because of the new infinite scroll and pagination functionality.

There are plans to have an option in Views to disable this, however there are no ETA on this.

Thanks,
Shane

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