Matching date from structure field with tag

Hello
I can’t match my date into a structure field with my filter tag. I already used the same code with text field and it worked, but not in this case. If I echo the $tit, I have the same date structure as my structure field, so I’m wondering what I’m doing wrong.

<?php if($tit = $jourspara): ?>
    <?php $item = $page->pleines()->toStructure()->findBy('date', $tit); ?>
    <?php if($item) { ?> 
    <div class="black"> 
        <?php echo $item->description();
                    } ?> </div>
    <?php endif ?>

my blueprint

fields:
  rubriques:
    label: Rubriques
    type: structure
    entry: >
      Date : <h1>{{date}}</h1><br />
      Description : <br />{{description}}
    fields:
      date:
        label: Date
        type: date
      description:
        label: Description
        type: textarea

Are you sure you are using the correct field? According to your blueprint the field is call rubriques?

Pfff…my fault sorry. I was looking for the ‘pleines’ page where I have my structure so

<?php if($tit = $jourspara): ?>
    <?php $item = $site->page('pleines')->rubriques()->toStructure()->findBy('date', $tit); ?>
    <?php if($item) { ?> 
    <div class="black"> 
        <?php echo $item->description();
                    } ?> </div>
    <?php endif ?>

But it doesn’t return the “description” yet.

This should work:

<?php $item = $site->page('pleines')->rubriques()->toStructure()->findBy('date', strtotime($tit)); ?>
1 Like