Skip Navigation

[Closed] Utilizar un Shortcode de una Views dentro de otro Shortcode

This support ticket is created 3 years, 10 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 5 replies, has 2 voices.

Last updated by Nigel 3 years, 10 months ago.

Assisted by: Nigel.

Author
Posts
#1659651

Hola Nigel, necesito crear esta función poniendo un shortcode dentro de otro.

[types field='estic-d-acord-amb-totes-les-condicions-indicades' item='[wpv-view name="id_docent"]'][/types]

Tal como me comentáste hace un tiempo en el tiket #563646 se había de quitar un div envolvente de la Wiews, con la función que me indicaste

/**
 * Naked Views output with no wrapper divs
 */
add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_naked_view_output', 5, 2 );
function prefix_naked_view_output( $out, $view_id ) {
   if ( 3234  == $view_id ) { // Editar el ID como sea necesario
        $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;
}

Ahora no me funciona, sigue siendo valida?
la Wiews que quiero quitar el div es ID 3234
Saludos.
Rafa Corts

#1660333

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Screenshot 2020-06-12 at 15.44.05.png

Hola Rafa

Hoy en día no es necesario usar código, tienes una opción en la View...

#1661461
Captura de pantalla 2020-06-13 20.08.09.png
Captura de pantalla 2020-06-13 20.08.15.png

Hola Nigel, he seleccionado esta opción y sigue sin funcionar.

[wpv-post-url item="[wpv-view name='id_docent']"]

Es para poder saber el ID de un Post Type i crear una condición para mostrar o ocultar un boton.
Saludos.
Rafa Corts

#1663463

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Screenshot 2020-06-15 at 14.52.46.png

Mejor usar el Loop Wizard y elegir la opción "List with Separators" para la forma de salida.

Puede ser que usar una plantilla en la salida del View afecta los resultados.

#1665659
Captura de pantalla 2020-06-16 20.44.42.png

Hola Nigel, ahora si perfecto con la opción "list With Separators" .
Otra duda con los shortcode:
Con este otro código también podia ser correto ?
[php]
[wpv-conditional if="( '[types field='estic-d-acord-amb-totes-les-condicions-indicades' item='[wpv-view name="id_docent"]'][/types]' eq 'Si, accepto' )"]
Dentro
[/wpv-conditional]
Con esta condición quiero saber que si en un formulario en donde hay el campo [types field='estic-d-acord-amb-totes-les-condicions-indicades'][/types] en formato checkbox esta seleccionado .
Te lo pregunto por que no llega a funcionar. por un lado hay una View para que filtre por autor y "Si, accepo" esta puesto en lugar de 1 o 0 hay este texto.
Saludos.
Rafa Corts

#1666317

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hola Rafa

Sin pensar mucho veo un problema, es decir que la clausa entera de if debe ser dentro de "..." ininterrumpida.

Tambien puedes activar el modo debug para ver los valores comparados.

Prueba

[wpv-conditional if="( '[types field='estic-d-acord-amb-totes-les-condicions-indicades' item='[wpv-view name='id_docent']'][/types]' eq 'Si, accepto' )" debug="true"]
Dentro
[/wpv-conditional]

The topic ‘[Closed] Utilizar un Shortcode de una Views dentro de otro Shortcode’ is closed to new replies.