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 6 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.

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
- 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)

This topic contains 19 réponses, has 2 voix.

Last updated by fred-r.M Il y a 4 années et 6 mois.

Assisted by: 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

Languages: Anglais (English )

Timezone: 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:
=> hidden link

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:
=> hidden link

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;
=> hidden link

I can see now iframe is rendered correctly:
=> hidden link

#1339893

Dear Minesh

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

Languages: Anglais (English )

Timezone: 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:
=> hidden link

#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

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