? ? ? Success

User tests: Successful: Unsuccessful:

avatar pe7er
pe7er
8 Dec 2015

Sometimes Joomla's workflow can be a bit confusing for new users:
Usually you have to create a category "X", create some articles that you assign to that category "X", create a menu item of type Category Blog to display the articles from category "X".

This PR adds a new functionality to the Article edit form that makes it possible to create & assign a new Category on the fly.

Huge thanks to @roland-d who helped me with developing this functionality at the Joomla Code Sprint at Roompot in Weert(NL).

Testing Instructions

Before the PR

Go to Content > Article
Create a new article (Title) and select an existing Category.

After the PR

Go to Content > Article
Create a new article (Title) and click on the Category dropdown.

article1

The Category dropdown now has an option to add a new Category name.

article2

Don't forget to click on to select your newly created Category.

article3

The new Category will be on the bottom of the list, but only saved when the article is saved.

avatar pe7er pe7er - open - 8 Dec 2015
avatar pe7er pe7er - change - 8 Dec 2015
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 8 Dec 2015
Labels Added: ? ?
avatar brianteeman
brianteeman - comment - 8 Dec 2015

Is it always a root level category?

avatar pe7er
pe7er - comment - 8 Dec 2015

Yes, that's right.
If you want to change the Categories (which you'll probably will later on), you can do that later in the Category Manager.

avatar brianteeman
brianteeman - comment - 8 Dec 2015

Thanks for clarifying @pe7er just wanted to double check before testing

avatar wilsonge
wilsonge - comment - 9 Dec 2015

OK Several "smaller" comments and a "larger" comment (the plugin thing) but overall nice work. This is a really positive feature :)

avatar designbengel
designbengel - comment - 9 Dec 2015

What about having a field "parent category" and a second field "child category"
This would improve 2 things:
1) On pages with complex structure it´s easier to find the categories inside the list
2) This great new feature would be able to add categories to existing parent categories

thanks for this great feature!

avatar brianteeman
brianteeman - comment - 9 Dec 2015

Without commenting on the code aspects that @wilsonge mentioned

  1. Creating categories and alias works (although I did manage at one point to rename an existing category but cant replicate that anymore)
  2. As it stands its a bit of a hidden secret. I would suggest updating the tooltip similar to the one for the tags
  3. @wilsonge comment that this functionality should be available to all components that use categories makes sense to me. Just as tags works consistently across all uses so should category selection and creation
    This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8623.
avatar brianteeman
brianteeman - comment - 9 Dec 2015

Also what about the acl.
If the user doesnt have access to create a root level category what happens. (Sorry I havent tested this as I am useless setting up the ACL)


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8623.

avatar brianteeman
brianteeman - comment - 9 Dec 2015

Sorry me again

Front end editing
While you can create a new tag on the frontend you cant create a new category


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8623.

avatar pe7er
pe7er - comment - 9 Dec 2015

Thanks for your constructive feedback @wilsonge !
I've made some changes, e.g. moved the code to category helper file so that it can be reused with other extensions that use com_categories categories. IMHO it's better to use the helper file and not a plugin.
Roland (thanks @roland-d !) helped me with refactoring the allowAdd to the field.php library.

avatar pe7er
pe7er - comment - 9 Dec 2015

Thanks for your feedback @designbengel !
I've tried to keep it as simple as possible.
IMHO people can use the Category Manager to further (re)organize their category structure.
The categories created from articles are all assigned to parent level & easy to find.

Maybe we could add a message about that after creating a new category?
For example: "You've created a new category. To organize your categories go to the [Category Manager]" with [Category Manager] linked to the category manager?

avatar brianteeman
brianteeman - comment - 9 Dec 2015

Simple is always best

avatar pe7er
pe7er - comment - 9 Dec 2015

Thanks for your feedback @brianteeman
I'll indeed add this functionality to other components that make use of Categories. Now that the Category Creation method is in the helper file, it's easier to reuse by other components.

Thanks for your tooltip suggestion, I've added it to this PR.

avatar pe7er
pe7er - comment - 9 Dec 2015

I've reproduced the front-end problem with this PR that @brianteeman reported.
I'll try to fix that...

avatar infograf768
infograf768 - comment - 9 Dec 2015

