Fork me on GitHub

ObjectUtil::storeObjectCategories not storing multiple select categories?  Bottom

  • Hi fellow category-fans,

    I just ran into the strangest thing: when adding the multipleSize parameter to the selector_category plugin and trying to store multiple values for a category, these selections are not being stored. Tracking down this behaviour I found the following in ObjectUtil storeObjectCategories:

    Code

    foreach ($obj['__CATEGORIES__'] as $prop => $cat)
            {
                // if there's all the data and the Registry exists
                // the category is mapped
                if ($cat && $prop && isset($reg_ids[$prop]))
                {
                    $cobj['id']           = '';
                    $cobj['modname']      = $modname;
                    $cobj['obj_id']       = $obj[$idcolumn];
                    $cobj['category_id']  = $cat;
                    $cobj['reg_id']       = $reg_ids[$prop];
                   
                    $res = DBUtil::insertObject ($cobj, 'categories_mapobj');
                }
            }


    For a multiple selection $cat is an array, therefore the if condition fails, therefore InsertObject is never called.

    Am I talking total crap? Is this a bug (I can't believe nobody else ran into this problem before)?



    edited by: dits, datetimebrief
  • I am not sure if this is a bug, but I guess it probably is. Please report it to the Cozi for reference in any case.

    --
    Guite | ModuleStudio
  • Thanks, I've created the ticket: http://code.zikula.org/core/ticket/1739.
  • In News you can assign only one category per property, so if I read correct you dont have a problem then. And it works fine. Assigning multiple categories from one property is something I have never tried.

    I have used the categoryselector with multiple size for selecting categories to show in the News blocks icon_smile But that value is stored in a block param.

    --
    campertoday.nl, Module development, Dutch Zikula Community
  • espaan

    I have used the categoryselector with multiple size for selecting categories to show in the News blocks icon_smile But that value is stored in a block param.


    You mean you store a serialized array of property values in the block param? I presume the selection relates to what you want to display in the block. Then it makes sense storing it in the block data.

    In my case I want to store the multiple selection related to an PNObject, guess that should be handled by ObjectUtil.
  • Indeed. News block usage is only for selecting the categories to show in the block output. But the ticket is there icon_smile

    --
    campertoday.nl, Module development, Dutch Zikula Community

This list is based on users active over the last 60 minutes.