Welcome, Guest
Username: Password: Remember me

TOPIC: SOLVED: Remove Archived and Trashed options

SOLVED: Remove Archived and Trashed options 04 Mar 2015 14:10 #12874

  • andypooz
  • andypooz's Avatar
  • Offline
  • New Member
  • Posts: 18
  • Thank you received: 2
  • Karma: 0
I'm looking for the best way to remove the Archived and Trashed options from the form field in a component in development. I know it's a jdom element using the ckstate field type but can't trace it back to where it gets the various options (where presumably I can remove the ones I don't want)
I'm only going to use publish and unpublished and just don't want these other two options. I may have been able to change this from within jcook when I was generating the component but I'm well past that point now.
Any help very much appreciated- it has me stumped.

In ckstate, it has the line:
foreach ($this->element->children() as $option)
which must be the four published states, but I don't see where they are comping from

Cheers
Andy

As these things often go, I managed to find the answer myself after investigating further. For anyone with a similar need:

The jdom class with the list of state options which ckstate uses is:
libraries/jdom/html/form/input.select.state.php which follows the html.form.input.select.state reference in the ckstate class.

I removed the two lines 78-79
2 => array('icomoon-archive', 'JARCHIVED', 'both', 'info'),
-2 => array('icomoon-trash', 'JTRASHED', 'both', 'warning')
and the trailing comma on line 77, and this removed the options.

With a view to not messing up the default ckstate behaviour I overrode the class to create statebinary.php and referenced html.form.input.select.statebinary in my ckstate.php

Two issues which don't matter to me but worth raising:
-This means that all ckstate form fields in the component will use this binary class, so if you wanted all four publish options in some views but not others this wouldn't suit you.
-The overridden class does go into the jdom library, and may overridden if you are using updated jdom libraries in the future
Last Edit: 04 Mar 2015 15:03 by andypooz. Reason: Fix found (mostly)
The administrator has disabled public write access.

SOLVED: Remove Archived and Trashed options 04 Mar 2015 15:23 #12875

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Perfect, you found it.

If I can permit myself, your proposal is not the best because you have copied / paste code.

Why not to use a simple parameter ?

Two better solutions :

- 8< - - If you want to use it for 2 or 4 states in your application :
You can custom JDom for recieving one parameter for this purpose. (and ckstate.php for passing this parameter like a bridge between XML and JDom)

- 8< - - If you want 'sometimes' to use it as your please and specifiying the options manually, then you can simply add sub entries in the XML file.

Look at ckstate.php, it is designed to first search in the subitems of the XML node, so if something is found it is prioritary and sent to JDom. (parameter: 'list')
Important note, I don't know if the bug is fixed now, but if you want to add sub items nodes in a FORK, then you need to fix a Joomla issue :
www.j-cook.pro/index.php/h/hacks

Hope it helps.

PS : One last tought... 'statebinary' is a wierd name. In the past this field was binary and simply named 'publish'
Coding is now a piece of cake
Last Edit: 04 Mar 2015 15:24 by admin.
The administrator has disabled public write access.
Time to create page: 0.075 seconds

Get Started