You are here:  » Category Hierarchy - Map All Function


Category Hierarchy - Map All Function

Submitted by ChrisNBC on Fri, 2017-10-20 22:02 in

Hi David,

I’m using reverse category hierarchy mapping with ‘edit all’ selected. Often when I apply a filter the results displayed all need to be mapped to the same category, sometimes with one or two exceptions. I wondered if you could possibly suggest a way to add a ‘set all’ option which would apply the same category to all those displayed but would also allow exceptions to be mapped individually. I’ve scoured the forum but couldn’t see anything on this topic which is surprising as I guess a lot of users must have the same issue.

Thanks in advance.

Best regards
Chris

Submitted by support on Sat, 2017-10-21 09:24

Hello Chris,

Sure, i've helped a few users with exactly this and will mark for inclusion in the next distribution. Edit admin/categories_hierarchy_reverse.php and look for the following code at line 225:

    print "<td>&nbsp;</td>";

...and REPLACE with:

    print "<td id='edit_all'>&nbsp;</td>";

And then the following code at line 243:

      print "<td id='edit_".$k."'>";

...and REPLACE with:

      print "<td id='edit_".$k."' class='edit'>";

And finally the following JavaScript beginning at line 282:

  function rm_edit_all()
  {
    for(id=0;id<id_names.length;id++)
    {
      rm_edit(id);
    }
  }

...and REPLACE with:

  function rm_edit_all()
  {
    for(id=0;id<id_names.length;id++)
    {
      rm_edit(id);
    }
    html = document.getElementById("options").innerHTML.replace(/_ID_NAME/g,'all');
    document.getElementById("edit_all").innerHTML = html;
    $("#all").change(function() {
      $(".edit select").val($("#all").val());
    });
  }

With that in place, after clicking Edit All a new "set all" drop-down will appear alongside the button. After using the set all function you can still go on to map categories individually if required...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com