Fork me on GitHub
Current releases are 2.1.1 (2 Aug 2014) and 2.0.18.13 (5 Aug 2014)
Ready for 2.1? Find out if your favorite plugins are compatible.
The 2.0 branch will no longer receive updates after Dec 2014.

SubCategories

This discussion is related to the SubCategories addon.
SubCategories
«1345

Comments

  • I get these errors.

    In the main category view:
    Notice: Undefined index: CategoryID in /home/pushing1/public_html/forum/extensions/SubCategories/default.php on line 46

    In a category with sub-categories:
    Notice: Undefined variable: SessionPostBackKey in /home/pushing1/public_html/forum/extensions/SubCategories/default.php on line 75

    ---

    This is what I was looking for to... Sweet, thanks!
  • Notice: Undefined index: CategoryID in C:\AppServ\www\vanilla-test\extensions\SubCategories\default.php on line 46 This is what i get...
  • Uploaded version 0.1.0b of SubCategories.
  • Thanks for pointing that out. I have set some initialisers for these undefined variables, so they should be gone now.
  • Uploaded version 0.1.0 of SubCategories.
  • I have been checking and altering it all morning, and have finally removed the beta status. So this is the first release of SubCategories. I have added links to parent categories in the title of sub-categories and their associated discussion topics (unfortunately I had to add a database query to achieve this... but it is the only one, so it shouldn't hurt too much).

    I also managed to clear up the last of the dashes that seems to get in the way, though I am quite sure more dashes will appear in inappropriate places (extensions will be the main culprits). I may rethink the way I remove these dashes if it is a major problem for lots of people.

    Please continue to give me your feedback on this first release.

    Thanks,

    Adam.
  • On enabling the extention all categories suddently have 0 posts on the counter. (before ordering the categories in any sub-category order)

    I'm not sure if this a problem or not.
    edit: - parent category says 0 discussions despite subcategory having posts in it. perhaps that needs to change?
    also, how many levels of sub categorys can you have? is this possible :

    Subjects
    -science
    --biology
    -technology
    --gaphics
  • I can replicate this, it is an error derived from a change to the database query which pulls the categories so that sub-categories would not show on the main categories page. I will fix it ASAP and will release 0.1.1.

    As I said in the description. I have no plans at the moment to extend to nesting categories, though I can conceive of a way that it would work quite nicely (though the coding would be complex in the background).

    Cheers,

    Adam.
  • Another little bug. When sub-categories are enabled & I try to edit/view a blog post (using the blog addon) I get the following:

    Fatal error: Cannot redeclare class CategoryManager in /home/.pilar/xxxx/xxxxxxxxxxx.com/forums/library/Vanilla/Vanilla.Class.CategoryManager.php on line 14

    seems to be some sort of a conflict.
  • I can probably fix that little problem too, (but cannot test it, so please test it in the next release).

    Adam.
  • Uploaded version 0.1.1 of SubCategories.
  • Version History:
    • 0.1.0b - First Beta
    • 0.1.0 - First Release: Added parent categories links, finished removal of redundant dashes.
    • 0.1.1 - Fixed one bug with categories beginning with only "-" and showing up as sub-categories in some places and another with category counts. General tidy up. Extrapolated SubCategories definition, and added a message to the Categories List Settings page. Also fixed a conflict with the Blog add-on (checks whether CategoryManager class exists before trying to include it).
    Okay, unless something major comes up, I think I will call it a day, and will look into this again tomorrow. (*angelic venus goes back to working on his Drupal/Vanilla integration extensions*)

    Adam.
  • Yep, seems to be working great. Is it possible however to replace 'Discussions X' on the main category page with perhaps number of subforums? Or remove that from the main page all together? Great job.
  • I may provide the ability to do this by theming in a next release (but I will not force any more theming changes on you guys), you will be able to remove the 'Discussions X' by editing the discussion.php file in your theme folder (and I will provide that variable for number of sub-forums in due course).

    Thanks for your help so far!

    Adam.
  • Thank you. Also just noticed after enabling the extension 'Announcements' stops working. No error is given. I'm not sure if this is just my forum playing up or if it's happening to everyones. Anybody want to confirm?
  • This may be a clash between the way Announcements and SubCategories are placing their content. I will investigate. (though I am not sure how exactly)

    Edit:
    It is just as I suspected... they both add their content at $Configuration["CONTROL_POSITION_BODY_ITEM"]-1, and are pushing each other's content around (it -shouldn't- disappear entirely). Exactly how it displays will probably depend on which extension was enabled first.

    You could change either Announcements or SubCategory's default.php to set $Configuration["CONTROL_POSITION_BODY_ITEM"]-1 to $Configuration["CONTROL_POSITION_BODY_ITEM"]-2 which will raise the one you edit's position above the other (do a search and replace). This is a temporary fix, whilst I work out a more elegant way to fix the problem. (*looks at the "AddRenderControl" method in more detail*)

    Adam.
  • Sweet, works pretty good now. No errors as of yet, but I'll let you know.

    Thanks.
  • Works great except this:

    "parent category says 0 discussions despite subcategory having posts in it. perhaps that needs to change?"

    Thanks.
  • sjeeps, parent categories are completely independent of sub-categories. Personally, that was my intention from the outset, I will think about it. I might make it an option (something about inheriting children categories statistics) but I quite like the idea of each category being independent (whether a sub-category or not) of each other. To me it seems illogical to have this happen:

    Main Category (with 0 posts)

    Another Category (with 20 posts)

    Now if "Another Category" were to be a sub-category of "Main Category" it would be confusing to have in the details on the main list of categories under "Main Category" a label saying that it has 20 discussions... when really it is empty... I think that having a list of sub-forums a parent category contains (or just a number) makes more sense.

    Anyways, just my $0.02.

    I will add the option in a future version, if there is enough interest?

    Adam.
  • Adam, thank you. To me it seems more illogical if it looks like this: Parent Category 20 posts (Total posts in all sub-categories) Sub Category 1 10 posts Sub Category 2 10 posts
  • Nope (I was arguing the opposite case), but I can see how some people would want this. So I will create a variable which supplies the theme with the amount of sub-categories a category has AND a count of all discussions it contains (in it's sub-categories and it's own), too.

    These will be extra variables, for use in themeing, not replacing any default ones.

    Sound like a good idea? =)

    Adam.
  • I agree with sjeeps on this one, but I can also see the other point of view - a toggle would be great. Alternatively, you could have a "Subcats (2) discussions (42)" or whatever the numbers may be?
  • I want to have a sub subcatigory like: (Main) People (sub) State (Sub sub)city/town It is possible to do it with this?
  • pug, as I said above, I have not implemented multiple hierarchies of categories yet. At the moment you can only have sub-categories, not sub-sub-categories (or further). My main priority was to get one level of sub-categories working. I have laid down the framework, it is within the scope of what I have written to alter it to add further hierarchies, but it would be quite an undertaking (it is a more complex notion) so if a programmer is willing to alter my code, then I will happily review their changes and add the functionality. I will think about adding support for it at a later date (I am currently writing a further 3 new extensions for Vanilla). The way I conceive further levels of sub-categories working is this: Main Category (category) (parent) - Sub Main Category (sub category) (child of parent) - - Sub Sub Main Category (sub sub category) (child of a child of the parent) - - - Sub Sub Sub Main Category (sub sub sub category) (child of a child of a child of the parent) - Another Sub Main Category (sub category) (child of parent) Another Main Category (category) [ category name | (category type) | (parent/child relationship) ] As you can see above, it works by adding more dash spaces to the beginning of a categories name. But yes, for the moment, I leave implementing this to someone else (though, given a few weeks, if it hasn't been started, I will do it myself). Adam.
  • Uploaded version 0.1.2 of SubCategories.
  • Version History:
    • 0.1.0b - First Beta
    • 0.1.0 - First Release: Added parent categories links, finished removal of redundant dashes.
    • 0.1.1 - Fixed one bug with categories beginning with only "-" and showing up as sub-categories in some places and another with category counts. General tidy up. Extrapolated SubCategories definition, and added a message to the Categories List Settings page. Also fixed a conflict with the Blog add-on (checks whether CategoryManager class exists before trying to include it).
    • 0.1.2 - Added some functions to ease theming, see readme.txt
    Okay, I couldn't work out how to add variables to the theming layer (would have been too nasty a exercise) if you know of a better way than I have done, don't hesitate to tell me.

    An exert explaining how from the readme:

    ...
    =================================
    THEMING YOUR NEW (SUB-)CATEGORIES
    =================================

    For the moment, the look of your sub-categories cannot be changed without altering the extension's default.php, I will look to rectify this in the future.

    To add the amount of sub-categories a category has to the category list, you need to edit your categories.php theme file, you should add below:

    <li class="CategoryDiscussionCount">
    <span>'.$this->Context->GetDefinition('Discussions').'</span> '.$Category->DiscussionCount.'
    </li>';

    this:

    $CategoryList .= ' <li class="CategoryDiscussionCount">
    <span>'.$this->Context->GetDefinition('SubCategories').'</span> '.SubCategoryCount($Category->CategoryID).'
    </li>';

    If you wish to have the discussion count of the category include all sub-categories discussion counts, you should change the line:

    <span>'.$this->Context->GetDefinition('Discussions').'</span> '.$Category->DiscussionCount.'


    to this:

    <span>'.$this->Context->GetDefinition('Discussions').'</span> '.SubDiscussionCount($Category->CategoryID).'

    This is just an example of how you can change the default Vanilla theme to include updated discussion and sub-category counts.
  • Nice addition AV - wish Mark would enable SoftWrap on this forum though, as that code is a sod to read without wrapping.
  • PS - may want to remove the DS_Store files :P edit - wohoo.. announcement extention works :P edit 2 - I just tried out the theme modification and it works great! Nice one!
  • Sorry about the .DS_Store, I usually remember, was in a rush this time.

    I am currently working on the sub sub sub sub sub ... categories (because I got bored, and thought of a decent way to do it).

    Adam.
«1345
Sign In or Register to comment.