Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
$305 per month—let's make that $500!Learn more
Directions how to create component with name YourComponent using BxrExtra.
Create directory 'yourcomponent'. Clone BxrExtra to yourcomponent directory by running 'git clone git://github.com/TheBoxer/BxrExtra.git .' from yourcomponent folder.
You can delete '.git' folder now.
Edit 'config.core.php' file and point 'MODX_CORE_PATH' constant to your MODX core location.
Now you want to rename BxrExtra to YourComponent, co first of all edit 'rename_it.sh' and set 'repl1' to 'YourComponent', 'repl2' to 'yourcomponent' and 'path' to './yourcomponent'.
Edit 'yourcomponent/core/components/yourcomponent/templates/home.tpl' and change id of div from 'bxrextra-panel-home-div' to 'yourcomponent-panel-home-div'.
After this changes add two settings in your System Settings (in manager):
- 'yourcomponent.core_path' - Point to /yourcomponent/core/components/yourcomponent/
- 'yourcomponent.assets_url' - /yourcomponent/assets/components/yourcomponent/
Assets url must be visible from web.
Next step is creating namespace with name 'YourComponent', core path 'Point to /yourcomponent/core/components/yourcomponent/' and assets path 'Point to /yourcomponent/assets/components/yourcomponent/'.
After you created namespace, add new action under YourComponent namespace with index controller and without parent controller.
Place just created action under Component menu (or where ever you want) with lexicon key 'yourcomponent' and description 'yourcomponent.menu_desc'. Then clear the cache and refresh manager page.
If you want to create default database table provided in BxrExtra add new snippet in your manager, call it createDBTable and set it as static. Set media sources for Static files to '(None)' and Static file to '
[[++yourcomponent.core_path]]/elements/snippets/snippet.yourcomponentCreateDB.php'. Use 'createDBTable' snippet in any of your resources and run it. You shoud get 'Table created.' message.
Now you should have fully working extra with functions described below.
- Integrates a custom table of "Items"
- A snippet listing Items sorted by name and templated with a chunk
- A custom manager page to manage Items on
- Class based processors
- Grid with inline editing, right menu function and new item / update item / delete item window and search box
- Drag and drop sort in grid
If you do not require all of this functionality, simply remove it and change the appropriate code.
- delete assets/components/yourcomponent/js/mgr/extra/griddraganddrop.js
- in core/components/yourcomponent/controllers/home.class.php
- in assets/components/yourcomponent/js/mgr/widgets/items.grid.js
- remove ddGroup config parameter
- remove enableDragDrop config parameter, or set to false
- remove render and beforeDestroy listeners
- remove getDragDropText function
Removing position from database (position is used for sort)¶
- in core/components/yourcomponent/model/schema/yourcomponent.mysql.schema.xml
- remove field with "position" key
- remove all php files in core/component/yourcomponent/model/yourcomponent/mysql folder
- in _build
- rename build.config.sample.php to build.config.php
- edit build.config.php and set MODX_BASE_PATH to path to your modx location
- run _build/build.schema.php
- it should make new files in core/component/yourcomponent/model/yourcomponent/mysql folder
- remove yourcomponent_items table from database
- run snippet that create database table (described in Setup)
Fell free to open pull requests or add issues.