1 (edited by stefan 2022-04-27 07:48:22)

Topic: Category but no subcategory

Hello,

in the help for subcats I read this:
If, when adding/editing and event, no subcategory has been selected, the event will have the normal category colors in the various views.
But it seems not possible to not select a subcategory because allways te first subcat is preselected. There is no empty option in the subcat select.

Or am I doing something wrong???

Stefan

Re: Category but no subcategory

Hi Stefan,
You are right, good point!
I will add the option "None" to the subcategory drop-down menu.

Temporary solution:
Edit the file "pages/eventform1.php" and change line 32 to:

echo $options ? "<option value='0'>None</option>\n".$options : "<script>showX('scMenu',0)</script>\n";

Roel

Re: Category but no subcategory

Beware that there could be people that already uses subcategories and that expects that when a category is marked for using subcategories, then an event will/must have one of the specified subcategories.
It could be a state of an event: Booked, pre-booked, free.
Or it could be a type for the event:
Exhibition, lecture, film.

The category is a type, and the subcategory is a specification for that type. Maybe some admins wants always the users to specify the specification for the category type.

If change is made in a next release it would be good if it would be an option for a category that has sub-cats:
Sub-cat required 1,0 or Y/N  where the default is required, so the system acts as it does now.

Re: Category but no subcategory

I think Schwartz is right.
Admins should have the possibility to choose between these two options.

But thanks for the workaround.
Didn't think it would be that easy wink

Re: Category but no subcategory

If we want this to be optional per event category, the selection needs to be stored in the categories table in the DB.
I'm not very keen on changing the DB schema only for this purpose.
If in the help for subcats (see Stefan's first post) I change the text from . . .

If, when adding/editing and event, no subcategory has been selected, the event will have the normal category colors in the various views.

to . . .

If, when adding/editing and event, subcategories are available, then a subcategory must be selected.

and leave the code unchanged, the problem is solved wink

Do you agree?

Roel

Re: Category but no subcategory

I really can understand not wanting to change the DB scheme!

A little less work would be to have an option via the settings page for all categories.

But - as far as I am the first and only one asking for that I can live with the workaround wink

Re: Category but no subcategory

I've done the following:
When editing an event category, if the admin adds a subcategory with the name "-" (hyphen), it will result in "None" (no subcategory) in the subcategory drop-down menu in the Add/Edit Event window. So in other words: If the admin has added a subcategory with name "-", the user will be able to select "no subcategory" and otherwise the user will have to select a subcategory.

Stefan, I will send you an updated file eventfrom1.php by email.
Let me know if this works for you please.

Roel

8 (edited by stefan 2022-04-28 07:50:08)

Re: Category but no subcategory

Hy Roel,

yes, this works.
Important to me was when "none" subcat ist selected, that the category is shown only with the main cat.
What I mean - it is shown like "public" not like "public - none".
And so it is ... - yes, good solution. Hopefully not onlyfor me
Thanks for that!

Only thing, that perhaps confuses a little bit is the need of setting colors for the "-" subcat without any effect ...

   Stefan

Re: Category but no subcategory

Hi there,
You are right, this could be confusing. I think my current 'solution' is not the best solution.
I'm working on a more elegant solution.
Once this new solution is ready, I will sent you some changed files.
Roel

Re: Category but no subcategory

Hi there,
I've almost completed a more elegant solution, however, the code changes are so complicated that  I've decided to drop it all.
The point is that by adding just an indicator "user must select a subcategory" to the categories table in the DB everything would be extremely simple. So I think it is much better to put this change on our "todo" list for the next calendar release with a DB schema change.

I assume Stefan, that you can live with the "temporary solution" in my first reply above wink

Roel

Re: Category but no subcategory

Of corseI can!
I am a little sorry for being the reason for that much work for you roll
But at the end perhaps someone else will need that functionality too.
So - thanks a lot smile

Re: Category but no subcategory

Hi Roel,

are there any changes/ anything new concerning subcategories in 5.2.1 ?
I find the new string "cat_scat_must" in the language files but nothing else ...
Am I missing something?

Thanks and greetings

   Stefan

Re: Category but no subcategory

Hi Stefan,
After adding your requested option "none" in the sub-category drop down menu, I looked into the possibility to add a setting to enable/disable this option. Last minute I decided not to do this.
I forgot however, to remove the corresponding text from the language files.
So the the text "cat_scat_must" is not used and can be removed from the language files.

Greetings,
Roel