Merge branch 'template_support' into dev
This commit is contained in:
@@ -56,23 +56,32 @@ class EditContent extends Controller
|
||||
$page = Content::findOrFail($id);
|
||||
$page->module_settings = json_decode($page->module_settings);
|
||||
|
||||
$allModules = ModulesHandlerToId::getWithTranslations();
|
||||
$moduleId = $allModules[$page->module_handler];
|
||||
$module = Module::findOrFail($moduleId);
|
||||
// select template
|
||||
$template = Module::where('is_template', true)
|
||||
->where('enabled', true)
|
||||
->first();
|
||||
|
||||
// get module ID
|
||||
$module = Module::where('handler', $page->module_handler)->firstOrFail();
|
||||
|
||||
$templates = Template::where('module_id', $moduleId)
|
||||
// get all Blade templates for rendering page
|
||||
$templates = Template::where('module_id', $module->id)
|
||||
->select(['template_name', 'name', 'description'])
|
||||
->get();
|
||||
|
||||
// get module for Categories - PingPong module
|
||||
$categoryModule = ModuleInstance::get('categories');
|
||||
|
||||
// add categories, if supported
|
||||
$categories = [];
|
||||
if ($module->support_categories && $categoryModule->enabled()) {
|
||||
$categories = Category::where('module_id', $moduleId)
|
||||
$categories = Category::where('module_id', $module->id)
|
||||
->get();
|
||||
}
|
||||
|
||||
// modify data for edit form according to installed template
|
||||
call_user_func_array([$template->handler, 'beforePopulatingEditForm'], [&$page]);
|
||||
|
||||
$history = $this->history->getStructuredHistoryOf($page);
|
||||
|
||||
// render view
|
||||
@@ -107,6 +116,10 @@ class EditContent extends Controller
|
||||
* @var $page Content
|
||||
*/
|
||||
$page = Content::findOrFail($id);
|
||||
|
||||
$template = Module::where('is_template', true)
|
||||
->where('enabled', true)
|
||||
->first();
|
||||
} catch (NotFoundHttpException $e) {
|
||||
|
||||
// log attempt of invalid edit
|
||||
@@ -121,6 +134,9 @@ class EditContent extends Controller
|
||||
// upload file - if provided
|
||||
$file = $page->uploadTitlePhoto($request);
|
||||
|
||||
// let template to modify request and content page
|
||||
call_user_func_array([$template->handler, 'beforeSave'], [&$page, $request]);
|
||||
|
||||
$request->url = Str::slug($request->url);
|
||||
$request->parentPage = $request->parentPage ? $request->parentPage : null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user