# Compatibility & Plug-ins
# Configuration tricks
NOTE
You can rewrite config settings from 'scripts' and 'editor' sections directly on your page. This will be affected on all instances on page. You can use it when you need to dynamically change some parameter from that sections.
Example:
Xcrud_config::$some_parameter = 'some value';
You must write this after you included xcrud.php file and before render()
method. All parameters and description you can find in configuration file (xcrud_config.php)
# load_css()
Static method. Allow you to load xcrud's css files at you custom place. By default xcrud loads styles before instance output
echo Xcrud::load_css();
# load_js()
Static method. Allow you to load xcrud's javascript files and scripts at you custom place. By default xcrud loads javascript after instance output
echo Xcrud::load_js();
# Bootstrap, jQuery and javascript conflicts
If your template already uses jquery or jqueryui or bootstrap, you must turn off them in configuration file.
Note, all xCRUD's scripts must be loaded after jQuery. If your jQuery loads in the bottom of page, you must call <?php echo Xcrud::load_js(); ?>
in the bottom of page after jQuery and <?php echo Xcrud::load_css(); ?>
in top (the best in <head></head>
).
If xCRUD's content rendered before output in template, set $manual_load
parameter in TRUE in configuration file. This will prevent automatic loading scripts and styles.
# Session Trouble
Many frameworks and cms can destroy native php session on reload. xCRUD generates Security key error to any action. If this was happenned, you can try to use alternative session (you need memcache(d) and mcrypt modules on your server).
Also you will get an error when session name was changed from default. And you can try to customize $sess_name
or $dynamic_session
parameters in configuration.
If you have deep integration with your framework or cms (this mean, the xcrud's ajax file (uri) is a part of your system), you can use special functions to syncronize xcrud's session with yours. Codegniter example:
# Ajax controller
class Ajax extends CI_Controller{
public function __construct(){
parent::__construct();
}
public function index(){
include(FCPATH.'/xcrud/xcrud.php');
Xcrud::import_session($this->session->userdata('xcrud_sess'));
Xcrud::get_requested_instance();
$this->session->set_userdata(array('xcrud_sess'=>Xcrud::export_session()));
}
}
# Some content controller
class Ajax extends CI_Controller{
public function __construct(){
parent::__construct();
}
public function orders(){
include(FCPATH.'/xcrud/xcrud.php');
$xcrud = Xcrud::get_instance();
$xcrud->table('orders');
$data['content'] = $xcrud->render();
$this->load->view('some_content', $data);
// Xcrud::export_session() will destroy all xcrud's instances
$this->session->set_userdata(array('xcrud_sess'=>Xcrud::export_session()));
}
}