Site Types
Site types are a way to quickly set up your own category of website. The first site type we have is SiteTypePizza, which allows someone who either owns their own pizza restaurant or is making a website for a pizza company, to have their very own pizza website running in moments. Developers can then customize the public website, and otherwise, content management is already setup.
Note: Instances of SiteTypePizza are simply an example. Whatever you name as your site type will take the place of that reference in the below docs.

Activating a Site Type

Coming soon...

Creating a Site Type

CLI Command
To generate a site type locally through the command line, we have a simple way to do this:
1
php artisan cms:siteType:create VendorName SiteTypeName
Copied!
For the Pizza site type, the formatting was Adaptcms SiteTypePizza - however, if you do not include the prefix SiteType, it will be prepended automatically anyways.
Base Config
This first page on the site type activation screen is used to store general info for your site type. That may be the site name, a logo image, or other things that can be used in building a layout, for example:
1
src/SiteType/SiteTypePizza.php
2
3
/**
4
* Base Config
5
*
6
* @return array
7
*/
8
public $config = [
9
[
10
'name' => 'Site Name',
11
'field' => 'FieldText',
12
'is_required_create' => true,
13
'is_required_edit' => true
14
]
15
];
Copied!
Provide a valid {vendor}/{package} namespace for a field, define a name for the field, can require the field value to be provided, and can pass in meta-information as seen in an example below:
1
src/SiteType/SiteTypePizza.php
2
3
/**
4
* Base Config
5
*
6
* @return array
7
*/
8
public $config = [
9
[
10
'name' => 'Site Logo',
11
'field' => 'FieldImage',
12
'meta' => [
13
'mode' => 'single'
14
]
15
]
16
];
Copied!
FieldImage has an option to support either a single or multiple images above, so providing a meta key with key/value of mode => single would create the field so a single image can be uploaded to the provided module, or in this case, configuration for the site type.
Custom Modules
Using the Pizza example, we want a Location module so the owner can enter in their different store locations to show on the website:
1
src/SiteType/SiteTypePizza.php
2
3
/**
4
* Custom Modules
5
*
6
* @return array
7
*/
8
public $modules = [
9
[
10
'name' => 'Location',
11
'fields' => [
12
[
13
'name' => 'Title',
14
'field' => 'FieldText',
15
'is_required_create' => true,
16
'is_required_edit' => true
17
],
18
[
19
'name' => 'Address',
20
'field' => 'FieldPlace',
21
'is_required_create' => true,
22
'is_required_edit' => true
23
],
24
[
25
'name' => 'Notes',
26
'field' => 'FieldTextarea'
27
]
28
]
29
]
30
];
Copied!
So we want a module called Location, with a title field (ex. Downtown Atlanta), address (of the store), and notes (ex. store hours or parking info).
Custom Pages
The other piece is static pages. For our example pizza restaurant, we may want an About Us page to talk about the history and mission of the pizza chain, a contact page with information on how to get in contact, a catering page with information on how to get pizza catered to you, and so on.
For this example, we'll just show a simple About Us page:
1
src/SiteType/SiteTypePizza.php
2
3
/**
4
* Custom Pages
5
*
6
* @return array
7
*/
8
public $pages = [
9
[
10
'name' => 'About Us',
11
'url' => '/about',
12
'fields' => [
13
[
14
'name' => 'Body',
15
'field' => 'FieldRichText',
16
'is_required_create' => true,
17
'is_required_edit' => true
18
]
19
]
20
]
21
];
Copied!
UI - Overwrite Layout
When creating a Site Type, you can choose to overwrite the public layout in the src/SiteType/SiteTypePizza.php file:
1
class SiteTypePizza
2
{
3
/**
4
* @var bool
5
*/
6
public $overwriteLayout = true;
7
}
Copied!
This value is set to false by default, but switching to true will copy the layout in your site type path ui/layouts/layout.vue to the Site package folder where the public layout resides.
Using the power of package fields, you can easily build PHP arrays that contain the configuration used when activating the site type.
UI - Activate Site Type
When activating a site type, there is a basic warning near the top of the page explaining that current data may be overwritten by continuing and below that is where you may choose to show whatever you choose. You may want to simply thank the user for using your site type, show a preview of what it will look like, or other notes.
Simply edit, to your heart's content, the file at ui/ActivateSiteType.vue within your Site Type's folder.
Last modified 7mo ago