Details Page no record found

8 posts by 3 authors in: Forums > CMS Builder
Last Post: November 24, 2009   (RSS)

By MRI - November 18, 2009

I have a list page set up and when you click on an item in the list it should then link to the Details Page.

Only one list item is linking correctly, the other give me "No Record Found" message.

Im not sure if it is because on the details page, I have another multiple records list displaying.

HEres the code at the top of my detaisl page:

<?php

require_once "/XXXXXXX";

list($ad_managerRecords, $ad_managerMetaData) = getRecords(array(
'tableName' => 'ad_manager',
'limit' => '2',
'orderBy' => 'RAND()',
'where' => " page_display LIKE '%\tAll\t%' ",
));

?>
<?php

require_once "/XXXXXXX";

list($employment_pageRecords, $employment_pageMetaData) = getRecords(array(
'tableName' => 'employment_page',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$employment_pageRecord = @$employment_pageRecords[0]; // get first record

// show error message if no matching record is found
if (!$employment_pageRecord) {
print "Record not found!";
exit;
}

?>
<?php

require_once "/XXXXXXX";

list($employment_listingsRecords, $employment_listingsMetaData) = getRecords(array(
'tableName' => 'employment_listings',
'limit' => '1',
));
$employment_listingsRecord = @$employment_listingsRecords[0]; // get first record

// show error message if no matching record is found
if (!$employment_listingsRecord) {
print "Record not found!";
exit;
}

?>



The employment_listings is the record that is not displaying..
you can preview at: http://runningaces.mriinteract.net/employment/index.php
The Housekeeping works but not the others.

Also I would like to know if there is a way for the Job Category title not display if there are no records under that category.

I have set up just one multiple record manager in the CMS and when you enter a job listing, you select a category the listing goes under.

For if you look at the link above... I would like "Card Room, Finance etc" not display since there are no records under that category

THANKS IN ADVANCE!

Re: [MRI] Details Page no record found

By gkornbluth - November 18, 2009 - edited: November 18, 2009

Hi MRI,

If I understand you correctly, I'd try removing the: where' => whereRecordNumberInUrl(1), in the employment listings and see if that helps. Sometimes the 'limit' => '1', can give strange results as well.

You might also, add:

allowSearch => false,

so later when you add search engines it won't "filter" those records, since I'm assuming you’ll want to show them all the time.

The issue of not showing particular text can be done using an "if" statement around the HTML entry with a ! (not) before the $ as in the "records not found!", below.

You don't have to repeat the entire block of "require once" code on your page either.

You can use: <?php

require_once "/XXXXXXX";

list($ad_managerRecords, $ad_managerMetaData) = getRecords(array(
'tableName' => 'ad_manager',
'limit' => '2',
'orderBy' => 'RAND()',
'where' => " page_display LIKE '%\tAll\t%' ",
));

list($employment_pageRecords, $employment_pageMetaData) = getRecords(array(
'tableName' => 'employment_page',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$employment_pageRecord = @$employment_pageRecords[0]; // get first record

// show error message if no matching record is found
if (!$employment_pageRecord) {
print "Record not found!";
exit;
}

list($employment_listingsRecords, $employment_listingsMetaData) = getRecords(array(
'tableName' => 'employment_listings',
'limit' => '1',
));
$employment_listingsRecord = @$employment_listingsRecords[0]; // get first record

// show error message if no matching record is found
if (!$employment_listingsRecord) {
print "Record not found!";
exit;
}

?>


If you know that you don't need them, you can remove the: // show error message if no matching record is found
if (!$employment_pageRecord) {
print "Record not found!";
exit;
}
or change "Record not found!" to anything that you prefer.

Hope this sets you in the right direction.

Best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Details Page no record found

By MRI - November 19, 2009

Did not work... still have the same issue..

let focus on the first issue.. then we figure out the second question i had.

ok lets try again..

http://runningaces.mriinteract.net/employment/index.php
This page lists all the job listings.. (page displays fine)

heres the header php code:

<?php

require_once "xxx";

list($ad_managerRecords, $ad_managerMetaData) = getRecords(array(
'tableName' => 'ad_manager',
'limit' => '2',
'orderBy' => 'RAND()',
'where' => " page_display LIKE '%\tAll\t%' ",
));

?>
<?php

require_once "xxx";

list($employment_pageRecords, $employment_pageMetaData) = getRecords(array(
'tableName' => 'employment_page',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$employment_pageRecord = @$employment_pageRecords[0]; // get first record

// show error message if no matching record is found
if (!$employment_pageRecord) {
print "Record not found!";
exit;
}

?>
<?php

require_once "xxx";

list($employment_listingsRecords, $employment_listingsMetaData) = getRecords(array(
'tableName' => 'employment_listings',
));

?>


Then when you click on a job listing... it should take you to the details page:
http://runningaces.mriinteract.net/employment/joblistings.php

this works fine: http://runningaces.mriinteract.net/employment/joblistings.php?HOUSEKEEPER-1

but any other job listing does not... i get the Record not found messages..

HEres the code on the details page:

<?php

require_once "xxx";

list($ad_managerRecords, $ad_managerMetaData) = getRecords(array(
'tableName' => 'ad_manager',
'limit' => '2',
'orderBy' => 'RAND()',
'where' => " page_display LIKE '%\tAll\t%' ",
));

?>
<?php

require_once "xxx";

list($employment_pageRecords, $employment_pageMetaData) = getRecords(array(
'tableName' => 'employment_page',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$employment_pageRecord = @$employment_pageRecords[0]; // get first record

// show error message if no matching record is found
if (!$employment_pageRecord) {
print "Record not found!";
exit;
}

?>
<?php

require_once "xxx";

list($employment_listingsRecords, $employment_listingsMetaData) = getRecords(array(
'tableName' => 'employment_listings',
'limit' => '1',
));
$employment_listingsRecord = @$employment_listingsRecords[0]; // get first record

// show error message if no matching record is found
if (!$employment_listingsRecord) {
print "Record not found!";
exit;
}

?>


can i send you files to review?
I think the conflict has to do with having multiple list records/single record on the same page.

Re: [gkornbluth] Details Page no record found

By MRI - November 19, 2009

I got it....sorry.

Now, just need help with the removing of the header text if there are no records in that section.

Heres how its set up.. http://runningaces.mriinteract.net/employment/

in the CMS I have a Employment listings where you can add new job listings... then you select which category it show show up in.

If there are no job listings in a certain category, I would like that category header to not display.

Heres how the listings are set up:

<h3><strong>CARD ROOM</strong></h3>
<ul>
<?php foreach ($employment_listingsRecords as $record): ?>
<?php if (strpos($record['category'], 'Card Room')): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['job_title'] ?></a></li>
<?php endif ?>
<?php endforeach; ?>
</ul>

<h3><strong>FACILITIES</strong></h3>
<ul>
<?php foreach ($employment_listingsRecords as $record): ?>
<?php if (strpos($record['category'], 'Facilities')): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['job_title'] ?></a></li>
<?php endif ?>
<?php endforeach; ?>
</ul>

<h3><strong>FINANCE</strong></h3>
<ul>
<?php foreach ($employment_listingsRecords as $record): ?>
<?php if (strpos($record['category'], 'Finance')): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['job_title'] ?></a></li>
<?php endif ?>
<?php endforeach; ?>
</ul>

<h3><strong>FOOD &amp; BEVERAGE</strong></h3>
<ul>
<?php foreach ($employment_listingsRecords as $record): ?>
<?php if (strpos($record['category'], 'Food and Beverage')): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['job_title'] ?></a></li>
<?php endif ?>
<?php endforeach; ?>
</ul>

<h3><strong>HUMAN RESOURCES</strong></h3>
<ul>
<?php foreach ($employment_listingsRecords as $record): ?>
<?php if (strpos($record['category'], 'Human Resources')): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['job_title'] ?></a></li>
<?php endif ?>
<?php endforeach; ?>
</ul>

<h3><strong>INFORMATION TECHNOLOGY</strong></h3>
<ul>
<?php foreach ($employment_listingsRecords as $record): ?>
<?php if (strpos($record['category'], 'Information Technology')): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['job_title'] ?></a></li>
<?php endif ?>
<?php endforeach; ?>
</ul>

<h3><strong>MARKETING</strong></h3>
<ul>
<?php foreach ($employment_listingsRecords as $record): ?>
<?php if (strpos($record['category'], 'Marketing')): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['job_title'] ?></a></li>
<?php endif ?>
<?php endforeach; ?>
</ul>

<h3><strong>MUTUELS</strong></h3>
<ul>
<?php foreach ($employment_listingsRecords as $record): ?>
<?php if (strpos($record['category'], 'Mutuels')): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['job_title'] ?></a></li>
<?php endif ?>
<?php endforeach; ?>
</ul>

<h3><strong>RACING</strong></h3>
<ul>
<?php foreach ($employment_listingsRecords as $record): ?>
<?php if (strpos($record['category'], 'Racing')): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['job_title'] ?></a></li>
<?php endif ?>
<?php endforeach; ?>
</ul>

<h3><strong>SECURITY/SURVEILLANCE</strong></h3>
<ul>
<?php foreach ($employment_listingsRecords as $record): ?>
<?php if (strpos($record['category'], 'Security')): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['job_title'] ?></a></li>
<?php endif ?>
<?php endforeach; ?>
</ul>

Re: [MRI] Details Page no record found

By gkornbluth - November 19, 2009

Glad you got it working.

You also seem to understand "if" statements fairly well.

I've got to run out now, but I'm sure you'll get it fixed.

Best,

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [MRI] Details Page no record found

By Chris - November 24, 2009 - edited: November 24, 2009

Hi MRI,

Did you get your conditional header text working?

If not, you could try something like this:

<?php $found = 0; ?>
<?php foreach ($employment_listingsRecords as $record): ?>
<?php if (strpos($record['category'], 'Card Room')): ?>
<?php if (!$found): ?>
<h3><strong>CARD ROOM</strong></h3>
<ul>
<?php $found = 1; ?>
<?php endif ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['job_title'] ?></a></li>
<?php endif ?>
<?php endforeach; ?>
<?php if ($found): ?>
</ul>
<?php endif ?>


Please let us know if you have any questions.
All the best,
Chris

Re: [chris] Details Page no record found

By MRI - November 24, 2009

cool thanks!! I actually rigged it to work using another way which is probably more complicated... but ill give your suggestion a shot and see how it works.