Multi-level Category Functions

63 posts by 17 authors in: Forums > CMS Builder
Last Post: December 19, 2011   (RSS)

By aev - December 10, 2008


Yes, that would be great!

-aev-

Re: [aev] Multi-level Category Functions

By esupport - January 7, 2009

hi Dave

I would like to creat my category with CSS and Table like below:
> Product 1
--------------------------------------
>Product 1-1
>Product 1-2
--------------------------------------
> Product 2

but now my Category in each table and have blank line like here:
> Product1
-----------------------------------
<----blank line
> Product1-1
-----------------------------------
<----blank line
> Product1-2
-----------------------------------
> Product 2


Here is my code below:

<?php foreach ($categoryRecords as $categoryRecord): ?>
<?php echo str_repeat("&nbsp; &nbsp; &nbsp;", $categoryRecord['depth']); ?>
<?php if ($categoryRecord['_isSelected']): ?>
<span class="sidebar">
<?php endif; ?>
</span>
<table border="0" cellpadding="5" cellspacing="2">
<tr>
<td class="sidebar" onmouseover="this.style.backgroundColor='#D0D7E1';" onmouseout="this.style.backgroundColor='';" valign="top"><!-- /category menu --><a href="<?php echo $categoryRecord['_link'] ?>" class="sidebar"><?php echo $categoryRecord['name'] ?></a></td>
</tr>
<tr>
<td class="sidebar" onmouseover="this.style.backgroundColor='#D0D7E1';" onmouseout="this.style.backgroundColor='';" valign="top"><img src="images/blue-page/sidebar-line.gif" width="140" height="1" /></td>
</tr>
</table>
<?php if ($categoryRecord['_isSelected']): ?>
<?php endif; ?>
<?php endforeach; ?>

Do you know how to solve the problem?

How you can help me.
Thanks a lot!!

-JH
-Jax H.

Re: [JH] Multi-level Category Functions

By Dave - January 7, 2009

Hi JH,

It's hard to tell from the code alone. Are you able to post an url to the page in question?

Generally, the first step is to create an html mockup that shows the category menu how you want it. It's much easier to debug html in an html only file.

Once that is working we can compare the code from the html mockup and the CMS generated code and see what we need to change.

If you can post urls to both that would be very helpful.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Multi-level Category Functions

By aev - January 14, 2009

Hi Dave,

can we limit the depth for a category section, like we can in AM?

With most designs we need to limit how many levels our clients can create.

-aev-

Re: [aev] Multi-level Category Functions

By Dave - January 14, 2009

No, unfortunately there's currently no way to limit the depth.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Multi-level Category Functions

By aev - January 15, 2009

Could you please add that to your CMSB feature request list.. [:)]

We recently started using these menus and would very much like to limit their depth.

-aev-

Re: [aev] Multi-level Category Functions

By Dave - January 15, 2009

Sure, added. Hopefully in the next few versions.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Multi-level Category Functions

By aev - January 19, 2009

Hi!

According to the opening post in this thread, we are using this code to load a category section:

list($categoryRecords, $selectedCategory) = getCategories(array(
'tableName' => 'category',
'selectedCategoryNum' => '', // defaults to getNumberFromEndOfUrl()
'categoryFormat' => 'showall', // showall, onelevel, twolevel
));


The problem with this code is that it doesn't put anything inside $selectedCategory if there is no "number at end of URL". We would like $selectedCategory to be the first record in the $categoryRecords array when there is no number in the URL.

How can we do that?

Isn't $selectedCategory more like a "selectedRecord"?

We would really appreciate more documentation on how to configure Category section, like we have for other type of sections here:
http://www.interactivetools.com/docs/cmsbuilder/viewer_options.html

-aev-

Re: [aev] Multi-level Category Functions

By Dave - January 19, 2009

Hi Aev,

Try this quick fix. Add this code above the code you posted:

$selectedCategoryNum = getNumberFromEndOfUrl();
if (!$selectedCategoryNum) { $selectedCategoryNum = 1; }

// set the number to the default category num you want selected.

Then change the option to this:

'selectedCategoryNum' => $selectedCategoryNum,

Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Multi-level Category Functions

By aev - January 20, 2009

Hi Dave,

I'm sorry but this wasn't quite what I wanted to solve.

We already used this similar code, that did the same thing:
if (!getNumberFromEndOfUrl()) {
$catNum = 1;
} else {
$catNum = getNumberFromEndOfUrl();
}

The problem with this solution is that it uses a certain category number, like 1, as the default page when there is no number in the URL. We want to display whatever page our client put at the top in his category section, and that isn't necessary cat no. 1.

It's like we want to display $categoryRecords[0], but I don't know how to do that inside the list( getCategories()); function.

How can we do that?

-aev-