Skip to main content
Version: 10.x

Views

Definition & Principles​

Read Porto SAP Documentation (#Views).

Rules​

  • Views SHOULD be created inside the Containers, and they will be automatically available for use in the Web Controllers.

Folder Structure​

- app
- Containers
- {section-name}
- {container-name}
- UI
- WEB
- Views
- welcome.php
- profile.php
- ...

Code Sample​

Welcome page View​

<!DOCTYPE html>
<html>
<head>
<title>Welcome</title>
</head>
<body>
<div class="container">
<div class="content">
<div class="title">Welcome</div>
</div>
</div>
</body>
</html>

Usage From Controller​

class Controller extends WebController
{
public function sayWelcome()
{
return view('just-welcome');
}
}

Namespaces​

  • By default, all Views are namespaced as the camelCase of its Section name + @ + camelCase of its Container name.

For example, a view named welcome-page inside MySection > MyContainer can be accessed like this: view(mySection@myContainer::welcome-page)

If you try to access it without the namespace view('just-welcome'), it will not find your View.

note

View files in Ship folder are exception to this and will be namespaced with the word "ship" instead of section name, e.g. view(ship::welcome-page)