Simple usage Minimal theme
This is a simpliest example
HIDE CODE
<?php
// أو فقط التحذيرات
error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR);
$xcrud = Xcrud::get_instance();
$xcrud->table('edit');
$user_id = 40;
// Autosave (edit mode)
$xcrud->autosave(true, 600,$user_id);
$xcrud->autosave_history(true, 0);
//$xcrud->button('#', "Top", 'glyphicon glyphicon-arrow-up icon-arrow-up', 'btn xcrud-action', array(
// 'data-action' => 'movetop',
// 'data-task' => 'action',
// 'data-primary' => '{id}'));
//
//$xcrud->button('#', "Bottom", 'glyphicon glyphicon-arrow-down icon-arrow-down', 'btn xcrud-action', array(
// 'data-action' => 'movebottom',
// 'data-task' => 'action',
// 'data-primary' => '{id}'));
//
//$xcrud->create_action('movetop', 'movetop');
//$xcrud->create_action('movebottom', 'movebottom');
//SELECT `id`, `title`, `snippet`, `sub_title`, `photo`, `photo_title`, `source_id`, `cat_sources`, `news_type`, `news_content_type`, `embed_url`, `embed_code`, `writer_id`, `editor_id`, `publish_date`, `last_update_date`, `article`, `publish_status`, `media_url`, `homepage`, `article_writer`, `view`, `metatag`, `revision_id`, `card_trend`, `card_fav`, `card_fixed`, `view_last_update`, `properties_writers`, `create_date`, `cat_id`, `user_add`, `status`, `lang`, `newsletter`, `source`, `news_date`, `react_like`, `react_love`, `react_happy`, `react_sad`, `react_angry`, `react_wow`, `react_total`, `react_top` FROM `edit` WHERE 1
//$xcrud->fields_row('title, snippet, news_type', 3, 'Main', true);
$xcrud->fields("title,source_id, snippet, news_type,photo,photo_title");
//$xcrud->fields_row('title, snippet', 2, 'Main', true);
//$xcrud->fields_row('photo, photo_title', 2, 'Main', true);
//$xcrud->fields_row('source_id,status,cat_id,homepage', 3, 'Main', true);
//
//$template_path = dirname(__FILE__) . '/templates/edit_news.html';
//if (file_exists($template_path)) {
// $custom_template = file_get_contents($template_path);
// $xcrud->set_template($custom_template);
//}
$TodayDate = date('Y-m-d');
/////////// END Permison Sections /////////////
$xcrud->bulk_select_position('left');
$xcrud->set_bulk_select(true);
$xcrud->create_action('bulk_delete', 'bulk_delete');
//$xcrud->is_edit_modal(true);
/////////// Start relation Sections /////////////
$xcrud->relation('user_add','users','id','name',array('status' => 1));
$xcrud->relation('article_writer','contacts','id','name',array('status' => 1,'writer' => 1));
//$xcrud->relation('editor_id','users','id','name');
//$xcrud->relation('cat_id','categories','id','name','','','multi');
//$xcrud->relation('person_id','persons','id','full_name',array('status' => 1),'','multi');
//$xcrud->relation('cat_id','categories','id','name','','','');
if($settings_system['multi_lang'] == 1){
$xcrud->relation('lang','lang','id','lang',array('status' => 1));
$lang_yes = ',lang';
} else { $xcrud->change_type('lang','hidden'); }
/////////// END relation Sections /////////////
if(isset($_GET['act'])){
$filed = $_GET['act'];
if($_GET["act"] == 'publish_date'){ $xcrud->where(''.$filed.' >', $TodayDate); }
elseif($_GET["act"] == 'backup'){
$tables = array($_GET['show']);
$Table_Db = backup_tables($tables,dirname(__DIR__, 1).'/db_backup/');
$goto = 'db_backup/'.$Table_Db;
echo '<meta http-equiv="refresh" content="0;url='.$goto.'">';
}
else { $xcrud->where(''.$filed.' =', $_GET['v']); }
}
$xcrud->show_primary_ai_column(true);
$xcrud->columns('id,title,cat_id,view,status');
$xcrud->fields_inline('title,cat_id');//set the fields to allow inline editing
$xcrud->fields('title,snippet,photo,embed_code,photo_title,article,cat_id,metatag,lang,homepage,status', false, 'تاب١ ');
$xcrud->fields('create_date,publish_date,last_update_date', false, "تاب ٢");
//$xcrud->fields('multimedia_vid,multimedia_photo,multimedia_vid_title,multimedia_photo_title', false, "رابط");
//,embed_type,embed_code
$xcrud->set_attr('title,photo_title',array('class'=>'xcrud-input dataChar_input','data-minChars'=>'20','data-maxChars'=>'120'));
$xcrud->validation_required(array('title','article','cat_id','snippet','photo'));
//$xcrud->validation_required('title',130);
//$xcrud->validation_required('snippet',250);
$xcrud->change_type('snippet','textarea');
$xcrud->set_attr('snippet',array('class'=>'xcrud-input dataChar_input','data-minChars'=>'60','data-maxChars'=>'250'));
//dataChar_input
//$xcrud->set_attr('cat_id',array('id'=>'permissions_menu'));
$xcrud->set_attr('cat_id',array('class'=>'form-control selectpicker xcrud-input','multiple'=>'multiple','data-actions-box'=>'true'));
//$xcrud->change_type('article','texteditor');
$xcrud->change_type('user_add','hidden',$user_id,20);
//$xcrud->change_type('multimedia_vid,multimedia_photo','text');
$xcrud->change_type('create_date','datetime',date('Y-m-d H:i:s'));
$xcrud->change_type('last_update_date','datetime',date('Y-m-d H:i:s'));
$xcrud->change_type('publish_date','datetime',date('Y-m-d H:i:s'));
$xcrud->change_type('photo', 'image');
//$xcrud->change_type('photo', 'image', '', array('watermark' => $image_tools["watermark"],'watermark_position' => array($watermark_position['0'],$watermark_position['1']) , 'manual_crop' => !$img_crop ,'thumbs'=>array(
// array('width'=> 150, 'marker'=>'_small'),
// array('width'=> 200, 'marker'=>'_middle'),
// array('width' => 400, 'marker'=>'_big'))));
// $xcrud->change_type('photo', 'image', '', array('watermark' => $image_tools["watermark"],'watermark_position' => array($watermark_position['0'],$watermark_position['1']) , 'manual_crop' => !$img_crop ,'thumbs'=>array(
// array('width'=> 150, 'marker'=>'_small'),
// array('width'=> 200, 'marker'=>'_middle'),
// array('width' => 400, 'marker'=>'_big'))));
// array('width'=>257,'height'=>314,'not_rename'=>false,'path'=>'../upload/','url'=>'../upload/')
$xcrud->modal('photo');
$xcrud->column_width('title','25%');
$xcrud->column_width('last_update_date','10%');
$xcrud->disabled('create_date,last_update_date','edit');
$xcrud->change_type('embed_type', 'select', '', array(''=>' ','1'=>'Facebook','2'=>'Youtube','3'=>'Viemo','4'=>'Maps','5'=>'Twitter','6'=>'SoundCloud'));
$xcrud->pass_var('editor_id', $user_id, 'edit');
$xcrud->pass_default(array('writer_id' => $user_id));//, 'editor_id' => $user_id
$xcrud->change_type('metatag','text','',array('class'=>'xcrud-input tagify tagsMedia','id'=>'kt_tagify_1'));
$xcrud->change_type('multimedia_vid_title','text','',array('class'=>'xcrud-input SearchMediavid','data-search'=>'vid'));
$xcrud->change_type('multimedia_photo_title','text','',array('class'=>'xcrud-input SearchMediaphoto','data-search'=>'photo'));
$xcrud->change_type('multimedia_vid','hidden','',array('class'=>'xcrud-input Mediavid'));
$xcrud->change_type('multimedia_photo','hidden','',array('class'=>'xcrud-input MediaPhoto'));
$xcrud->highlight_row('view','>=','5000','#DEF4FF');
//$xcrud->button(main_url("{id}","edit"),$LANG_reader['EditـShowNews'],'icon-link','',array('target'=>'_blank'));
$xcrud->button('index.php?show=edit_update&edit_id={id}',$LANG_reader['EditـCopyNews'],'icon-drawer-3','','');
$xcrud->disabled(array('create_date','user_add'),'edit');
$xcrud->modal('photo');
/////////////////////////// START Actions View users in table //////////////////////////////////////
$xcrud->column_callback('user_add','user_add_icon');
$xcrud->column_callback('status','status_icon');
/////////////////////////// START Actions View users in table //////////////////////////////////////
$xcrud->after_update('After_news_revison_update');
$xcrud->before_update('Before_news_revison');
/////////////////////////// START Actions View users in table //////////////////////////////////////
/////////////////////////// End Actions View users in table //////////////////////////////////////
/////////////////////////// START Photo Actions //////////////////////////////////////
/////////////////////////// START Photo Upload //////////////////////////////////////
$xcrud->modal('photo');
$xcrud->change_type('photo', 'image', '');
/////////////////////////// END Photo Upload //////////////////////////////////////
/////////////////////////// End Photo Actions //////////////////////////////////////
$xcrud->select(
'',
'fa fa-cog',
'btn btn-sm btn-light xcrud-button xcrud-orange',
[
['label' => 'مشاهدة الخبر على الموقع', 'icon' => 'fa fa-eye', 'url' => '/news/{id}', 'target' => '_blank'],
['label' => 'إرسال الخبر لصديق', 'icon' => 'fa fa-share', 'onclick' => 'sendNewsToFriend({id}); return false;'],
['label' => 'تنبيه', 'icon' => 'fa fa-share', 'onclick' => 'alert(\'hello\');'],
['label' => 'عدم نشر الخبر', 'icon' => 'fa fa-ban', 'onclick' => 'unpublishNews({id}); return false;', 'class' => 'text-danger']
],
['data-test' => 'selectMenu'],
['id', '!=', 0]
);
$xcrud->upload_multi('photo', 10);
$xcrud->change_type('embed_code', 'file', '');
$xcrud->upload_multi('embed_code', 10);
$xcrud->order_by('publish_date','desc');
$xcrud->unset_sortable();
$xcrud->order_by('id');
$xcrud->columns('id,title,snippet');
echo $xcrud->render();
?>