-
Notifications
You must be signed in to change notification settings - Fork 7
Sample Objects
These are sample object data structures that you could save in your database/objects/
directory. The files must be named after the object's class name, e.g. modSystemSetting.php. JSON files can also be used. A file can contain a single object or an array of objects.
You can examine the output of the Export function to generate these files for you from existing data. You can also use Repoman's "Look" function to examine object structure along with their relations.
You can define a custom manager page in MODX 2.3 by defining 2 objects: a modAction
and a modMenu
-- they are linked together by the namespace and controller, e.g. something + index.
modAction.php:
<?php
return array (
'namespace' => 'something',
'controller' => 'index',
'haslayout' => 1,
'lang_topics' => 'something:default',
'assets' => '',
'help_url' => '',
);
Then in the menu modMenu.php:
<?php
return array(
array(
'text' => 'Some Thing', // Lexicon key
'description' => 'something_desc', // Lexicon key
'parent' => 'components',
'action' => 'index',
'icon' => '',
'menuindex' => 0,
'params' => '',
'handler' => '',
'permissions' => '',
'namespace' => 'something'
),
);
This example is attached to an action, so this is how you would build a Custom Manager Page.
<?php
/**
* This file must be named modMenu.php and stored in your model/seeds/ directory
* The menu 'text' and 'description' fields should be Lexicon keys.
*/
return array(
array(
'text' => 'moxycart',
'description' => 'moxycart_desc',
'parent' => 'components',
'action' => 0,
'icon' => '',
'menuindex' => 0,
'params' => '',
'handler' => '',
'permissions' => '',
'Action' => array (
//'action' => 0, // Omit this so that it will inherit from the related object
// This will create an ERROR: Attempt to set NOT NULL field action to NULL
// But it's safe to ignore in this case.
'namespace' => 'moxycart', // <-- this must match your namespace exactly
'controller' => 'index',
'haslayout' => 1,
'lang_topics' => 'moxycart:default',
'assets' => '',
'help_url' => '',
),
),
);
/*EOF*/
Name the file modSystemSetting.php:
<?php
/*-----------------------------------------------------------------
For descriptions here, you must create some lexicon entries:
Name: setting_ + $key
Description: setting_ + $key + _desc
-----------------------------------------------------------------*/
return array(
array(
'key' => 'moxycart.domain',
'value'=> '',
'xtype'=> 'textfield',
'namespace' => 'moxycart',
'area' => 'moxycart:default'
),
array(
'key' => 'moxycart.upload_dir',
'value'=> '',
'xtype'=> 'textfield',
'namespace' => 'moxycart',
'area' => 'moxycart:default'
),
array(
'key' => 'moxycart.api_key',
'value'=> '',
'xtype'=> 'textfield',
'namespace' => 'moxycart',
'area' => 'moxycart:default'
),
);
/*EOF*/
© 2014 and beyond by Craftsman Coding