added sort for categories (template function) and redirection to the add page