How to attached Page/Article to category?

11 posts by 3 authors in: Forums > CMS Builder
Last Post: March 11, 2010   (RSS)

By esteban - January 15, 2010

How to attached Page/Article to category? How to add menu from category list to webpage (display menu on frontend)? I can only know how to add category and add article. I used AM but I'm new in CMS Builder.

Re: [esteban] How to attached Page/Article to category?

By Dave - January 15, 2010

Hi esteban,

Are you trying to re-create Article Manager in CMSB? If so we are hoping to have some sample templates soon to make that easier.

For now, here's how to associate an article and a category.

Under "Section Editors" select "Articles" and add a "list field" called "Category Num" with these options:

List Options: Get options from database (Advanced)
Section Tablename: Categories
Use this field for option values: num
Use this field for option labels: name

Let me know what kind of site you are trying to build and how we can best help!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] How to attached Page/Article to category?

Thanks for help Dave.
I working on CMS builder. I have a lot of question, but CMS Builder this is what I waited for years :-) Do you plan to enlarge sections of CMS builder documentation?

Re: [esteban] How to attached Page/Article to category?

By Dave - February 15, 2010

Hi esteban,

Yes, we do. We have some ideas on putting together a training program that makes it easier to learn CMSB.

But right your best resources are the current documentation and the forum.

Please post if you have any questions.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] How to attached Page/Article to category?

By esteban - March 2, 2010 - edited: March 2, 2010

Ok it's help.

How to show menu from category -> [by code generator = section category + listpage] and Category page have to link to page with 6 records from this category.

How to link from category listing to detail page with full article.

Re: [esteban] How to attached Page/Article to category?

By Chris - March 3, 2010

Hi esteban,

I'm having trouble figuring out exactly what you want. Could you please explain in more detail?

Also, please attach the complete PHP source code for the pages you need help with.
All the best,
Chris

Re: [chris] How to attached Page/Article to category?

By esteban - March 4, 2010

Hi Chris,
I have a section in CMSB: "category" with subcategory and one template for article name "article". I can add article to category or subcategory.

Category:

product1
- product 1.1
- product 1.2

product 2
- product 2.1
- product 2.2

I would like to make:
1. menu on webpage from category - when editor add a category it's show in menu on website and he can add article to this category. Each category-page [listin category page] show article from this category: sort by date.

I would like to link to article from this list to detail page.

I haven't got a code because i don't how to do this.

It's typical navigation frame for website. Website have to include many category and article. Article can be attached to several category - more than one.

Thanks

Re: [esteban] How to attached Page/Article to category?

By Dave - March 8, 2010

Hi esteban,

>I would like to show on product 1 only submenu ... and on product 2 only submenu:

You can show only categories of a certain depth like this:

<?php foreach ($categoriesRecords as $categoryRecord): ?>
<?php if ($categoryRecord['depth'] <= 0) { continue; } // skip categories of depth 0 or lower ?>


Try increasing the 0 to 1 if you want to hide more categories.

There's also few options you can pass to getCategories() to control what it shows or doesn't show:

'rootCategoryNum' => '0',
// Only categories _below_ this one will be shown (defaults to 0 for all)

'categoryFormat' => 'showall',
// controls what to show or hide: showall, onelevel, twolevel, breadcrumb

>How to show this menu horizontal not in list?

The first step is to create an html mockup of what you want the horizontal menu to look like. All that code does is output a bulleted list. So you need to create the html first that shows how you want it to look then adjust the CMSB code to output HTML that matches your mockup.

Note, categories are a fairly new feature and a bit more complicated then the rest of CMSB. We are working on making them simpler, but for now it might take a little extra work to get them working the way you want.

Hope that helps.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] How to attached Page/Article to category?

By esteban - March 8, 2010

Your answer did not help me at all. I do not know php so I do not know where to put the given piece of code. Moreover, in this tutorial is used completely different syntax.

http://www.interactivetools.com/iforum/Products_C2/CMS_Builder_F35/Sub-categories_Tutorial_P77230/

I got stuck with the categories. When I generate code from the code generator the result is -> clickable menu, but it does not display the sub-articles assigned to a category it show all the article in database. What is wrong?


<?php

require_once "/home/trener_osobisty/trener_osobisty/cmsAdmin/lib/viewer_functions.php";

list($main_menuRecords, $main_menuMetaData) = getRecords(array(
'tableName' => 'main_menu',
));

?>


<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->

<?php foreach ($main_menuRecords as $record): ?>
Record Number: <?php echo $record['num'] ?><br/>
Parent Category: <?php echo $record['parentNum'] ?><br/>
Name: <?php echo $record['name'] ?><br/>
Content: <?php echo $record['content'] ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>

<hr/>
<?php endforeach ?>

<?php if (!$main_menuRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->


When I used this method:

http://www.interactivetools.com/iforum/Products_C2/CMS_Builder_F35/Sub-categories_Tutorial_P77230/

It's working on listing page but on detail page for article link is broken, it should be:

/article-list.php?category_num=4
and is
/article.php?category_num=4

Please help.
Esteban