Skip Navigation

[Résolu] How to use conditional and output what we need

This support ticket is created Il y a 4 années et 9 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 19 réponses, a 2 voix.

Dernière mise à jour par fred-r.M Il y a 4 années et 9 mois.

Assisté par: Minesh.

Auteur
Publications
#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

Les langues: Anglais (English )

Fuseau horaire: 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:
=> lien caché

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:
=> lien caché

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;
=> lien caché

I can see now iframe is rendered correctly:
=> lien caché

#1339893

Dear Minesh

Ok, yes. But on this, where I used to get an image, lien caché 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

Les langues: Anglais (English )

Fuseau horaire: 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:
=> lien caché

#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

Ce ticket est maintenant fermé. Si vous êtes un client de Toolset et que vous avez besoin d'aide, veuillez ouvrir un nouveau ticket d'assistance