Welcome to the navigation

Amet, voluptate dolore labore dolor consequat, cillum do id exercitation ut in in commodo anim excepteur sit deserunt eu proident, ullamco duis dolore incididunt aute. Veniam, ad reprehenderit incididunt dolore laboris non tempor excepteur cupidatat nulla velit lorem irure culpa dolore deserunt nisi sint mollit enim ea aute proident, dolor

Yeah, this will be replaced... But please enjoy the search!

Creating page types in Optimizely CMS 12 using the command line

Creating page types and similar using the Optimizely CLI may be a new approach to many but when you get the basics it is very powerful. Here are some advices on how to script and setup content types and controllers a bit more automated.

Introduction

If you are new to the Optimizely CLI, begin by reading my blog post on getting started, https://www.herlitz.io/2022/05/03/optimizely-cms-12-cli-tools-getting-started/.

Creating content type and controller using CLI

This example would assume you are using some feature pattern and it will create a folder and place the contenttype and the controller in the folder you specify as name. 

The commands used in this script is epi-cms-contenttype and epi-cms-pagecontroller where epi-cms-contenttype will accept three parameters

  • -na for namespace, optional - MyAppNamespace is used as default
  • -b for base, optional - PageData is used as default
  • --name for name of the content type, optional - the name of the folder where the file is created is used as default

The dotnet new epi-cms-pagecontroller will accept three parameters

  • -na for namespace, optional - MyAppNamespace is used as default
  • -ct for content type, optional - PageData is used as default
  • --name for the name of the controller, optional - the name of the folder where the file is created is used as default

As can be seen, all parameters are optional, this does however not mean it is intended to be used that way and I would recommend anyone to set ALL parameters.

PowerShell

$name = "ArticlePage"
$nameSpace = "MyWeb.Cms.Features"
$contentType = "${name}Type"
$controller = "${name}Controller"

mkdir $name cd $name
dotnet new epi-cms-contenttype -na $nameSpace -b PageData --name $contentType dotnet new epi-cms-pagecontroller -na $nameSpace -ct $contentType --name $controller

Bash

NAME="ArticlePage"
NAMESPACE="MyWeb.Cms.Features"
CONTENTTYPE="${NAME}Type"
CONTROLLER="${NAME}Controller"

mkdir $NAME
cd $NAME

dotnet new epi-cms-contenttype -na $NAMESPACE -b PageData --name $CONTENTTYPE
dotnet new epi-cms-pagecontroller -na $NAMESPACE -ct $CONTENTTYPE --name $CONTROLLER

This would create the following files