<?xml version="1.0" encoding="UTF-8"?>    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
        <title>finding last child entry in category menu with 2 levels</title>
        <link>https://interactivetools.com/forum/forum-posts.php?finding-last-child-entry-in-category-menu-with-2-levels-72847</link>
        <description></description>
        <pubDate>Wed, 11 Nov 2026 14:53:57 -0700</pubDate>
        <language>en-us</language>
        <atom:link href="https://interactivetools.com/forum/forum-posts.php?rss=1&amp;finding-last-child-entry-in-category-menu-with-2-levels-72847" rel="self" type="application/rss+xml" />

                <item>
          <title>Re: [Jason] finding last child entry in category menu with 2 levels</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2212727#post2212727</link>
          <description><![CDATA[Ah!  I'm sure that will come in handy in the future.<br /><br />Works perfectly.  Thanks, Jason!<br /><br />Ian<br />]]></description>
          <pubDate>Mon, 15 Aug 2011 18:21:15 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2212727#post2212727</guid>
        </item>
                <item>
          <title>Re: [buttermilk] finding last child entry in category menu with 2 levels</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2212726#post2212726</link>
          <description><![CDATA[Hi,<br /><br />_isLastChild is a pseudo field that get's created when you use getCategories.<br /><br />Try this change:<br /><br /><code>// load records <br />  list($speciesRecords, $speciesMetaData) = <span style="color:red">getCategories(array( </span><br />    'tableName'   =&gt; 'species', <br />  ));</code><br /><br />Hope this helps<br />]]></description>
          <pubDate>Mon, 15 Aug 2011 18:11:11 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2212726#post2212726</guid>
        </item>
                <item>
          <title>Re: [Jason] finding last child entry in category menu with 2 levels</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2212725#post2212725</link>
          <description><![CDATA[Hmm...<br /><br />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.<br /><br />my sql code was: <br /><br /><code>&lt;?php<br />  <br /><br />  // load viewer library<br />  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';<br />  $dirsToCheck = array('/home/jocotoco/public_html/','','../','../../','../../../');<br />  foreach ($dirsToCheck as $dir) { if (@include_once(&quot;$dir$libraryPath&quot;)) { break; }}<br />  if (!function_exists('getRecords')) { die(&quot;Couldn't load viewer library, check filepath in sourcecode.&quot;); }<br /><br />  // load records<br />  list($speciesRecords, $speciesMetaData) = getRecords(array(<br />    'tableName'   =&gt; 'species',<br />  ));<br /><br />?&gt;</code><br /><br />The php in the order described above is below:<br /><br /><code>&lt;h1&gt;Species - List Page Viewer&lt;/h1&gt;<br />***********************<br />&lt;br /&gt;<br />&lt;br /&gt;<br /><br />   <br />&lt;?php foreach ($speciesRecords as $category): ?&gt; <br />  &lt;?php if ($category['_isLastChild']): ?&gt; <br />        last child <br />  &lt;?php else: ?&gt; <br />        NOT the last child <br />  &lt;?php endif ?&gt; <br />&lt;?php endforeach?&gt; <br />   <br />&lt;br /&gt;<br />&lt;br /&gt;<br />*******************<br />&lt;br /&gt;<br />&lt;br /&gt;<br /><br /><br /><br />&lt;br /&gt;<br />&lt;br /&gt;<br /><br />	<br />&lt;?php foreach ($speciesRecords as $category): ?&gt; <br />  &lt;?php if ($category['depth'] == 0): ?&gt;<br />        This is 0 depth&lt;br /&gt;<br /><br />  &lt;?php else: ?&gt; <br />       	NO &lt;br /&gt;<br /><br />  &lt;?php endif ?&gt; <br />&lt;?php endforeach?&gt;	<br />&lt;br /&gt;<br />&lt;br /&gt;<br /><br />*****************************<br />&lt;br /&gt;<br />&lt;br /&gt;<br /><br /><br /><br /><br />&lt;br /&gt;<br />&lt;br /&gt;<br /><br /><br /><br /><br /><br /><br />    &lt;?php foreach ($speciesRecords as $record): ?&gt;<br /><br />      Parent Category: &lt;?php echo $record['parentNum'] ?&gt;&lt;br/&gt;<br />      &lt;h2&gt;&lt;?php echo $record['name'] ?&gt;&lt;/h2&gt;<br />      Content: &lt;?php echo $record['content'] ?&gt;&lt;br/&gt;<br /><br />      &lt;hr/&gt;<br />    &lt;?php endforeach ?&gt;</code><br /><br />I tried tweaking it sundry ways, but no joy.<br /><br />Oh here's the output I was getting: <br /><a target="_blank" href="http://74.52.72.36/~jocotoco/species_test3.php">http://74.52.72.36/~jocotoco/species_test3.php</a><br /><br />Ian<br /><br />p.s. I've attached a screenshot of the section I'm working with.  (the &quot;last&quot; 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.)<br />]]></description>
          <pubDate>Mon, 15 Aug 2011 17:18:01 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2212725#post2212725</guid>
        </item>
                <item>
          <title>Re: [buttermilk] finding last child entry in category menu with 2 levels</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2212714#post2212714</link>
          <description><![CDATA[Hi Ian,<br /><br />You can use the _isLastChild field to determine this. So for example:<br /><br /><code>&lt;?php foreach ($categoryRecords as $category): ?&gt;<br />  &lt;?php if ($category['_isLastChild']): ?&gt;<br />        //output when the current record is the last child<br />  &lt;?php else: ?&gt;<br />      // output when the current record is not the last child<br />  &lt;?php endif ?&gt;<br />&lt;?php enforeach?&gt;</code><br /><br /><br />Hope this helps get you started.<br />]]></description>
          <pubDate>Mon, 15 Aug 2011 13:00:08 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2212714#post2212714</guid>
        </item>
                <item>
          <title>finding last child entry in category menu with 2 levels</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2212704#post2212704</link>
          <description><![CDATA[Hi All,<br /><br />I was wondering if anybody knows how to get php to find out if an entry in a foreach loop is the last child of the parent entry.  So, if I had 3 level 0 entries and each had 4 or 5 child entries (depth 1), how could I vary the output for the final entry in each main record?<br /><br />I imagine an &quot;if&quot; statement would work here, but I'm not really sure how to structure it.<br /><br />Any help is appreciated!<br /><br />Ian<br />]]></description>
          <pubDate>Sat, 13 Aug 2011 11:36:00 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2212704#post2212704</guid>
        </item>
              </channel>
    </rss>
  