Skip Navigation

[Resuelto] How to use conditional and output what we need

This support ticket is created hace 5 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Este tema contiene 19 respuestas, tiene 2 mensajes.

Última actualización por fred-r.M hace 5 años, 2 meses.

Asistido por: Minesh.

Autor
Mensajes
#1339637
2019-09-13_17-55-36.png

You find it under Impreza, Page Blocks, Tourist Spot Page Block!

Please check the image for it!

#1339821

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Thank you. After deep investigation, I found that the issue is the shortcode added to iframe do not get rendered:
- when I check the source code in page soruce it looks like as given under:

<iframe src="[types field='location-video' output='raw'][/types]" width="420" height="345"><br />
</iframe>

Additionally, I found that if I change the content template form here:
=> enlace oculto

And try to apply the content template or Layout build with Tooslet it does not get effect. So, your theme looks like taking over the control what to render and discards whatever we set to display with Toolset (content template or layout).

The only way I found to share solution with you is I've added the following code to "Custom Code" section of Toolset:
=> enlace oculto

function func_display_iframes() {
  
  global $post;
  $location_video = $vimeo_video = '';
  
  $location_video = get_post_meta($post->ID,'wpcf-location-video',true);
  $vimeo_video = get_post_meta($post->ID,'wpcf-vimeo-video',true);
  
  if($location_video != '' and $vimeo_video == '') {
     $str = '<iframe src="'.$location_video.'" width="853" height="480" frameborder="0" allowfullscreen="allowfullscreen"></iframe>';
  } else if ($location_video == '' and $vimeo_video != '') {
      $str .= '<iframe src="'.$vimeo_video.'" width="853" height="480" frameborder="0" allowfullscreen="allowfullscreen"></iframe>';
  }
  
  return $str;
  
  
}
add_shortcode( 'show_iframe', 'func_display_iframes' );

And then displayed the shortcode [show_iframe] with your page builder text module;
=> enlace oculto

I can see now iframe is rendered correctly:
=> enlace oculto

#1339893

Dear Minesh

Ok, yes. But on this, where I used to get an image, enlace oculto it is still not okay...

Question, why you did not use the child themes function.php, to create the short code function?

Maybe we include the image part too, in there.

As I mentioned earlier, having the closing [/wpv-conditional] is not working somehow. Could also be a theme issue. But maybe we can fix this too?

Regards,

#1339983

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Question, why you did not use the child themes function.php, to create the short code function?
==> Because if you will change the theme, you need to copy/paste the code to functions.php file again. But as we added the code to custom code section, it will not be the case if you change the theme.

More info:
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

Ok - I've updated the code as given under:

function func_display_iframes() {
  
  global $post;
  $location_video = $vimeo_video = '';
  
  $location_video = get_post_meta($post->ID,'wpcf-location-video',true);
  $vimeo_video = get_post_meta($post->ID,'wpcf-vimeo-video',true);
  
  if ($location_video == '' and $vimeo_video == '') {
    $str = do_shortcode("[wpv-post-featured-image size='center' class='img-responsive']");
  }else  if($location_video != '' and $vimeo_video == '') {
     $str = '<iframe src="'.$location_video.'" width="853" height="480" frameborder="0" allowfullscreen="allowfullscreen"></iframe>';
  } else if ($location_video == '' and $vimeo_video != '') {
      $str .= '<iframe src="'.$vimeo_video.'" width="853" height="480" frameborder="0" allowfullscreen="allowfullscreen"></iframe>';
  }
  
  return $str;
  
  
}
add_shortcode( 'show_iframe', 'func_display_iframes' );

I can see now the expected results:
=> enlace oculto

#1340281

My issue is resolved now. Thank you!

Dear Minesh

Thank You to solve this issue and problem. I just saw a bit more behind the scene of toolset.

Regards,

Simon