Viewer Search Engines: No records were found!

10 posts by 2 authors in: Forums > CMS Builder
Last Post: April 20, 2011   (RSS)

I'm working on a website for a florist that has plants broken down by categories and subcategories. I've set up a section in CMSB that shows the categories: http://thecoachesloft.com/plants.php. Not all of these have content for the subcategories yet, but Vines (2 subcategories) and Shrubs (1 subcategory) do. If you click on the links on this page, you should see a page that lists the relevant subcategories, but I keep getting the message "No records were found!"; for example: http://thecoachesloft.com/plantsSubcategory.php?title=Vines.

Any idea why this is, please?

======

Display code in plantsSubcategory.php:

<?php foreach ($product_subcategoriesRecords as $record): ?>
<p><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a><br/>
Main Category: <?php echo $record['main_category'] ?><br/>
Light: <?php echo $record['light'] ?><br/>
Plant Care: <?php echo $record['content'] ?><br/>
Facts: <?php echo $record['facts'] ?><br/>

<!-- STEP 2a: Display Uploads for field 'main_image' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
<?php foreach ($record['main_image'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />

<?php elseif ($upload['isImage']): ?>
<?php else: ?>
<?php endif ?>
<?php endforeach ?>
<!-- STEP2a: /Display Uploads -->


<hr/>
<?php endforeach ?>

<?php if (!$product_subcategoriesRecords): ?>
<p>No records were found!</p>
<?php endif ?>
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [NigelGordijk] Viewer Search Engines: No records were found!

By Jason - April 19, 2011

Hi Nigel,

I did some testing on your page and what I found is the issue is with your URL. This URL:
http://thecoachesloft.com/plantsSubcategory.php?title=Vines
Will only search for record where their title = "Vines".

I first changed it to look for records with "vines" in the title like this:
http://thecoachesloft.com/plantsSubcategory.php?title_keyword=Vines

This outputs a single record. It is showing a main_category field to be 10. So this is most likely the record number for Vines in your "categories" section. If you change your URL to this:
http://thecoachesloft.com/plantsSubcategory.php?main_category=10

You get the 2 records you'd expect.

So what you need to do is on plants.php, output your links like this:

<p><a href="plantsSubcategory.php?main_category=<?php echo $record['num'] ?>"><?php echo $record['title'] ?></a></p>

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Viewer Search Engines: No records were found!

Thanks for your help, Jason. That works perfectly!

Is there a way to get the subcategory heading on the subcategory page? No matter which section I'm in it always shows "Annual" at the top: http://thecoachesloft.com/plantsSubcategory.php?main_category=10 and http://thecoachesloft.com/plantsSubcategory.php?main_category=1.
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [NigelGordijk] Viewer Search Engines: No records were found!

By Jason - April 19, 2011

Hi Nigel,

Try this code:

// load records
list($categoriesRecords, $categoriesMetaData) = getRecords(array(
'tableName' => 'categories',
));

$categoriesRecord = @$categoriesRecords[0]; // get first record

$title = "";
foreach ($categoriesRecords as $category) {
if($category['num'] == @$_REQUEST['main_category']) {
$title = $category['title'];
}
}


Then you just need to output title

<TD CLASS="tdLowerHeadlineCell"><H1><?php echo $title; ?></H1></TD>

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Viewer Search Engines: No records were found!

Worked perfectly! Thank you.
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [NigelGordijk] Viewer Search Engines: No records were found!

By Jason - April 20, 2011

Hi Nigel,

What's happening here is because your query for $product_detailsRecords occurs outside your foreach loop, your list is just getting repeated.

Assuming that 'product_details' has a field called 'sub_category' and it's value is the "num" from the 'product_subcategories' section, you could try something like this:

<?php
list($product_detailsRecords, $product_detailsMetaData) = getRecords(array(
'tableName' => 'product_details',
'allowSearch' => false,
'where' => "sub_category = '". intval($record['num'])."'",
));
?>
<ul><?php foreach ($product_detailsRecords as $detailRecord): ?>
<li>
<a href="<?php echo $detailRecord['_link'] ?>"><?php echo $detailRecord['title'] ?></a>
<?php endforeach ?>

<?php if (!$product_detailsRecords): ?>
</li>
<?php endif ?></ul>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Viewer Search Engines: No records were found!

Hi, Jason.

In product_details there is a field called subcategory (no underscore), so the code I've used is as follows:

list($product_detailsRecords, $product_detailsMetaData) = getRecords(array(
'tableName' => 'product_details',
'allowSearch' => false,
'where' => "subcategory = '". intval($record['num'])."'",
));


However, now I'm getting an error message on http://thecoachesloft.com/plantsSubcategory.php?main_category=10:

"Notice: Undefined variable: record in /home/colourp1/public_html/plantsSubcategory.php on line 39"

Line 39 is

'where' => "subcategory = '". intval($record['num'])."'",

Any idea why, please?
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [NigelGordijk] Viewer Search Engines: No records were found!

By Jason - April 20, 2011

Hi Nigel,

You have to make sure that this code is inside the foreach loop for $product_subcategoriesRecords

check that. If you're still getting an error, please re attach your .php file.

thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Viewer Search Engines: No records were found!

Ah, my mistake. I thought the code that loads the table was supposed to go in the head of the document, so I split the code you provided. Everything is working perfectly now. Thanks for your help.

http://thecoachesloft.com/plantsSubcategory.php?main_category=10
http://thecoachesloft.com/categoriesDetails.php?Clematis-2
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net