Please alpha order
+JGLOBAL_ADD_CUSTOM_CATEGORY="Add new Category"

avatar pe7er
pe7er - comment - 9 Dec 2015

I will do so. Thanks @infograf768

Something else: I've run into an issue with creating a new Category Name with numbers only.
I'll fix that too...

avatar pe7er
pe7er - comment - 9 Dec 2015

Solved the issue with using a Category name that's only a number. Thanks @roland-d
Alpha ordered new language strings. Thanks @infograf768
Changed tooltip. Thanks @brianteeman

avatar pe7er
pe7er - comment - 9 Dec 2015

Ok, I've moved some code from fields to categoryedit (Thanks for this advice @wilsonge)
Roland helped me restructuring it (Thanks @roland-d!)

avatar micker
micker - comment - 9 Dec 2015

its realy goooooodddd
same think for link menu ?
in article editing view and category editing view => select an existing link or create a new one

avatar pe7er
pe7er - comment - 9 Dec 2015

@micker yes, after I've created this feature for other components, I'll look into menu item creation.

avatar wilsonge
wilsonge - comment - 9 Dec 2015

Almost there :) I think this last comment and you are good from a code perspective. Nice one @pe7er looking forward to seeing this make it into core!

avatar pe7er
pe7er - comment - 9 Dec 2015

I've changed require_one to JLoader::register. Thanks @wilsonge !

avatar wilsonge
wilsonge - comment - 9 Dec 2015

SeemsGood

avatar infograf768
infograf768 - comment - 10 Dec 2015

Tested OK here in monolanguage and multilanguage where the new category picks the article language ( :smile: ).
The tip displayed in back-end could also be displayed in front-end I guess.

avatar alikon
alikon - comment - 10 Dec 2015

tested successfuly
nice one @pe7er

avatar wilsonge wilsonge - change - 10 Dec 2015
Labels Added: ?
avatar wilsonge wilsonge - change - 10 Dec 2015
Milestone Added:
avatar Kubik-Rubik Kubik-Rubik - change - 10 Dec 2015
Labels Added: ?
avatar pe7er
pe7er - comment - 10 Dec 2015

Thanks for testing @infograf768 & @alikon and everybody else for improving this PR!

avatar joomla-cms-bot joomla-cms-bot - change - 10 Dec 2015
Labels Removed: ?
avatar infograf768
infograf768 - comment - 11 Dec 2015

Thought:
after looking more into this, I became conscious of an aspect we may have overseen: ACL.
By default, an Author and up can create articles —normal—, but also categories as the permissions for the component are not separated in Joomla.
As long as this was in back-end, that was not a problem as Authors, Editors, Publishers are not allowed to log in back-end by default, but now that this feature let's create also categories in frontend, it shows the limitations of our ACL. Basically, an Author could create as many new categories as desired...

Is it a real issue? What do you think?

avatar Gerlof Gerlof - test_item - 11 Dec 2015 - Tested successfully
avatar Gerlof
Gerlof - comment - 11 Dec 2015

I have tested this item :white_check_mark: successfully on cf87097


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8623.

avatar pe7er
pe7er - comment - 12 Dec 2015

Thanks for testing @Gerlof

Thanks @infograf768 for your comment about this PR & ACL.
This can be a problem indeed, will check it...

avatar joomla-cms-bot
joomla-cms-bot - comment - 12 Dec 2015

This PR has received new commits.

CC: @Gerlof


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8623.

avatar pe7er
pe7er - comment - 12 Dec 2015

I've tested the issue with front-end ACL that @infograf768 described:
It was possible for an author to create (unlimited) new categories, however their articles were all created with publish state "unpublished".
IMHO that's unwanted behavior, so I removed the possibility on the front-end to add new categories.

avatar NLRoosj NLRoosj - test_item - 12 Dec 2015 - Tested successfully
avatar NLRoosj
NLRoosj - comment - 12 Dec 2015

I have tested this item :white_check_mark: successfully on c055379

Very usable to end-users AND administrators. Tested multi-lingual. Worked fine!


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8623.

avatar FeikeMulder FeikeMulder - test_item - 12 Dec 2015 - Tested successfully
avatar FeikeMulder
FeikeMulder - comment - 12 Dec 2015

