Skip Navigation

[Resuelto] How to get view to appear on same line as other content?

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:
Get clean output from a view.

Solution:

The code below should be able to assist you.

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 hace 6 años, 2 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 4 respuestas, tiene 2 mensajes.

Última actualización por davidR-12 hace 6 años, 2 meses.

Asistido por: Shane.

Autor
Mensajes
#1105556

I have created a taxonomy view that displays terms. I want this view to display the terms on the same line as other content. However, as the view is contained in a <div> and doesn't seem to have a definitive class (Each iteration of the view has its own class and I am using the view a lot) I cant see a way to do this. I was provided with a solution to this before but I cannot see it in my support archive.

Regards,

David

#1105633

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi David,

What you might need to do is to wrap each of those view shortcodes in separate divs like this.

<div>shortcode</div>
<div>shortcode</div>

Then style those wrapper divs to get them aligned horizontally .

Thanks,
Shane

#1106522

Hi Shane,

That doesnt fix the issue. Toolset is generating a <div> that has no fixed class so I cant style it. I need to remove the div that the view is creating and replace it with a <span> (which I am convinced I have done before but cannot find on my help ticket feed) or I need to be able to give the view a fixed class so I can target it wherever it appears on the site.

Regards,

David

#1106694

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi David,

I believe this is the code that you are referring to.

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 should remove the div around the view.

Thanks,
Shane

#1107508

Hi Shane,

YES! Thats the one thank you. I have saved it this time to my code repository as I know I will need it again at some point.

Regards,

David