Subcategory list

14 posts by 2 authors in: Forums > CMS Builder
Last Post: December 19, 2012   (RSS)

By Jesus - November 28, 2012

Hello,

Right now I'm displaying on my right column the latest 10 articles on my category page and that's perfect. here's the code I'm using:

<?php
list($articleRecords, $articleMetaData) = getRecords(array(
'tableName' => 'accesando',
'allowSearch' => false,
'limit' => 10,
'orderBy' => "createdDate DESC"
));
?>


Now... I'm thinking to include some sub-categories and now, I'll try to display the subcategories on my main category page in place of the latest articles I'm currently showing.

I already know how to create those subcategories (based on this post:http://www.interactivetools.com/iforum/Products_C2/CMS_Builder_F35/gforum.cgi?post=94165;search_string=subcategories;t=search_engine#94165

So, any help in order to display just the subcategories links on my right side column (as a list too)?

Thanks in advance!

Re: [Jesus] Subcategory list

By Jason - November 28, 2012

Hi,

No problem. Do you have all of your categories/subcategories set up in a category section? Do you want to get the subcategories of the category of your top article, or all 10 articles? Finally, how are categories being stored in your article section?

Let me know and we should be able to point you in the right direction.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Subcategory list

By Jesus - November 28, 2012

Hi Jason thanks for your asnwer.

I created a subcategory list field on my category section so I can select which sub-category I choose for each article.

Please see the attached file.

Jesus
Attachments:

list.png 43K

Re: [Jesus] Subcategory list

By Jesus - November 28, 2012

mmm.... but I'm thinking that having the subcategories this way will not give me a chance to create the proper path for each subcategory.

Example...

Main category: Accesando
Subcategory A: Social Networking
Subcategory B: SEO

I want my paths to be:
/accesando/
/accesando/social-networking/
/accesando/seo/

Then... on my accesando index page... I want to display on my right column, all subcategories like this:

Accesando
Social Networking
SEO

Then, on each of my subcategories index pages, I want to display my latest 10 articles on my right column (ONLY IF not nested categories are be found, this will be my case.)

Thanks for your help and clarification.

Jesus

Re: [Jesus] Subcategory list

By Jesus - December 11, 2012

Hi Jason,

Thanks for your answer.

What I'm thinking here its to create each subcategory like I do with my regular categories in order to have the proper path defined (as I showed previously on the post), then use a hard code link on my template (I'll use this way because I'll not have or create as many subcategories so often, so I can do it when I need it) but....

I'll like to know if its possible to have on my main category page, the latest 5 headlines for each subcategory inside this main category.

Example:

Accesando (index page - main category), will need to show:

The latest 5 headines for:
Subcategory A: Social Networking
Subcategory B: SEO
and so on...

Will you give me a hand how can I create different headlines (one per subcategory) on a single php page?

Thanks

Re: [Jesus] Subcategory list

By Jason - December 11, 2012

Hi,

Yes, you can do this, but exactly how depends on how your categories, subcategories, and articles are all related. Can you give me some more information on how this is stored in the CMS?

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jesus] Subcategory list

By Jesus - December 12, 2012

Hi Jason thanks for your answer.

Ok, here's how I've this thing.

I created a table per category/subcategory and on my Editor Section, I defined the proper path for each category/subcategory.

I've my templates, using just one category to be displayed using this code at the very top.

<?php
list($articleRecords, $articleMetaData) = getRecords(array(
'tableName' => 'accesando',
'allowSearch' => false,
'limit' => 10,
'orderBy' => "createdDate DESC"
));
?>

Obviously the tableName value changes when I'm working with a specific category/template.

Now, with my idea for some of my index pages (like the one I'm trying to create with this example). I want to have the latest headlines <link>, date per subcategory inside this main category.

Main category: Accesando
Subcategory A: Social Networking
Subcategory B: SEO

But I don't know if I need to include on the code I showed previously here located at the top of my page all tables or more tables and then displayed the headlines below... so I'm just confused on how can I do this.

Thanks for the clarification and pointing me to the right direction.

Jesus

Re: [Jesus] Subcategory list

By Jason - December 12, 2012

Hi Jesus,

Okay, I see. If each category and subcategory is stored in a separate section, you would need to do a separate getRecords call for each. For example, if you wanted to retrieve records from accesando, social_networking, and seo, you could do that like this:

<?php

list($articleRecords, $articleMetaData) = getRecords(array(
'tableName' => 'accesando',
'allowSearch' => false,
'limit' => 10,
'orderBy' => "createdDate DESC"
));

// get Social Networking Headlines
list($socialNetworkingRecords, $socialNetworkingMetaData) = getRecords(array(
'tableName' => 'social_networking',
'allowSearch' => false,
'limit' => 5,
'orderBy' => "createdDate DESC"
));

// get SEO Headlines
list($seoRecords, $seoMetaData) = getRecords(array(
'tableName' => 'seo',
'allowSearch' => false,
'limit' => 5,
'orderBy' => "createdDate DESC"
));

?>


This will get the 10 newest records from accesando and the latest 5 from social_networking and seo.

Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jesus] Subcategory list

By Jesus - December 12, 2012

Awesome!, let me try it!

Thanks!