Displaying single record

5 posts by 2 authors in: Forums > CMS Builder
Last Post: October 22, 2010   (RSS)

Hi there!

I am having a serious problem with show details of a single record from a category I have set up...

So here it is:
Main category: HOME PAGE
Sub Categories: Welcome , Featured Video

How can I display just a single record? Let's say I would like to display just the "featured video". I have managed to display them (Welcome and Featured Video) at random but for some reason when i try to add the "Where" clause, it all goes bazookas! :-S

HEEELP!

Re: [mrmzalewski] Displaying single record

By Jason - October 22, 2010

Hi,

If you could attach the code from the .php file you're working with, I can take a closer look. If you could also provide a link to that page where it does AND doesn't work, that would be helpful.

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] Displaying single record

Hmmm... What I am trying to do is to display just one record, in this case "Featured Video", but it only shows the "Welcome" entry... If I however set to show the record at random they do mix... this is the code (viewer type: detailed page, which record: load record number..., record sorting: default):

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/homepages/45/d281998588/htdocs/casaroccapiccola/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($home_pageRecords, $home_pageMetaData) = getRecords(array(
'tableName' => 'home_page',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$home_pageRecord = @$home_pageRecords[0]; // get first record

// show error message if no matching record is found
if (!$home_pageRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
body { font-family: arial; }
.instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
</style>
</head>
<body>

<!-- INSTRUCTIONS -->
<div class="instructions">
<b>Sample Detail Page Viewer - Instructions:</b>
<ol>
<?php ?>
<li><b>Remove any fields you don't want displayed.</b></li>
<li>Rearrange remaining fields to suit your needs.</li>
<li>Copy and paste code into previously designed page (or add design to this page).</li>
</ol>
</div>
<!-- /INSTRUCTIONS -->

<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->
<h1>Home Page - Detail Page Viewer</h1>
Record Number: <?php echo $home_pageRecord['num'] ?><br/>
Parent Category: <?php echo $home_pageRecord['parentNum'] ?><br/>
Name: <?php echo $home_pageRecord['name'] ?><br/>
Content: <?php echo $home_pageRecord['content'] ?><br/>
_link : <a href="<?php echo $home_pageRecord['_link'] ?>"><?php echo $home_pageRecord['_link'] ?></a><br/>

<hr/>
<?php if (!$home_pageRecord): ?>
No record found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->

<a href="<?php echo $home_pageMetaData['_listPage']; ?>">&lt;&lt; Back to list page</a> -
<a href="mailto:?subject=<?php echo thisPageUrl() ?>">Email this Page</a>
</body>
</html>


So how can i set the second record which i have in my Home_Page category as static? Mind- i have another one with 12 entries! hahahaha...



THANKS!
M

Re: [Jason] Displaying single record

excellent! you are a life saviour! works great, thanks! now please help with my Image upload problem, ahahah! :-)



thanks
m