Bought a theme. Running into errors. Any suggestions?

Here is a screenshot.

Thanks

The first line returns a page object, in the second line, the count method is used, but that is a collection method, so that does not make sense.

Is that a change you made?

Remove the first() method from the first line, then it should work.

Hi @bbarclay!

The count() method is only available on Collection objects, but you are trying to call it on a single page object.

I’m not quite sure what you’re trying to accomplish, but if you want to check if there are any entries added to a structure field, you should fetch that field’s contents and convert it to a Collection object at first, in the same way you’re doing this in the for each loop later on…

if($services->services()->services()->toStructure()->count() > 0) { … }

If you want to check if there are any pages that are using the services template, than you must not call the first() method in order to get the full collection and not just its first item.

$services = $site()->index()->filterBy('template', 'services');

All this is super helpful. I’m getting through it, but now it’s giving me this.

<?php if(!$team->members()->empty()): ?>

returning this.

Call to a member function empty() on null

Please provide some more context, $team->members() does not seem to be a field…

Not sure if this is enough information or not. thanks for all the help.

if($team->count() > 0): ?>
<?php if(!$team->members()->empty()): ?>

  <section class="" id="section-team"> 
      <div class="container text-center">
          <?php if($page->isHomePage()): ?>
            <div class="text-center container-title">
              <h2 class="">About Us</h2>
              <hr class="line">
            </div>
          <?php endif ?>
          <div<?php if($team->members()->toStructure()->count() > 3): ?> id="carousel"<?php endif ?> class="carousel slide">
            <?php $chunks = $team->members()->toStructure()->chunk(3); ?>
            <?php $first = $chunks->first(); ?>
            

            <!-- Wrapper for slides -->
            <div class="carousel-inner">
                <?php foreach($chunks as $items): ?>
                  <!-- Slide -->
                  <div class="item<?php if($items == $first) echo ' active' ?>">
                    <div class="/*container*/ col-xs-8 col-xs-offset-2">
                      <?php foreach($items as $item): ?>
                      <?php $picture = $team->image($item->picture()); ?>
                        <div class="col-xs-12 col-sm-4 member">
                          <img class="img-responsive text-center" src="<?= $picture->url() ?>" alt="Portrait" />
                          <h3 class=""><? echo $item->name()->html() ?></h3>
                          <p class=""><? echo $item->position()->html() ?></p>
                          <a href="mailto:<? echo $item->mail()->html() ?>"><? echo $item->mail()->html() ?></a>
                        </div>
                      <?php endforeach; ?>
                    </div>
                  </div>
                <?php endforeach ?>
            </div>

            <?php if($team->members()->toStructure()->count() > 3): ?>
            <!-- Controls -->
            <a class="left carousel-control" href="#carousel" data-slide="prev">
                <span class="glyphicon glyphicon-chevron-left"></span>
            </a>
            <a class="right carousel-control" href="#carousel" data-slide="next">
                <span class="glyphicon glyphicon-chevron-right"></span>
            </a>
            <?php endif ?>
      </div>
  </section>


<?php endif ?>
<?php endif ?>

But what is $team?

Hope you inserted those errors or did you buy the theme like that?

Theme like this. The developer is saying he’s not getting these errors, so we are also trying to work with him to resolve this.