Code stop working after changing php version

Hi everyone! Recently I changed the php version of my host to 5.5 in order to use oembed plugin but other part of my code stop working. Running locally with MAMP everything works great.

I’m very not with PHP, Could you help me please?

Here the code, thanks in advance.

<?php if(!$page->text()->empty()): ?>
    
    <div class="gallery">
        <?php foreach($page->text()->kirbytext()->split(',') as $tag): ?>
        <div class="gallery-cell">
            <?php echo $tag?>
        </div>
        <?php endforeach ?>
    </div>

<?php else: ?>
    <div class="gallery">
          <?php foreach($page->images()->sortBy('sort', 'asc') as $image): ?>
          <div class="gallery-cell">
            <img src="<?php echo $image->url() ?>" alt="<?php echo $page->title()->html() ?>">
          </div>
          <?php endforeach ?>
    </div>

<?php endif ?>

First of all, you really should turn on debugging during development in your config.php:

c::set('debug', true);

Secondly, this line:

 <?php foreach($page->text()->kirbytext()->split(',') as $tag): ?>

should be replaced with this:

 <?php foreach($page->text()->split(',') as $tag): ?>

thanks for the debug suggestion, but when I remove “->kirbytext()->” oembed doesn’t work. With $tag im referring to oembed links.

Could you post your blueprint and what you have in your text field?

I think you’d better use a structure field with several url fields and then call the oembed() field method in your template on every URL as described in the oEmbed readme

Blueprint:

fields:
  oembed_videos:
    label: Videos
    type: structure
    fields:
      video_url:
        label: Video URL
        type: url

In your template:

<?php if($page->oembed_videos()->isNotEmpty()): ?>
<?php $videos = $page->oembed_videos()->toStructure();  ?>
    <div class="gallery">
        <?php foreach($videos as $video): ?>
        <div class="gallery-cell">
            <?php echo $video->video_url()->oembed() ?>
        </div>
        <?php endforeach ?>
    </div>

<?php else: ?>
    <div class="gallery">
          <?php foreach($page->images()->sortBy('sort', 'asc') as $image): ?>
          <div class="gallery-cell">
            <img src="<?php echo $image->url() ?>" alt="<?php echo $page->title()->html() ?>">
          </div>
          <?php endforeach ?>
    </div>

<?php endif ?>

Thanks I will try it. With Structure field do you refer this?
https://getkirby.com/blog/structured-field-content

by the way here my blueprint
https://cloudup.com/c-qVOUFIQZA
and the content in the field.

I posted a suggestion above. Pls. don’t post code as images.

To this, which is a Kirby 2 feature.

Oh! I didn’t saw it thank you.
Sorry for the image :worried:

I will try what are you suggesting. Thanks for your help!

Thank you this worked perfectly, know I understand better. Thanks again!

You’re welcome :slightly_smiling: