Rodrigo Posted July 13, 2014 Report Share Posted July 13, 2014 (edited) 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.phpFind: 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 Edited July 27, 2015 by Rodrigo interfasys, Michael, PauloV and 3 others 6 Quote Link to comment Share on other sites More sharing options...
Michael Posted July 13, 2014 Report Share Posted July 13, 2014 WOW! Thanks mate that's like amazing Quote Link to comment Share on other sites More sharing options...
Rodrigo Posted July 13, 2014 Author Report Share Posted July 13, 2014 I made a mistake on the title, this should work on Blesta 3.2.1, don't know if it works for earlier versions. Quote Link to comment Share on other sites More sharing options...
PauloV Posted July 14, 2014 Report Share Posted July 14, 2014 Cool Quote Link to comment Share on other sites More sharing options...
serge Posted January 27, 2015 Report Share Posted January 27, 2015 Thank you, it's working fine!! I was now thinking how some page could only be available for a given blesta's company? Quote Link to comment Share on other sites More sharing options...
Paul Posted January 27, 2015 Report Share Posted January 27, 2015 Thank you, it's working fine!! I was now thinking how some page could only be available for a given blesta's company? I believe the company ID may be available, and a conditional could be created to display different content for different companies. I'll have to look into it, unless someone else knows? serge 1 Quote Link to comment Share on other sites More sharing options...
Michael Posted January 27, 2015 Report Share Posted January 27, 2015 I believe the company ID may be available, and a conditional could be created to display different content for different companies. I'll have to look into it, unless someone else knows? here mate: https://licensecart.com/plugin/support_manager/knowledgebase/view/189/company-id/12/ serge 1 Quote Link to comment Share on other sites More sharing options...
serge Posted January 27, 2015 Report Share Posted January 27, 2015 yes, thanks, I just found that before, I will be porting this code using that way Quote Link to comment Share on other sites More sharing options...
serge Posted January 27, 2015 Report Share Posted January 27, 2015 From Rodrigo hack, pages content are in plugins/cms/controller/main.php but from my test & in the idea to port this hack for using it in Blesta multi companies, From my test, I think this variable "$system_company->id" seem to do not have directly a value in such "general" file as not being in a view. Maybe in plugins/cms/controller/main.php , $system_company->id variable it should be set before in this function: public function preAction() { But I'm not enough skilled Quote Link to comment Share on other sites More sharing options...
serge Posted February 2, 2015 Report Share Posted February 2, 2015 The solution for that work with multi-company is : else { if ($this->company_id == "YOUR-COMPANY-ID") { switch($uri) { case 'page-x': SEE CONTENT HERE FROM ABOVE RODRIGO TUTORIAL case 'page-y': SEE CONTENT HERE FROM ABOVE RODRIGO TUTORIAL } } if ($this->company_id == "YOUR-OTHER-COMPANY-ID") { switch($uri) { case 'page-y1': SEE CONTENT HERE FROM ABOVE RODRIGO TUTORIAL case 'page-y2': SEE CONTENT HERE FROM ABOVE RODRIGO TUTORIAL } } } Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted February 8, 2015 Report Share Posted February 8, 2015 my next version of admin tools plugin , i have added option for cms portal , you can create/edit/delete page from cms without topucing any files in cms plugin . i have tested it and is working . serge and Michael 2 Quote Link to comment Share on other sites More sharing options...
serge Posted February 9, 2015 Report Share Posted February 9, 2015 Great Thank You! Just tested, and working fine. It's will be fine next version support these bellow custom, by page: <title>XXXXXXX</title><meta name="Description" content="XXXXXXXXXXX"><meta name="Geography" content="XXXXXXXX"><meta name="country" content="XXXXXXXX"><meta name="language" content="XXXXXXXXXXX"><meta name="publisher" content="XXXXXXXXXXXXX"><meta name="application-name" content="XXXXXXXXX"><meta name="identifier-url" content="XXXXXXXXXX"><meta property="og:title" content="XXXXXX" /><meta property="og:description" content="XXXXXXXXX" /><meta property="og:image" content="XXXXXXX" /><meta property="og:url" content="XXXXXXXXX" /> Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted February 9, 2015 Report Share Posted February 9, 2015 i have a idea to add it , but not sure if it work . serge 1 Quote Link to comment Share on other sites More sharing options...
serge Posted February 20, 2015 Report Share Posted February 20, 2015 There an issue in case of multi-companies, in one company non existing URL are not redirected to base_uri. http://www.blesta.com/forums/index.php?/topic/4158-cms-plugin-multicompanies-missing-redirection-for-non-existing-url/ As the company that had this bug in my case was a one page company (and no more page used), I fixed it that way, by adding this just just before the closing of " else { " at bottom, : ------------------------------------------------ if ($this->company_id == "2") {// REDIRECT TO BASE URI $this->redirect($this->base_uri);} } // END of "else" ----------------------------------------------- Quote Link to comment Share on other sites More sharing options...
Ken Ng Posted April 6, 2015 Report Share Posted April 6, 2015 Thanks for this! Any idea on how can we load alternative structure.pdt(Wanted try a different header design or can we get if page = 'custom page' then load it?) on different pages? Quote Link to comment Share on other sites More sharing options...
serge Posted April 6, 2015 Report Share Posted April 6, 2015 I think in structure.pdt you need to create condition . In my case my homepage content comme from blesta portal plugin (edited from blesta interface) and I created condition in structure.pdt to display metatag depending if it's the display of homepage or a custom page, so you could take inspiration of this to apply on header display at basing your condition on the page tittle. and your custom page title will be definited in /plugins/cms/controllers/main.php in structure.pdt: <?php if ($this->Html->ifSet($metatags)) { // CASE : NOT BEING HOMEPAGE // PAGE TITLE COME FROM CMS $title = (($page_title = (isset($page_title) ? $page_title : $this->_($page_title_lang, true, $get_params))) ? $this->Html->_($page_title, true) . " | " : "") . 'SiteShop . ph'; echo "<title>".$title."</title>"; // METATAGS IN ADITION TO ABOVE 2 (viewport & Content-Type"), COME FROM CUSTOM STATIC PAGE ADDED IN: /plugins/cms/controllers/main.php echo $this->Html->ifSet($metatags); } else { // CASE: HOMEPAGE, add missing metatags $metatags = " <title> xxxxxxxxxxxxxxxxxxxxxxx </title> <meta name=\"Description\" content=\"xxxxxxxxxxxxxxxx\"> <meta name=\"Geography\" content=\"xxxxxxxxxxx\"> <meta name=\"country\" content=\"xxxxxxxxxxx\"> <meta name=\"language\" content=\"xxxxxxxxxxxxxx\"> <meta name=\"publisher\" content=\"xxxxxxxxxxxxxxxxxx\"> <meta name=\"application-name\" content=\"xxxxxxxxx\"> <meta name=\"identifier-url\" content=\"http://xxxxxxxxxx\"> <meta property=\"og:title\" content=\"xxxxxxxxxxxxxxxxxxxx" /> <meta property=\"og:description\" content=\"xxxxxxxxxxxxxxx\" /> <meta property=\"og:image\" content=\"xxxxxxxxxxxxxxxxx.png\" /> <meta property=\"og:url\" content=\"http://xxxxxxxxxxxxxxx\" /> "; echo $metatags; } ?> in /plugins/cms/controllers/main.php at the ending of your given custom page: It's like above post, but it was missing common metatag VS only facebook metatag ("og: ) EOT; $metatags = <<<EOT <meta name="Description" content="xxxxxxxxx"> <meta name="Geography" content="vvvvvvvv"> <meta name="country" content="xxxxxxxxxxxx"> <meta name="language" content="xxxxxxxxxxxx"> <meta name="publisher" content="xxxxxxxxxxxxxxxxxxxx"> <meta name="application-name" content="xxxxxxxxxxxxxxxxx"> <meta property="og:title" content="Your Page Title" /> <meta property="og:description" content="xxxxxxxxxxxxxxxxx" /> <meta property="og:image" content="xxxxxxxxxxxxxxxxxxxxxxxxx" /> <meta property="og:url" content="{$blesta_url}xxxxxxxxxxxxxxxx" /> EOT; $this->structure->set("metatags" , $metatags); $this->set("content", $html); break; // default: $this->redirect($this->base_uri); Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted April 7, 2015 Report Share Posted April 7, 2015 Thanks for this! Any idea on how can we load alternative structure.pdt(Wanted try a different header design or can we get if page = 'custom page' then load it?) on different pages? You can . But you need to chabge the cms controller plugin . Quote Link to comment Share on other sites More sharing options...
Ken Ng Posted May 1, 2015 Report Share Posted May 1, 2015 Is this the best way to create static pages? Quote Link to comment Share on other sites More sharing options...
Michael Posted May 1, 2015 Report Share Posted May 1, 2015 Is this the best way to create static pages? The Admin Tools from Naja7Host is better. Quote Link to comment Share on other sites More sharing options...
Ken Ng Posted May 2, 2015 Report Share Posted May 2, 2015 I've installed admin tools and its a great tool. However in my case, I'm going to release themes for Blesta and not sure if this is the best solution for clients to install admin tool to use my theme. And if I don't use admin tools and make changes to main.php, I'm pretty sure client will mess up codes as well. Hope that blesta will implement a better custom static page on CMS soon. Quote Link to comment Share on other sites More sharing options...
serge Posted May 2, 2015 Report Share Posted May 2, 2015 yeah, I see your point Ken Ng 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.