Navigation überspringen

[Gelöst] How to use conditional and output what we need

This support ticket is created vor 5 Jahren, 3 Monaten. 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.

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)

Dieses Thema enthält 19 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von fred-r.M vor 5 Jahren, 3 Monaten.

Assistiert von: Minesh.

Author
Artikel
#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

Sprachen: Englisch (English )

Zeitzone: 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:
=> versteckter 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:
=> versteckter 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;
=> versteckter Link

I can see now iframe is rendered correctly:
=> versteckter Link

#1339893

Dear Minesh

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

Sprachen: Englisch (English )

Zeitzone: 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:
=> versteckter 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