Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Get object data only if item id is available

givanz43750b66acff
diff --git a/admin/controller/crud.php b/admin/controller/crud.php
index 34e7dc4..b1d51d8 100755
--- a/admin/controller/crud.php
+++ b/admin/controller/crud.php
@@ -76,35 +76,38 @@ class Crud extends Base {
}
function index() {
- $type = $this->type;
- $type_id = "{$type}_id";
- $view = View :: getInstance();
- $data_id = $this->request->get[$type_id] ?? false;
- $admin_path = \Vvveb\adminPath();
-
- if (isset($this->model)) {
- $modelName = $this->model;
- } else {
- $modelName = $type;
- }
-
- $model = model($modelName);
+ $type = $this->type;
+ $type_id = "{$type}_id";
+ $view = View :: getInstance();
+ $data_id = $this->request->get[$type_id] ?? false;
+ $admin_path = \Vvveb\adminPath();
+ $data = [];
+
+ if ($data_id) {
+ if (isset($this->model)) {
+ $modelName = $this->model;
+ } else {
+ $modelName = $type;
+ }
- $controllerPath = $admin_path . 'index.php?module=media/media';
- $view->scanUrl = "$controllerPath&action=scan";
- $view->uploadUrl = "$controllerPath&action=upload";
+ $model = model($modelName);
- $options = [
- $type_id => $data_id,
- ] + $this->global;
- unset($options['user_id']);
+ $options = [
+ $type_id => $data_id,
+ ] + $this->global;
+ unset($options['user_id']);
- $data = $model->get($options);
+ $data = $model->get($options);
- if (isset($data['image'])) {
- $data['image_url'] = Images::image($data['image'], $type);
+ if (isset($data['image'])) {
+ $data['image_url'] = Images::image($data['image'], $type);
+ }
}
+ $controllerPath = $admin_path . 'index.php?module=media/media';
+ $view->scanUrl = "$controllerPath&action=scan";
+ $view->uploadUrl = "$controllerPath&action=upload";
+
$this->view->status = [0 => __('Inactive'), 1 => __('Active')];
$this->view->$type = $data;
}