Milk Admin
Public Page Template
The public.page.php template is a theme page without sidebar and menu, ideal for creating public pages, landing pages, or forms accessible without authentication.
Main features:
- No sidebar or side menu
- Centered header with logo, title, and description
- Main content with maximum width of 800px
- Customizable footer
- Fully customizable background via CSS classes
How to use the public template
To use the public template in your module, use Response::themePage('public', $content):
#[RequestAction('home')]
public function home() {
// Customize the page appearance
\App\Theme::set('public.header.title', 'Your Title');
\App\Theme::set('public.header.description', 'An engaging description');
// Create the content
$content = '<h2>Welcome!</h2><p>Your content here</p>';
// Render with the public template
Response::themePage('public', $content);
}
Customization variables
You can customize the page appearance using Theme::set(). All variables are optional and have default values.
Header
| Variable | Description | Default |
|---|---|---|
public.header.title |
Main page title | 'Milk Admin' |
public.header.description |
Description below the title | '' (empty) |
public.header.logo-path |
Custom logo path | THEME_URL.'/Assets/logo-big.webp' |
public.header.title-color |
Title color (CSS) | '#333' |
Footer
| Variable | Description | Default |
|---|---|---|
public.footer.text |
Footer text | '© '.date('Y').' Milk Admin' |
public.footer.link |
Footer link URL | 'https://milkadmin.org' |
public.footer.link-text |
Link text (if different from footer.text) | Uses footer.text value |
Background
| Variable | Description | Default |
|---|---|---|
public.theme.bg-class |
CSS class for background (see available classes below) | 'public-bg-light-gray' |
Available Background Classes
The following classes are defined in theme.css and can be used to customize the page background:
Light Backgrounds (Professional)
public-bg-light-gray
Light gray (#f5f7fa)
Light gray (#f5f7fa)
public-bg-soft-white
Soft white (#fafbfc)
Soft white (#fafbfc)
public-bg-warm-white
Warm white (#faf9f7)
Warm white (#faf9f7)
public-bg-cool-blue
Cool blue (#f0f4f8)
Cool blue (#f0f4f8)
public-bg-mint
Mint green (#f0fdf4)
Mint green (#f0fdf4)
public-bg-lavender
Lavender (#faf5ff)
Lavender (#faf5ff)
public-bg-peach
Peach (#fff7ed)
Peach (#fff7ed)
Gradient Backgrounds (Modern)
public-bg-gradient-purple
Elegant purple/blue
Elegant purple/blue
public-bg-gradient-ocean
Deep ocean
Deep ocean
public-bg-gradient-sunset
Warm sunset
Warm sunset
public-bg-gradient-forest
Green forest
Green forest
public-bg-gradient-rose
Intense rose
Intense rose
public-bg-gradient-sky
Blue sky
Blue sky
public-bg-gradient-fire
Blazing fire
Blazing fire
public-bg-gradient-emerald
Bright emerald
Bright emerald
Complete Examples
Example 1: Custom Login Page
#[RequestAction('home')]
public function login() {
\App\Theme::set('public.header.title', 'Login to System');
\App\Theme::set('public.header.description', 'Enter your credentials to continue');
\App\Theme::set('public.theme.bg-class', 'public-bg-gradient-ocean');
\App\Theme::set('public.footer.text', '© 2025 My Company');
\App\Theme::set('public.footer.link', 'https://mycompany.com');
$loginForm = \Builders\FormBuilder::create($this->model, $this->page)
->addField('username', 'string', ['label' => 'Username'])
->addField('password', 'password', ['label' => 'Password'])
->render();
Response::themePage('public', $loginForm);
}
Example 2: Minimalist Landing Page
#[RequestAction('home')]
public function landing() {
\App\Theme::set('public.header.title', 'Welcome to MyApp');
\App\Theme::set('public.header.description', 'The simple and powerful solution to manage your business');
\App\Theme::set('public.theme.bg-class', 'public-bg-soft-white');
\App\Theme::set('public.footer.text', 'MyApp - Made with ❤️ in Italy');
\App\Theme::set('public.footer.link', ''); // No link
$content = '
<div class="text-center">
<h2>Main Features</h2>
<p>Discover what makes MyApp special</p>
<a href="?page=register" class="btn btn-primary btn-lg">Get Started</a>
</div>
';
Response::themePage('public', $content);
}
Example 3: Contact Form
#[RequestAction('home')]
public function contact() {
\App\Theme::set('public.header.title', 'Contact Us');
\App\Theme::set('public.header.description', 'We\'ll be happy to answer your questions');
\App\Theme::set('public.theme.bg-class', 'public-bg-mint');
\App\Theme::set('public.header.title-color', '#047857'); // Dark green
$contactForm = \Builders\FormBuilder::create($this->model, $this->page)
->addField('name', 'string', ['label' => 'Name'])
->addField('email', 'email', ['label' => 'Email'])
->addField('message', 'text', ['label' => 'Message'])
->render();
Response::themePage('public', $contactForm);
}
Advanced Customization
Creating a Custom Background Class
If the predefined classes don't meet your needs, you can add custom classes in theme.css:
/* In theme.css */
.public-bg-custom-brand {
background: linear-gradient(135deg, #your-color-1 0%, #your-color-2 100%);
}
/* Or a solid color */
.public-bg-custom-corporate {
background: #f8f9fa;
}
Then use it in your module:
\App\Theme::set('public.theme.bg-class', 'public-bg-custom-brand');
Custom Logo
To use a different logo from the default:
\App\Theme::set('public.header.logo-path', THEME_URL.'/Assets/my-custom-logo.png');
Important Notes
Security:
- Make sure to properly configure
->access('public')in the module configuration if you want the page to be accessible without login - Always sanitize user-generated content before rendering it
- Use
_r()for outputting dynamic data in HTML
Responsive Design:
The public template is fully responsive and automatically adapts to mobile, tablet, and desktop devices.
See Also
- Theme Class - For more details on Theme::set() and Theme::get()
- Form Builder - To create forms for use in public pages
- Live Example - See the public template in action
Loading...