Hi, I'm sharing a quick method for making custom static pages in blest system without any additional plugin. Please consider that any future update would require to take care of the changes made as they can be erased. In this example I'll be doing a static page that will be located in your_blesta_location.com/services
1.1 Creating a static page with custom HTML 1. Open plugins/cms/controller/main.php Find:
else {
$this->redirect($this->base_uri);
}
Replace for:
else {
switch($uri) {
case 'services':
$this->structure->set("page_title", "*** INSERT PAGE TITLE ***");
$this->structure->set("title", "*** INSERT TITLE SHOWN ON PORTAL TEMPLATE ***");
// Placeholders won't work with this method, so let's use variables
$url = rtrim($this->base_url, "/");
$blesta_url = $this->Html->safe($url . WEBDIR);
$html = <<<EOT
<div class="col-md-4 col-sm-6 portal-box">
<a href="{$blesta_url}services>
<div class="well">
<i class="fa fa-cogs fa-4x"></i>
<h4>Foo</h4>
<p>Bar.</p>
</div>
</a>
</div>
EOT;
$this->set("content", $html);
break;
default:
$this->redirect($this->base_uri);
}
}
You can repeat the php case for making all the static pages you want, putting HTML between the EOT marks (There should be no space or characters after EOT; mark). If you don't like the broken indentation you can try another methods for doing multi line strings in PHP, but I think using nowdoc is more easy when you need to insert html.
1.2 Adding custom meta tags to the new static page (optional)
1. Open plugins/cms/controller/main.php
Find
$this->set("content", $html);
Add Before:
$metatags = <<<EOT
<meta property="og:title" content="foo"/>
<meta property="og:description" content="bar."/>
<meta property="og:image" content="baz"/>
<meta property="og:url" content="http://www.example.com/services"/>
EOT;
$this->structure->set("metatags" , $metatags);
2. Open /app/views/client/bootstrap/structure.pdt (or in your own template)
Find
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Add after
<?php echo $this->Html->ifSet($metatags) ?>
Dev note: this could be easier if could find a way to get structure protected property values, then concat the metatags to an existing variable like $custom_head (Is there a method like $this->structure->get()?)
Also, don't forget that the Portal plugin is being developed for being a fully functional CMS system, so this would not be needed in the future.
Here is my result, I'm linking this custom static page from the blesta portal main page for linking to different order pages (currently in design and module coding process, blesta flexibility is awesome)
Result:
Setting what Facebook shows by modifying meta tags
I hope somebody finds this useful
Bye
EDIT: fixed a detail in $url definition
EDIT2: Added how to add custom html into <head>
EDIT3. Confirming that this still works for Blesta 3.5.1