Some categories not showing up

10 posts by 3 authors in: Forums > CMS Builder
Last Post: August 23, 2019   (RSS)

By gregThomas - July 19, 2019

Hey Common Sense Design,

Here are a few common problems that could cause this issue:

  • There is a hidden character in the dropdown value (as displayed in category-02.jpg) such as an extra space.
  • There are no records in the database with the category TCMH, or the records that have the category are hidden.

If it isn't either of these issues, please could you raise a second level support request (https://www.interactivetools.com/support/request/) so that I can take a look at how the page is set up? I'll need the sites FTP and CMS login credentials.

Cheers,

Greg

Greg Thomas

PHP Programmer - interactivetools.com

By CommonSenseDesign - July 19, 2019

Thanks, Greg. I'm sending you the details.

By CommonSenseDesign - August 15, 2019

Hi, Greg.

Thanks for the solution you sent me via email a while back.

Is there a way of solving this without having to add an image to each record? I know it works, but that seems a bit inelegant. If there isn't an easy fix, I certainly don't have a problem with passing your suggestion on to my client, though.

Thanks!

By gregThomas - August 15, 2019

Hey Nigel,

You just need to check if the image array exists and display the title on its own if it doesn't:

<div class="col-md-5">
  <?php foreach ($calendarRecords as $record): ?>
    <?php if(empty($record['upload])): ?>
      <?php echo htmlencode($record['title']) ?>
    <?php else: ?>
      <?php foreach ($record['upload'] as $index => $upload): ?>
        <p>
          <?php echo $record['category:label'] ?>:
          <a href="<?php echo htmlencode($upload['urlPath']) ?>" target="_blank">
            <?php echo htmlencode($record['title']) ?>
          </a>
        </p>
      <?php endforeach ?>
    <?php endif; ?>
  <?php endforeach ?>
</div>
Greg Thomas

PHP Programmer - interactivetools.com

By CommonSenseDesign - August 20, 2019

Hi, Greg.

I've tried this on a duplicate page, but now there's an error message: http://www.tcmhomes.com/calendar0.php.

There are syntax errors on the highlighted lines of code, but I don't know what the errors are.

<div class="col-md-5">
<?php foreach ($calendarRecords as $record): ?>
<?php if(empty($record['upload])): ?>
<?php echo htmlencode($record['title']) ?>
<?php else: ?>
<?php foreach ($record['upload'] as $index => $upload): ?>
<p>
<?php echo $record['category:label'] ?>:
<a href="<?php echo htmlencode($upload['urlPath']) ?>" target="_blank">
<?php echo htmlencode($record['title']) ?>
</a>
</p>
<?php endforeach ?>
<?php endif; ?>
<?php endforeach ?>
</div>

By gregThomas - August 21, 2019

Hey,

I've reviewed the code, but I can't see anything obviously wrong with the code on those lines. Please, could you find out what the exact errors are that appear and post them for me?

Greg Thomas

PHP Programmer - interactivetools.com

By CommonSenseDesign - August 21, 2019

Hi, Greg.

I've attached a screengrab.

Cheers,

N

Attachments:

calendar0.php 13K

dreamweaver.jpg 111K

By Damon - August 21, 2019

Hi,

On line 161 there is a missing single quote after upload.

Should be like this:

<?php if(empty($record['upload'])): ?>

Let me know if that fixes the error.

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By CommonSenseDesign - August 23, 2019

Hi, Damon. Thank you - I should have spotted that!

The error is gone, and everything seems to be working now as intended.

Thanks so much to you guys for your patience and help.