<?xml version="1.0" encoding="UTF-8"?>    <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
      <channel>
        <title>Two category sections on the same page using getCategories.</title>
        <link>https://interactivetools.com/forum/forum-posts.php?Two-category-sections-on-the-same-page-using-getCategories_-78991</link>
        <description></description>
        <pubDate>Tue, 17 Mar 2026 00:07:10 -0700</pubDate>
        <language>en-us</language>
        <atom:link href="https://interactivetools.com/forum/forum-posts.php?rss=1&amp;Two-category-sections-on-the-same-page-using-getCategories_-78991" rel="self" type="application/rss+xml" />

                <item>
          <title>Two category sections on the same page using getCategories.</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231755#post2231755</link>
          <description><![CDATA[<p>Hi,</p>
<p>If you use selectedCategoryNum, then getCategories will not take 'defaultCategory' into account.  In addition, defaultCategory will only be used if getLastNumberInUrl() doesn't return anything, which in your case it will return 4.</p>

<p>How are you assigning a value to $getRecord?  The best way to accomplish what you're looking for is to set the selectedCategoryNum value to the record you are looking for..  So, if you want the record num of the first top level category, you can do something like this:</p>

<p><code><span style="color:#0000ff;">// get first category num</span><br /><span style="color:#0000ff;">$firstTopLevelCategory = mysql_get($getNav, null, "depth = '0' ORDER BY globalOrder ASC");</span><br /><span style="color:#0000ff;">$firstCategoryNum      = @$firstTopLevelCategory['num'];</span><br /><br />list($categoryRecords, $selectedCategory) = getCategories(array( <br />  'tableName'            =&gt; mysql_escapef(@$getNav), <br />  'defaultCategory'      =&gt; 'first', // Enter 'first', a category number, or leave blank '' for none<br />  'categoryFormat'       =&gt; 'onelevel', // showall, onelevel, twolevel <br />  'ulAttributesCallback' =&gt; 'customMenuUlAttr', // ADVANCED: custom function to return ul attributes, eg: myUlAttr($category);<br />  'liAttributesCallback' =&gt; 'customMenuLiAttr', // ADVANCED: custom function to return li attributes, eg: myLiAttr($category);<br />  'selectedCategoryNum'  =&gt; <span style="color:#0000ff;">mysql_escapef($firstCategoryNum),</span> <br />));</code></p>

<p>Hope this helps</p>]]></description>
          <pubDate>Sat, 14 Sep 2013 14:57:44 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231755#post2231755</guid>
        </item>
                <item>
          <title>Two category sections on the same page using getCategories.</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231750#post2231750</link>
          <description><![CDATA[<p>Hi,</p>
<p>I have a new problem similar to the one above.</p>
<p>On a another site I'm working on we have 4 category sections, but we only display one at a time. I load the pages with this url:</p>
<p><a href="http://www.example.com/index.php?nav=2" rel="nofollow">http://www.example.com/index.php?nav=2</a></p>
<p>And pass the nav value like this:</p>
<p><code>list($categoryRecords, $selectedCategory) = getCategories(array( <br />  'tableName' =&gt; mysql_escapef(@$getNav), <br />  'defaultCategory' =&gt; 'first', // Enter 'first', a category number, or leave blank '' for none<br />  'categoryFormat' =&gt; 'onelevel', // showall, onelevel, twolevel <br />  'ulAttributesCallback' =&gt; 'customMenuUlAttr', // ADVANCED: custom function to return ul attributes, eg: myUlAttr($category);<br />  'liAttributesCallback' =&gt; 'customMenuLiAttr', // ADVANCED: custom function to return li attributes, eg: myLiAttr($category);<br />  'selectedCategoryNum' =&gt; mysql_escapef(@$getRecord), <br /> ));<br /></code></p>
<p>This work fine, the problem is that since this page doesn't have the url variable like id=34 I use to pass to $getRecord, this getCategories call treats my nav=2 as the record number. We don't want this, we would like the category to load with the 'first' cat selected.</p>
<p>To sum this up; how can we load a category with the first category selected, not cat. num=1 but categoryRecords[0] (this can be cat. num=3).</p>
<p>-aev-</p>]]></description>
          <pubDate>Fri, 13 Sep 2013 05:49:37 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231750#post2231750</guid>
        </item>
                <item>
          <title>Two category sections on the same page using getCategories.</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231730#post2231730</link>
          <description><![CDATA[<p>HI,</p>
<p>thanks! <span><strong>'selectedCategoryNum' =&gt; '0',</strong> was the missing piece I needed for getting this to work!</span></p>
<p><span>Here is the code I ended up using:</span></p>
<p><code>if ($getSection == "nav") {<br /><br />  // Menu 1 (selected)<br />  list($categoryRecords, $selectedCategory) = getCategories(array( <br />    'tableName' =&gt; 'nav', <br />    'defaultCategory' =&gt; 'first', // Enter 'first', a category number, or leave blank '' for none<br />    'categoryFormat' =&gt; 'onelevel', // showall, onelevel, twolevel <br />    'ulAttributesCallback' =&gt; 'customMenuUlAttr', // ADVANCED: custom function to return ul attributes, eg: myUlAttr($category);<br />    'liAttributesCallback' =&gt; 'customMenuLiAttr', // ADVANCED: custom function to return li attributes, eg: myLiAttr($category);<br />    'selectedCategoryNum' =&gt; mysql_escapef(@$getRecord), <br />  ));<br /><br />  // Menu 2<br />  list($categoryRecords2) = getCategories(array( <br />    'tableName' =&gt; 'nav2', <br />    'defaultCategory' =&gt; '', // Enter 'first', a category number, or leave blank '' for none<br />    'categoryFormat' =&gt; 'onelevel', // showall, onelevel, twolevel <br />    'ulAttributesCallback' =&gt; 'customMenuUlAttr', // ADVANCED: custom function to return ul attributes, eg: myUlAttr($category);<br />    'liAttributesCallback' =&gt; 'customMenuLiAttr', // ADVANCED: custom function to return li attributes, eg: myLiAttr($category);<br />    'selectedCategoryNum' =&gt; '0'<br />  ));<br /><br />} elseif  ($getSection == "nav2") {<br /><br />  // Menu 1<br />  list($categoryRecords) = getCategories(array( <br />    'tableName' =&gt; 'nav',<br />    'defaultCategory' =&gt; '', // Enter 'first', a category number, or leave blank '' for none<br />    'categoryFormat' =&gt; 'onelevel', // showall, onelevel, twolevel <br />    'ulAttributesCallback' =&gt; 'customMenuUlAttr', // ADVANCED: custom function to return ul attributes, eg: myUlAttr($category);<br />    'liAttributesCallback' =&gt; 'customMenuLiAttr', // ADVANCED: custom function to return li attributes, eg: myLiAttr($category);<br />    'selectedCategoryNum' =&gt; '0' <br />  ));<br /><br />  // Menu 2 (selected)<br />  list($categoryRecords2, $selectedCategory ) = getCategories(array( <br />    'tableName' =&gt; 'nav2', <br />    'defaultCategory' =&gt; 'first', // Enter 'first', a category number, or leave blank '' for none<br />    'categoryFormat' =&gt; 'onelevel', // showall, onelevel, twolevel <br />    'ulAttributesCallback' =&gt; 'customMenuUlAttr', // ADVANCED: custom function to return ul attributes, eg: myUlAttr($category);<br />    'liAttributesCallback' =&gt; 'customMenuLiAttr', // ADVANCED: custom function to return li attributes, eg: myLiAttr($category);<br />    'selectedCategoryNum' =&gt; mysql_escapef(@$getRecord), <br />  ));<br /><br />}<br /></code></p>
<p>-aev-</p>]]></description>
          <pubDate>Mon, 09 Sep 2013 15:13:10 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231730#post2231730</guid>
        </item>
                <item>
          <title>Two category sections on the same page using getCategories.</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231729#post2231729</link>
          <description><![CDATA[<p>Hi,</p>

<p>By default, _isSelected is set by looking at the last number in the URL string.  You can change this by setting the 'selctedCategoryNum' option in your getCategories call.  If you set it like this:</p>
<p>'selectedCategoryNum' =&gt; '0',</p>
<p>then no record in that record set will have _isSelected set, as there will never be a record number 0.  It's important to remember to put the single quotes around the 0, otherwise this solution won't work.</p>

<p>We have two good tutorials in the forum to give you a good start on using getCategories:</p>

<p><a href="http://www.interactivetools.com/forum/forum-posts.php?postNum=2192758#post2192758" rel="nofollow">http://www.interactivetools.com/forum/forum-posts.php?postNum=2192758#post2192758</a></p>
<p><a href="http://www.interactivetools.com/forum/forum-posts.php?postNum=2201307#post2201307" rel="nofollow">http://www.interactivetools.com/forum/forum-posts.php?postNum=2201307#post2201307</a></p>

<p>Please let me know if you have any further questions.</p>

<p>Thanks!</p>]]></description>
          <pubDate>Mon, 09 Sep 2013 14:09:46 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231729#post2231729</guid>
        </item>
                <item>
          <title>Two category sections on the same page using getCategories.</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231728#post2231728</link>
          <description><![CDATA[<p>Hi,</p>
<p>when a $categoryRecords record is loaded I also get a "[_isSelected] =&gt; 1" on the record with the same record-num in $categoryRecords2 even if I load $categoryRecords2 with "categoryFormat =&gt; onelevel" and no "selectedCategoryNum" set.</p>
<p>As you suggest I could workaround this by changing my code for displaying $categoryRecords2, but I would rather know if I can adjust getCategories and keep the same code for displaying my categories.</p>
<p>Is there any documentation explaining all the details for using getCategories?</p>
<p>-aev-</p>]]></description>
          <pubDate>Mon, 09 Sep 2013 13:33:03 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231728#post2231728</guid>
        </item>
                <item>
          <title>Two category sections on the same page using getCategories.</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231720#post2231720</link>
          <description><![CDATA[<p>Hi,</p>
<p>How does the second record set ($categoryRecords2) show as "selected"?  Is this a function of your callback functions, customMenuUlAttr, and customMenuLiAttr?  If so, you can update those functions to look at the _tableName attribute of each record so that you don't style records from nav2 the same way.</p>
<p>Also, if you want to only show top level categories, you can look at the depth, field.  top level categories will have a depth of 0, so you can filter them like this:</p>
<p><code>&lt;?php foreach ($categoryRecords2 as $category): ?&gt;<br />  &lt;?php if ($category['depth'] != 0) { continue; } ?&gt;</code></p>
<p>Hope this helps,</p>]]></description>
          <pubDate>Mon, 09 Sep 2013 10:59:42 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231720#post2231720</guid>
        </item>
                <item>
          <title>Two category sections on the same page using getCategories.</title>
          <link>https://interactivetools.com/forum/forum-posts.php?postNum=2231715#post2231715</link>
          <description><![CDATA[<p>Hi,</p>
<p>I'm trying to use two category sections on the same page, making the active one display as "onelevel" and the other to only list it's top-level.</p>
<p>Here is my code so far:</p>
<p><code>if ($getSection == "nav") {<br /><br />  // nav1<br />  list($categoryRecords, $selectedCategory) = getCategories(array( <br />  'tableName' =&gt; 'nav', <br />  'defaultCategory' =&gt; 'first', // Enter 'first', a category number, or leave blank '' for none<br />  'categoryFormat' =&gt; 'onelevel', // showall, onelevel, twolevel <br />  'ulAttributesCallback' =&gt; 'customMenuUlAttr', // ADVANCED: custom function to return ul attributes, eg: myUlAttr($category);<br />  'liAttributesCallback' =&gt; 'customMenuLiAttr', // ADVANCED: custom function to return li attributes, eg: myLiAttr($category);<br />  'selectedCategoryNum' =&gt; mysql_escapef(@$getRecord), <br />  ));<br /><br />  // nav2<br />  list($categoryRecords2) = getCategories(array( <br />  'tableName' =&gt; 'nav2', <br />  'defaultCategory' =&gt; '', // Enter 'first', a category number, or leave blank '' for none<br />  'categoryFormat' =&gt; 'onelevel', // showall, onelevel, twolevel <br />  'ulAttributesCallback' =&gt; 'customMenuUlAttr', // ADVANCED: custom function to return ul attributes, eg: myUlAttr($category);<br />  'liAttributesCallback' =&gt; 'customMenuLiAttr', // ADVANCED: custom function to return li attributes, eg: myLiAttr($category);<br />  ));<br /><br />} else {<br /><br />  ..the same as above but swap 'nav' and 'nav2'<br /><br />}</code></p>

<p>The problem is that the second category menu get's selected in the same way as the primary, showing like a selected 'onelevel' menu. Any suggestions?</p>

<p>-aev-</p>
]]></description>
          <pubDate>Mon, 09 Sep 2013 07:04:48 -0700</pubDate>
          <guid isPermaLink="true">forum-posts.php?postNum=2231715#post2231715</guid>
        </item>
              </channel>
    </rss>
  