Re: [Jason] finding last child entry in category menu with 2 levels
Hmm...
I gave that a shot but it didn't work out. Below that code I tried a simple if statement that I've used successfully before just to make sure the foreach loop was working. Then, below that, I used the standard list viewer. The latter two worked for me as expected, but I couldn't the _isLastChild working.
my sql code was:
<?php
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/jocotoco/public_html/','','../','../../','../../../');
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($speciesRecords, $speciesMetaData) = getRecords(array(
'tableName' => 'species',
));
?>
The php in the order described above is below:
<h1>Species - List Page Viewer</h1>
***********************
<br />
<br />
<?php foreach ($speciesRecords as $category): ?>
<?php if ($category['_isLastChild']): ?>
last child
<?php else: ?>
NOT the last child
<?php endif ?>
<?php endforeach?>
<br />
<br />
*******************
<br />
<br />
<br />
<br />
<?php foreach ($speciesRecords as $category): ?>
<?php if ($category['depth'] == 0): ?>
This is 0 depth<br />
<?php else: ?>
NO <br />
<?php endif ?>
<?php endforeach?>
<br />
<br />
*****************************
<br />
<br />
<br />
<br />
<?php foreach ($speciesRecords as $record): ?>
Parent Category: <?php echo $record['parentNum'] ?><br/>
<h2><?php echo $record['name'] ?></h2>
Content: <?php echo $record['content'] ?><br/>
<hr/>
<?php endforeach ?>
I tried tweaking it sundry ways, but no joy.
Oh here's the output I was getting:
http://74.52.72.36/~jocotoco/species_test3.phpIan
p.s. I've attached a screenshot of the section I'm working with. (the "last" entries are only there because I came up with some code that would insert content based on their presence. It's kind of a hack solution, hence the question.)