Advertisement:

Author Topic: grandchildern catergories  (Read 3393 times)

abdul

  • Newbie
  • *
  • Posts: 8
grandchildern catergories
« on: December 07, 2011, 09:07:05 pm »
hi, am using osclass 2.3.1 modern theme.

i know that osclass administrator mentiond few time regarding to this tree gatergory topic and he did mentioned it is doable ,  but he did not give any actual codes and instruction on how to implement these code, so if you can please give the code
and step by step instruction on how to implement  i'd be much appreciated

am planing to have at the most 5 levels of gatergories within gatergoies
i`d like multi level tree category  category 1 sub2 sub3 sub4 e.g.


father category
  mother category
    children catergory
      grandchildern catergory
        and so on

please help me with the code!

i'd be much appreciated if you would specify all the files path!! to the files,so i can
locate with ease and  paste in the code!

i would want my osclass website to be one of the best in oder to do this i would need multi level sub sub gategories
it`s very important to me, as i like to give more options to my users

thank you in advance.
« Last Edit: December 07, 2011, 09:13:57 pm by abdul »

trains58554

  • Osclass contributor
  • Hero Member
  • *****
  • Posts: 3642
  • osCanyon, the class of Osclass
Re: grandchildern catergories
« Reply #1 on: December 07, 2011, 09:16:39 pm »
Hi abdul,

You could take a look at the Hierarchy theme's main.php file to see how I implemented a hierarchy menu to it. You will only be able to go one sub category deep right now as osclass does not yet support sub categories within sub categories that I know of.

Jay

abdul

  • Newbie
  • *
  • Posts: 8
Re: grandchildern catergories
« Reply #2 on: December 07, 2011, 09:30:52 pm »
Hi trains58554, thank you for you reply.

but seeing this furom am asuming administrator knows a way of doing this, see the attachment


thank you.

trains58554

  • Osclass contributor
  • Hero Member
  • *****
  • Posts: 3642
  • osCanyon, the class of Osclass
Re: grandchildern catergories
« Reply #3 on: December 07, 2011, 09:46:07 pm »
Hi abdul,

It can be done. I have had the Hierarchy theme displaying sub sub categories once. The problem is that in the admin section you cannot make a sub category have a sub category. So it would require manual editing of the database which I do not suggest.

Jay

abdul

  • Newbie
  • *
  • Posts: 8
Re: grandchildern catergories
« Reply #4 on: December 08, 2011, 12:44:04 am »
Hi abdul,

It can be done. I have had the Hierarchy theme displaying sub sub categories once. The problem is that in the admin section you cannot make a sub category have a sub category. So it would require manual editing of the database which I do not suggest.

Jay




Hi Jay,

I dont mind not doing it from the admin pannel. I would like to try from the data base coding, as i would have a back-up. Can you give me instructions about which file needs changing and what code needs to be implemented. I have waited a very long time for this multi level catergories. I have a website currently running and i feel as if  i dont have the confidence to promote my website. I believe first impression counts, as  i would not want to lose any users. Once i get this catergory i would want to start promoting my site asap.

I have done a few modification on my osclass website if you would like to see:here is my website: www.classifiedbangla.com

I would very much appriciate if you can give me all the file path to the files, it would help and make it easy for me if you could do that.


Thank you ever so much,

Hope to hear from you soon.

Abdul

_CONEJO

  • Administrator
  • Hero Member
  • *****
  • Posts: 4689
Re: grandchildern catergories
« Reply #5 on: December 09, 2011, 11:33:54 am »
Hi abdul,

It's possible, but you will have no helpers to do this.
Each category is a multi-dimensional array in php and depends on the way you retrieve them it will appear some data or other, but if you get the whole tree, data for a category should be something like


Array
(
    [
0] => Array
        (
            [
pk_i_id] => 10
            
[fk_i_parent_id] => 
            [
i_expiration_days] => 0
            
[i_position] => 0
            
[b_enabled] => 1
            
[s_icon] => 
            [
fk_i_category_id] => 10
            
[fk_c_locale_code] => en_US
            
[s_name] => Cat Ingles
            
[s_description] => 
            [
s_slug] => cat-ingles
            
[i_num_items] => 4709
            
[locale_order] => 1
            
[categories] => Array
                (
                )

        )

    [
1] => Array
        (
            [
pk_i_id] => 6
            
[fk_i_parent_id] => 
            [
i_expiration_days] => 0
            
[i_position] => 1
            
[b_enabled] => 1
            
[s_icon] => 
            [
fk_i_category_id] => 6
            
[fk_c_locale_code] => en_US
            
[s_name] => Caballos
            
[s_description] => 
            [
s_slug] => caballos
            
[i_num_items] => 216
            
[locale_order] => 1
            
[categories] => Array
                (
                    [
0] => Array
                        (
                            [
pk_i_id] => 122
                            
[fk_i_parent_id] => 6
                            
[i_expiration_days] => 0
                            
[i_position] => 0
                            
[b_enabled] => 1
                            
[s_icon] => 
                            [
fk_i_category_id] => 122
                            
[fk_c_locale_code] => en_US
                            
[s_name] => Welsh
                            
[s_description] => 
                            [
s_slug] => welsh
                            
[i_num_items] => 0
                            
[locale_order] => 1
                            
[categories] => Array
                                (
                                )

                        )

                    [
1] => Array
                        (
                            [
pk_i_id] => 121
                            
[fk_i_parent_id] => 6
                            
[i_expiration_days] => 0
                            
[i_position] => 1
                            
[b_enabled] => 1
                            
[s_icon] => 
                            [
fk_i_category_id] => 121
                            
[fk_c_locale_code] => en_US
                            
[s_name] => Shetland
                            
[s_description] => 
                            [
s_slug] => shetland
                            
[i_num_items] => 4
                            
[locale_order] => 1
                            
[categories] => Array
                                (
                                )

                        )



Inside the key "categories", to be able to handle this, you need a bit of PHP and arrays knowledge, since for a 5th-level category name you should do something like

echo $categories[X1]['categories'][X2]['categories'][X3]['categories'][X4]['categories'][X5]['s_name']


Where X1, X2, X3, X4 and X5 are numbers

GazOutEast

  • Newbie
  • *
  • Posts: 13
Re: grandchildern catergories
« Reply #6 on: January 22, 2012, 06:00:49 pm »
Given all the above explanations and examples, I am led to ask ...

If all that is true, then how come WordPress can have unlimited levels of subcategories?
I was of the understanding that osClass is broadly based on the same semantic coding as WordPress.

I still can't help but think that there's something intrinsically wrong in the code logic of osClass if it cannot program loops for unlimited subcats.