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

Hi, there.

I'm using the following code on a page, and all of the categories show up on the live page, except "TCMH". Any why just one category would be hidden? There are several records that use that category label.

<p><a href="calendar.php">Show All</a></p>
<p><a href="calendar.php?category=TCMH">TCMH</a></p>
<p><a href="calendar.php?category=Aldaview">Aldaview</a></p>
<p><a href="calendar.php?category=Greenwood">Greenwood</a></p>
<p><a href="calendar.php?category=Nithview">Nithview</a></p>

Here's the live page: http://www.tcmhomes.com/calendar.php

Thanks!

Attachments:

category-02.jpg 19K

category-01.jpg 25K

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

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!

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

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>

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

Hi, Greg.

I've attached a screengrab.

Cheers,

N

Attachments:

calendar0.php 13K

dreamweaver.jpg 111K

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/

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.