I have tested this item :white_check_mark: successfully on c055379

Tested successfully.
Verry Nice feature.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8623.

avatar superknutsel superknutsel - test_item - 12 Dec 2015 - Tested successfully
avatar superknutsel
superknutsel - comment - 12 Dec 2015

I have tested this item :white_check_mark: successfully on c055379

@test tested succesfully, nice feature!


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8623.

avatar wilsonge wilsonge - change - 12 Dec 2015
Milestone Removed:
avatar wilsonge wilsonge - change - 12 Dec 2015
Milestone Added:
avatar infograf768
infograf768 - comment - 13 Dec 2015

@pe7er
Do we still need the new strings in frontend?

avatar anibalsanchez anibalsanchez - test_item - 2 Jan 2016 - Tested successfully
avatar anibalsanchez
anibalsanchez - comment - 2 Jan 2016

I have tested this item :white_check_mark: successfully on c055379

Test OK


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8623.

avatar brianteeman brianteeman - change - 12 Jan 2016
Category Components
avatar brianteeman brianteeman - change - 12 Jan 2016
Status Pending Ready to Commit
Labels
avatar brianteeman
brianteeman - comment - 12 Jan 2016

RTC - thanks


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8623.

avatar joomla-cms-bot joomla-cms-bot - change - 12 Jan 2016
Labels Added: ?
avatar infograf768
infograf768 - comment - 12 Jan 2016

@pe7er
I still think we do not need the new language strings in frontend.

avatar wilsonge wilsonge - close - 9 Apr 2016
avatar wilsonge
wilsonge - comment - 9 Apr 2016

Merged with b853b6b

avatar wilsonge wilsonge - change - 9 Apr 2016
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2016-04-09 14:18:36
Closed_By wilsonge
avatar ggppdk
ggppdk - comment - 9 Apr 2016

With a quick look at the code

  • i did not find the ACL check on core.create for the categoryedit form element
  • only an attribute 'allowAdd' to enable the feature, ok but that also needs to be complemented with an ACL core.create check

so i decided to test this feature in 3.6.x

Indeed the categoryedit form element does not check it

How to test

  • Edit permissions of "manager" usergroup and deny the create at global configuration (and allow to backend access)
  • Login as a "manager" user to backend, and edit any article
  • Type "Test" into the categoryedit form element, and you see it allows you to add new category
  • After saving the article new category is not created which is expected but ... the article category is reset to 1 aka to ROOT category

The problem is that after checking the allowAdd attibute,
we need to go further and also make an core.create ACL check on
the extension (since we are creating a category at root level right ?)

https://github.com/pe7er/joomla-cms/blob/c05537939099d815ec49fb9676c955ec18d61e85/administrator/components/com_categories/models/fields/categoryedit.php#L59

$this->allowAdd = isset($this->element['allowAdd']) ? $this->element['allowAdd'] : '';

if ($this->allowAdd)
{
    $jinput = JFactory::getApplication()->input;
    $user = JFactory::getUser();
    $extension = $this->element['extension'] ? (string) $this->element['extension'] : (string) $jinput->get('extension', 'com_content');
    $this->allowAdd = $user->authorise('core.create', $extension);
}

no_privilege_create
no_privilege_create2

avatar joomla-cms-bot joomla-cms-bot - change - 9 Apr 2016
Labels Removed: ?
avatar ggppdk
ggppdk - comment - 9 Apr 2016

@wilsonge
@pe7er

can you test this ?

avatar wilsonge wilsonge - reference | 4cde326 - 20 May 16
avatar JoshuaLewis
JoshuaLewis - comment - 13 Jul 2016

Now if only this option was available on the frontend, communities could create all sorts of structures with this!

avatar chrisdavenport
chrisdavenport - comment - 13 Jul 2016

@JoshuaLewis What could possibly go wrong!? ;-)

avatar JoshuaLewis
JoshuaLewis - comment - 13 Jul 2016

If it was permission based (whether ACL or through a menu item) it could be managed through a select group of people via Joomla's user groups. If the easy creation of categories could be assigned to a parent category, someone attempting to wreck havoc wouldn't be hard to spot and wouldn't really mess up the site structure.

Add a Comment

Login with GitHub to post a comment