Fork me on GitHub
Current releases are 2.1 (gold) and 2.0.18.11 (security patch for 2.0)
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

135

Comments

  • Okay, this release should provide fixes for the above.
  • Before I start, just like to let everyone know my first experience with Vanilla was a hot 30 minutes ago, so as far as newbies go, I'm the perfect definition. My questions: 1. Anyway to get an aggregate of the 30 latest discussions within child categories and display them on the parent category page? 2. How do you reference the parent category when building the headline for child category pages? In other words, how do you generate "Parent > Child : Entry"? Finally, this is outside the scope of this plugin but does involve it: 3. If I wanted to limit the drop down list of available categories to child categories only when creating a discussion within the parent / child category, which theme files should I look to modify? Other than that, this plugin is brilliant, I love the "- " for sub categories.
  • Hello cowboystyle, welcome. To your questions...

    1. This currently isn't possible. It would be doable, but would be quite a mission due to the complexity of having unlimited levels of attachment (if that makes sense). Perhaps someone might like to undertake this as an extension with a requirement of the SubCategories extension?

    2. Due to the nature of how Vanilla allows extensions to interact with the core (you are quite removed, and can only dip in at designated points to alter things) I had to do this by forceably altering the titles before they got rendered in the theme (it was best for compatibility). As such, it is quite difficult to alter how this works (you would need to modify my extension). Though, in the future, I would consider changing how this functions if more pragmatic suggestions are made.

    3. I am not sure if this is doable through theming. You would need to use an extension to overload the GetDiscussionForm function in the DiscussionForm class, it wouldn't be pretty.

    I think I can see what you want to get out of the SubCategories extension. It is doable, but not very easily... it might take creating an extension purely tailored to your requirement. One extension that might help that I am working on an update for at the moment, is MultiRoles - which I hope to provide the ability to make categories read only. That way you would be able to control where people post to through permissions.

    Hmm, I am being a bit incoherent, I apologise.

    Adam.
  • @angelic_venus: Thanks for the pointers and prompt response, I completely understood everything you said. 1. I could definitely see this as a plugin, something like SubCategoryAggregate, I'll take a look at how the discussions.php does it's magic and maybe come up with something. 2. I only ask, because on the discussions page I'd like to present a complete category trace , as I have sub categories with the same name. 3. The limit on child categories would be for presentation purposes only, I don't require a strict enforcement, I'll take a look behind the scenes and see whats up.
  • This might be a bug, but it looks like Sub-Categories aren't viewable on the parent category page until you manually move the the child under the parent on the category creation page.
  • Yes, I would quite like to attach categories at the very top of the list, but due to the way that I remove sub categories from the main list (using a reg exp that looks for categories with a lack of "- " at the beginning of category names) it would be quite difficult. I think them not being displayed unless you attach them to a parent (by reordering them to be below a main category) reinforces how the system works anyways.

    Adam.
  • Adam: Just finished the alpha version of an XML RPC interface for some common functions for Vanilla, one of the functions being Category Creation. I can't get it to work with SubCategories (that is categories added with "- " don't register as sub categories) and I'm not quite sure where to begin for adding subcategories. Any advice?
  • Sent it out, thanks for the prompt reply whoops, whispered, ignore
  • Uploaded version 0.2.2 of SubCategories.
  • Version number changed from 0.2.2 to 0.2.3.
  • SubCategories does not detect child categories with same name like so: Dakota - North - South Carolina - North - South Carolina's children will never show up, so I came up with a quick fix which passes around the Category object instead of just relying on the name. Quick fix to detect SubCategories with same names: In "default.php": ln160 : function IsSubCategory($Category, $CurrentName = '', $Zealous = false) { ln165 : $Level = CategoryLevel($Category->Name); ln172 : $Parent = GetParent($Category->CategoryID, $Category->Name, $Level); ln326 : if(IsSubCategory($DiscussionGrid->Category)) { In "sub-categories.php": ln41 : if(IsSubCategory($Category, $CurrentName)) {
  • I think I may have found another bug. If you use the symbol ' & ' as in a category name the category doesnt show up. You end up having to write AND instead.
  • Okay, I will look in to these =), cheers guys.

    Adam.
  • Whoops, note on my quick fix, throws an error when using strict error detection, use this instead: ln137 : function CategoryLevel($CategoryName = '') { ln165 : $Level = CategoryLevel(@$Category->Name);
  • Would it be possible to list the sub-categories on the main Category tab/page? I would like to have them displayed, as clicking into the categories first, then seeing the subtopics does not let you quickly peruse all available topics at a glance. To clarify, what I am asking if it is possible to have the Main Category page display in nested format all of the Categories, sub-cat topics. Thanks!!
  • Currently not Democritus, because of the way I forcefully remove the categories on the main categories page. I have paused work on SubCats for the moment so that I can finish off some other stuff to be able to get my forum live. I will perhaps look in to your suggestion at a later day.

    As for the bug fixes, I should have some time to work on them soon.

    Adam.
  • Hey, thanks for quick reply. Completely understood. Will wait or find someone within my discussion group to hack at it. Demo-
  • I'm sorry to call the emperor naked but apart from making things disappear in the categories page how is this different from just creating normal categories (albeit with a dash in front of their name)? The children seem not to inherit any of their parents access privileges and people can post in the parent just like a normal category. sorry if I'm missing the point here
  • This is not about inheriting permissions, it is a stylistic change and only a stylistic change, it is designed to be a simplistic solution to SubCategories within Vanilla.

    Adam.
  • Another bug: script seems to hate the following character:

    '
  • Anyone got a url of this in action please? Would love to see it working.
  • 3. If I wanted to limit the drop down list of available categories to child categories only when creating a discussion within the parent / child category, which theme files should I look to modify? This would be a good addition to the plugin. Adam will you have time soon to continue to work on this much needed plugin...?
  • this does nto really work for me any ideas why?
  • tata said:If I wanted to limit the drop down list of available categories to child categories only when creating a discussion within the parent / child category, which theme files should I look to modify?
    Neither this extension nor Vanilla itself is really set up for this. As was stated earlier in this discussion, the SubCategories extension is really just stylistic, not structural. You would need to write a new extension to implement this effect.
    Hamed said:this does not really work for me
    any ideas why?
    Uhh... what's wrong? Did you install the theme files into the proper folder(s)? Did you add "(dash)(space)" to the front of your sub category name?

    It works perfect for me in v1.1.3 (except for the small bug Vaz mentions).
  • Someone whispered me about my solution to this, but I thought maybe it was useful enough to post here too.

    I wanted to, instead of just showing a count of Sub Categories under the parent category, actually list out all the subcategories with links.

    My solution is below, although it should probably be generalized a bit more. Maybe it could be added to a future version of the extension?

    ------------------------------------------------------------------

    In default.php under Subcategories I added this function (right under the line that reads "// Theme functions"...around 199)


    function SubCatList ($CategoryID,
    $list_prefix="<div>",
    $list_suffix="</div>\n",
    $sub_cat_item_prefix="",
    $sub_cat_item_suffix="",
    $sub_cat_item_separator=", ")
    {
    global $Context;

    $CategoryManager = $Context->ObjectFactory->NewContextObject($Context, 'CategoryManager');
    $Data = $CategoryManager->GetCategories(1);

    $Category = $Context->ObjectFactory->NewObject($Context, 'Category');
    $BeginSubForums = 0;
    $SubForums = 0;
    $CurrentName = '';
    $return_list = '';

    $Count = 0;

    $Level = false;

    while ($Row = $Context->Database->GetRow($Data))
    {
    $Category->Clear();
    $Category->GetPropertiesFromDataSet($Row);
    $Category->FormatPropertiesForDisplay();

    if ($Category->CategoryID == $CategoryID)
    {
    $BeginSubForums = 1;
    $CurrentName = $Category->Name;
    $Level = CategoryLevel($CurrentName);
    $return_list = $list_prefix;

    }

    if($BeginSubForums == 1)
    {

    if($Category->Name != $CurrentName)
    {
    if(CategoryLevel($Category->Name) <= $Level)
    {
    $return_list .= $list_suffix;
    break;
    }

    if ($Count > 0)
    $return_list .= $sub_cat_item_separator;

    $return_list .= $sub_cat_item_prefix .
    '<a href="' .
    GetUrl($Context->Configuration, 'index.php', '',
    'CategoryID', $Category->CategoryID) .
    '">'.
    SubNameTidy($Category->Name) .'</a>' .
    $sub_cat_item_suffix;

    $Count++;
    }
    }

    }

    return $return_list;

    }




    Then in theme/subcategories.php were it's calling SubCount($Category->CategoryID, 'categories'), instead call SubCatList ($CategoryID)

    That'll more or less do it.
  • @timfire theme files? i was supposed to upload files to the theme in adition to the extension folder?
  • Hamed: Yes, there should be a "sub-categories.php" included with the add-on that needs to be uploaded to the appropriate theme folder(s). Certain options also require you to modify your categories.php file, check the readme.
  • Can this be used to do "sections" in the style of the more generic forum systems (vB, phpBB, PunBB, etc.)? That is, I basically want to have a few parent categories, which are just for visual organization -- you have to post in one of the subcategories. (It needs only be two levels deep. The top-level abstract sections, and the categories they contain.) And on the main Categories page, each should show its immediate subcategories. Is that possible? Well, I'm sure it is, but has anyone done it? :)
Sign In or Register to comment.