Passa al contenuto principale

Editorial Content Types

Ci si riferisce ai content type definiti in maniera tradizionale che si vuole editare con il page editor.

Differenze con i CMS Types:

  • gli editorial hanno il loro workspace e possono avere filtri custom
  • gli editorial possono avere metadata fields piu' avanzati, schema multipli e altre logiche di business

I CMS Types sono di fatto piu' semplici.

Usare gli Editorial Content Types con il Page Builder

  • sullo schema di metadati primario bisogna aggiungere uno slug come questo:
{
"name": "slug",
"label_key": "Slug",
"type": "string",
"short_description": "the slug will be generated automatically upon save if empty",
"table": "assets",
"length": 2048,
"editor_config": {
"editor_type": "input",
"editor_subtype": "text"
}
}
  • bisogna aggiungere un hook di tipo metadata-services::before-save-adapters per garantire che lo slug sia sempre valorizzato e sia unico nella property. Esempio:
Plugins::registerHook('metadata-services::before-save-adapters', 'set-slug', function($assetId, $dto, $mds, array $options) {
$asset = AssetServices::getAsset($assetId);

if ($asset->assetSubtype == 'Article') {
CmsUtils::manageSlugUpdate($dto, $asset);
  • bisogna aggiornare gli asset type hook del tipo editoriale come segue:
  // se clicco su un articolo editoriale deve aprire il page editor
$hooks['workspace-navigation'] = static function($asset) {
$pushParam = Breadcrumbs::getPushParam();
$pageEditorUrl = getModuleUrl("Cms/pages/page-editor/page-editor.php?assetId=$asset->assetId&$pushParam");
return "onclick='window.location = \"$pageEditorUrl\"'";
} ;

// Alla creazione, l'asset dev'essere bindato alla property corrente
$hooks['on_created'] = static function($asset) {
$currentPropertyId = CmsPropertyServices::getCurrentUserPropertyId();

if ($currentPropertyId !== null) {
CmsPropertyServices::bindContentToProperty($asset->assetId, $currentPropertyId);
}
};

// alla creazione dell'asset mi deve mandare nel page editor
$hooks['on_created_redirect_url'] = getModuleUrl("Cms/pages/page-editor/page-editor.php?assetId=#assetId#");