Skip to content

Commit

Permalink
use php extension for backend views/partials files
Browse files Browse the repository at this point in the history
  • Loading branch information
mjauvin committed Sep 25, 2023
1 parent e658812 commit 1745a73
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions architecture/developer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,13 @@ Element classes names should use hyphen-case (dashes)
Partial views should begin with an underscore character. Whereas Controller and Layout views do not begin with an underscore character. Since views are often found in a single folder, the underscore (_) and dash (-) characters can be used to organise the files. A dash is used as a substitute for a space character. An underscore is used as a substitute for a slash character (folder or namespace).

```
index_fancy-layout.htm <== Index\Fancy layout
form-with-sidebar.htm <== Form with sidebar
_field-container.htm <== Field container (partial)
_field_baloon-selector.htm <== Field\Baloon Selector (partial)
index_fancy-layout.php <== Index\Fancy layout
form-with-sidebar.php <== Form with sidebar
_field-container.php <== Field container (partial)
_field_baloon-selector.php <== Field\Baloon Selector (partial)
```

View files must end with the `.htm` file extension.
View files must end with the `.php` file extension.

### Class naming

Expand Down Expand Up @@ -540,7 +540,7 @@ folder/
| |-- sub2folder/
| | `-- sub3file # A comment about this file
| `-- sub2folder2/
|-- index.htm
|-- index.php
`-- .hidden_file # This file is hidden and should be slightly transparent
```</code></pre>

Expand All @@ -557,7 +557,7 @@ folder/
| |-- sub2folder/
| | `-- sub3file # A comment about this file
| `-- sub2folder2/
|-- index.htm
|-- index.php
`-- .hidden_file # This file is hidden and should be slightly transparent
```

Expand All @@ -577,7 +577,7 @@ This feature also supports the output of the `tree` command-line utility which i

# folder/
# ├── .hidden_file
# ├── index.htm
# ├── index.php
# ├── subfolder1/
# ├── subfolder2/
# │ ├── document.pdf
Expand All @@ -601,7 +601,7 @@ folder/
│ └── sub2folder/
│ └── sub3file
├── .hidden_file
└── index.htm
└── index.php
```

> **NOTE:** The `tree` command may print out indented lines using a character that looks to be a space character, but is not. If this is the case, you may need to add the `--charset=ascii` option to the command, which will print a diagram similar to the first example.
8 changes: 4 additions & 4 deletions backend/controllers-ajax.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

The Winter CMS backend implements the MVC pattern. Controllers manage backend pages and implement various features like forms and lists. This article describes how to develop backend controllers and how to configure controller behaviors.

Each controller consists of a PHP file which resides in the the **/controllers** subdirectory of a Plugin directory. Controller views are `.htm` files that reside in the controller view directory. The controller view directory name matches the controller class name written in lowercase. The view directory can also contain controller configuration files. An example of a controller directory structure:
Each controller consists of a PHP file which resides in the the **/controllers** subdirectory of a Plugin directory. Controller views are `.php` files that reside in the controller view directory. The controller view directory name matches the controller class name written in lowercase. The view directory can also contain controller configuration files. An example of a controller directory structure:

```treeview
plugins/
`-- acme/
`-- blog/
|-- controllers/
| |-- users/ # Controller view directory
| | |-- _partial.htm # Controller partial file
| | |-- _partial.php # Controller partial file
| | |-- config_form.yaml # Controller config file
| | `-- index.htm # Controller view file
| | `-- index.php # Controller view file
| `-- Users.php # Controller class
`-- Plugin.php
```
Expand Down Expand Up @@ -57,7 +57,7 @@ Property | Description

## Actions, views and routing

Public controller methods, called **actions** are coupled to **view files** which represent the page corresponding the action. Backend view files use PHP syntax. Example of the **index.htm** view file contents, corresponding to the **index** action method:
Public controller methods, called **actions** are coupled to **view files** which represent the page corresponding the action. Backend view files use PHP syntax. Example of the **index.php** view file contents, corresponding to the **index** action method:

```html
<h1>Hello World</h1>
Expand Down
4 changes: 2 additions & 2 deletions backend/views-partials.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Partials

Backend partials are files with the extension **htm** that reside in the [controller's views](controllers-ajax#introduction) directory. The partial file names should start with the underscore: *_partial.htm*. Partials can be rendered from a backend page or another partial. Use the controller's `makePartial` method to render a partial. The method takes two parameters - the partial name and the optional array of variables to pass to the partial. Example:
Backend partials are files with the extension **php** that reside in the [controller's views](controllers-ajax#introduction) directory. The partial file names should start with the underscore: *_partial.php*. Partials can be rendered from a backend page or another partial. Use the controller's `makePartial` method to render a partial. The method takes two parameters - the partial name and the optional array of variables to pass to the partial. Example:

```php
<?= $this->makePartial('sidebar', ['showHeader' => true]) ?>
Expand Down Expand Up @@ -98,4 +98,4 @@ This layout uses two placeholders, a primary content area called **form-contents
<?php Block::endPut() ?>
```

The layout is executed in the final section by overriding the **body** placeholder used by every backend layout. It wraps everything with a `<form />` HTML tag and renders the child layout called **form-with-sidebar**. This file is located in `modules\backend\layouts\form-with-sidebar.htm`.
The layout is executed in the final section by overriding the **body** placeholder used by every backend layout. It wraps everything with a `<form />` HTML tag and renders the child layout called **form-with-sidebar**. This file is located in `modules\backend\layouts\form-with-sidebar.php`.

0 comments on commit 1745a73

Please sign in to comment.