Jump to content

Create Static Pages


compositor

Recommended Posts

I thought this may be the most appropriate place to post, i.e. not related to an extension.

I've been reading here:

added the code, but of course I have no understanding of what to do next.

From what I can gather, this person has created files linked from the main page, e.g. examplehost/billing so that an index page can be defined for examplehost

If anyone can give me information on how to do this it would be endlessly appreciated as it is one of the reasons I am thinking of investing in the platform.

Link to comment
Share on other sites

I take it if you modify the core plugin you need to add more of these below the first section and change the content.

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;

But remember that it will be overwritten with a new version or a patch if the portal plugin has been updated. 

Link to comment
Share on other sites

This is the code I have for the main.pdt file:

<?php
/**
 * CMS main controller
 * 
 * @package blesta
 * @subpackage blesta.plugins.cms.controllers
 * @copyright Copyright (c) 2010, Phillips Data, Inc.
 * @license http://www.blesta.com/license/ The Blesta License Agreement
 * @link http://www.blesta.com/ Blesta
 */
class Main extends CmsController {
	
	/**
	 * Pre-action
	 */
	public function preAction() {
		parent::preAction();
		
		$this->uses(array("PluginManager", "Cms.CmsPages"));
		
		// Redirect if this plugin is not installed for this company
		if (!$this->PluginManager->isInstalled("cms", $this->company_id))
			$this->redirect($this->client_uri);
		
		// Use the same structure as that of the client portal for the company given
		$this->structure->setDefaultView(APPDIR);
		$this->structure->setView(null, "client" . DS . $this->layout);
		$this->structure->set("custom_head",
			"<link href=\"" . Router::makeURI(str_replace("index.php/", "", WEBDIR) . $this->view->view_path) . "views/" . $this->view->view . "/css/styles.css\" rel=\"stylesheet\" type=\"text/css\" />"
		);
		
		$this->base_uri = WEBDIR;
		$this->view->base_uri = $this->base_uri;
		$this->structure->base_uri = $this->base_uri;
		
		// Set the client info
		if ($this->Session->read("blesta_client_id")) {
			$this->client = $this->Clients->get($this->Session->read("blesta_client_id"));
			$this->view->set("client", $this->client);
			$this->structure->set("client", $this->client);
		}
	}
	
	/**
	 * Portal/CMS index
	 */
	public function index() {
		$uri = "/";
		if (isset($this->get[0]))
			$uri = $this->get[0];
		
		$this->uses(array("Cms.CmsPages", "PluginManager"));
		
		// Load the template parser
		Loader::load(VENDORDIR . "h2o" . DS . "h2o.php");
		$parser_options_html = Configure::get("Blesta.parser_options");
		// Don't escape html
		$parser_options_html['autoescape'] = false;
		
		// Check if the page exists
		if (($page = $this->CmsPages->get($uri, $this->company_id))) {
			// Get installed plugins
			$plugins = $this->PluginManager->getAll($this->company_id);
			$installed_plugins = array();
			foreach ($plugins as $plugin)
				$installed_plugins[$plugin->dir] = $plugin;
			
			// Set page content
			$url = rtrim($this->base_url, "/");
			
			$tags = array(
				'base_url' => $this->Html->safe($url),
				'blesta_url' => $this->Html->safe($url . WEBDIR),
				'client_url' => $this->Html->safe($url . $this->client_uri),
				'admin_url' => $this->Html->safe($url . $this->admin_uri),
				'plugins' => $installed_plugins
			);
			
			$page->content = H2o::parseString($page->content, $parser_options_html)->render($tags);
			
			$this->set("content", $page->content);
			$this->structure->set("page_title", $page->title);
			$this->structure->set("title", $page->title);
		}
		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;
                            $metatags = <<<EOT
<meta property="og:title" content="Examplehost"/>
<meta property="og:description" content="Web Design and Development Services"/>
<meta property="og:image" content="https://examplehost.net.au/images/"/>
<meta property="og:url" content="https://examplehost.net.au/billing"/>
 
 
EOT;
                            $this->structure->set("metatags" , $metatags);$this->set("content", $html);
                            break;
							default:
							$this->redirect($this->base_uri);
                        } 
}
	}
}
?>

and this for structure.pdt

<!DOCTYPE html>
<html dir="<?php echo (in_array($this->_("AppController.lang.dir", true), array("ltr", "rtl")) ? $this->_("AppController.lang.dir", true) : "ltr");?>">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title><?php echo $this->Html->safe(($this->Html->ifSet($page_title) ? $page_title . " | " : "") . $this->Html->ifSet($system_company->name));?></title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<?php echo $this->Html->ifSet($metatags) ?>
		<link rel="shortcut icon" href="<?php echo $this->view_dir;?>images/favicon.ico" />
		
		<link href="<?php echo $this->view_dir;?>css/bootstrap.min.css" rel="stylesheet" type="text/css" />
		<link href="<?php echo $this->view_dir;?>css/styles.css" rel="stylesheet" type="text/css" />
		<link href="<?php echo $this->view_dir;?>css/slider.css" rel="stylesheet" type="text/css" />
		<?php
		// Theme CSS
		if (isset($theme_css)) {
		?>
		<link href="<?php $this->Html->_($theme_css);?>" rel="stylesheet" type="text/css" media="screen" />
		<?php
		}
        if ($this->_("AppController.lang.dir", true) == "rtl") {
        ?>
        <link href="<?php echo $this->view_dir;?>css/rtl.css" rel="stylesheet" type="text/css" media="screen" />
        <?php
        }
		?>
		<link href="<?php echo $this->view_dir;?>font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
		
		<script type="text/javascript" src="<?php echo $this->view_dir;?>javascript/jquery.min.js"></script>
		<script type="text/javascript" src="<?php echo $this->view_dir;?>javascript/bootstrap.min.js"></script>
		<!--[if lt IE 10]><script type="text/javascript" src="<?php echo $this->view_dir;?>javascript/history/json2.js"></script><![endif]-->
		<script type="text/javascript" src="<?php echo $this->view_dir;?>javascript/history/history.adapter.jquery.js"></script>
		<script type="text/javascript" src="<?php echo $this->view_dir;?>javascript/history/history.js"></script>
		<!--[if lt IE 10]><script type="text/javascript" src="<?php echo $this->view_dir;?>javascript/history/history.html4.js"></script><![endif]-->
		<script type="text/javascript" src="<?php echo $this->view_dir;?>javascript/jquery-client-3.5.0.js"></script>
		
		<?php
		echo $this->Javascript->getFiles("head");
		echo $this->Html->ifSet($custom_head);
		?>
		
		<!--[if lt IE 9]>
			<script src="<?php echo $this->view_dir;?>javascript/html5shiv.js" type="text/javascript"></script>
			<script src="<?php echo $this->view_dir;?>javascript/respond.min.js" type="text/javascript"></script>
		<![endif]-->
		<?php echo $this->Html->ifSet($head);?>
    </head>
    <body>
		<?php echo $this->Html->ifSet($body_start);?>
		<?php
		if ($this->Html->ifSet($show_header, true)) {
		?>
		<div class="header">
			<div class="container">
				<div class="logo">
					<a href="<?php echo $this->Html->safe($this->base_uri);?>">
						<?php
						if (!empty($theme_logo)) {
						?>
							<img src="<?php $this->Html->_($theme_logo);?>" alt="Logo" />
						<?php
						}
						elseif (!empty($blesta_logo)) {
						?>
							<img src="<?php $this->Html->_($blesta_logo);?>" alt="Blesta" />
						<?php
						}
						else {
						?>
							<img src="<?php echo $this->view_dir;?>images/logo.png" alt="Blesta" />
						<?php
						}
						?>
					</a>
				</div>
				<?php
				if ($this->Html->ifSet($staff_as_client)) {
				?>
				<span class="label label-info pull-right"><a href="<?php echo $this->Html->safe($this->admin_uri . "clients/logoutasclient/");?>"><span class="fa fa-info-circle"></span> <?php $this->_("AppController.client_structure.staff_as_client_note");?></a></span>
				<?php
				}
				?>
			</div>
		</div>
		<div class="title">
			<div class="container">
				<h3><?php echo ($this->Html->ifSet($title) ? $this->Html->_($title, true) : $this->_("AppController.client_structure.default_title", true));?></h3>
			</div>
		</div>
		<?php
			if (!$this->Html->ifSet($logged_in)) {
		?>
		<div class="clearfix"></div>
		<div class="no-nav"></div>
		<?php
			}
			else {
		?>
		<div class="nav-content">
			<div class="nav">
				<nav class="navbar navbar-default" role="navigation">
					<div class="navbar-header">
						<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
							<span class="sr-only"><?php $this->_("AppController.sreader.navigation");?></span>
							<span class="icon-bar"></span>
							<span class="icon-bar"></span>
							<span class="icon-bar"></span>
						</button>
					</div>
					
					<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
						<div class="container">
							<?php
							$active_nav = null;
							?>
							<ul class="nav navbar-nav">
								<?php
								foreach ($this->Html->ifSet($nav, array()) as $link => $value) {
									$attributes = array();
									$link_attributes = array();
									$dropdown = !empty($value['sub']);
									$active = false;
									
									if ($value['active']) {
										$active = true;
										$attributes['class'][] = "active";
										$active_nav = $value;
									}
									if ($dropdown) {
										$attributes['class'][] = "dropdown";
										$link_attributes['class'][] = "dropdown-toggle";
										$link_attributes['data-toggle'][] = "dropdown";
										
										// Set parent to active if child is
										if (!$active) {
											foreach ($this->Html->ifSet($value['sub'], array()) as $sub_link => $sub_value) {
												if ($sub_value['active']) {
													$attributes['class'][] = "active";
													break;
												}
											}
										}
									}
								?>
								<li<?php echo $this->Html->buildAttributes($attributes);?>>
									<a href="<?php $this->Html->_($link);?>"<?php echo $this->Html->buildAttributes($link_attributes);?>>
										<i class="<?php $this->Html->_($value['icon']);?>"></i> 
										<?php
										$this->Html->_($value['name']);
										
										if ($dropdown) {
										?>
										<b class="caret"></b>
										<?php
										}
										?>
									</a>
									<?php
									if (!empty($value['sub'])) {
									?>
									<ul class="dropdown-menu">
										<?php
										foreach ($this->Html->ifSet($value['sub'], array()) as $sub_link => $sub_value) {
										?>
										<li>
											<a href="<?php $this->Html->_($sub_link);?>"><i class="<?php $this->Html->_($sub_value['icon']);?>"></i> <?php $this->Html->_($sub_value['name']);?></a>
										</li>
										<?php
										}
										?>
									</ul>
									<?php
									}
									?>
								</li>
								<?php
								}
								?>
							</ul>
							
							<ul class="nav navbar-nav navbar-right">
								<li class="dropdown">
									<a href="#" class="dropdown-toggle" data-toggle="dropdown">
										<?php $this->Html->_($contact->first_name);?> <?php $this->Html->_($contact->last_name);?>
										<b class="caret"></b>
									</a>
									<ul class="dropdown-menu">
										<li><a href="<?php echo $this->Html->safe($this->client_uri . "main/edit/");?>"><i class="fa fa-edit fa-fw"></i> <?php $this->_("AppController.client_structure.text_update_account");?></a></li>
										<?php
										if ($this->Html->ifSet($portal_installed, false)) {
										?>
										<li><a href="<?php echo $this->Html->safe(WEBDIR);?>"><i class="fa fa-circle-o fa-fw"></i> <?php $this->_("AppController.client_structure.text_return_to_portal");?></a></li>
										<?php
										}
										?>
										<li class="divider"></li>
										<li><a href="<?php echo $this->Html->safe($this->client_uri . "logout/");?>"><i class="fa fa-sign-out fa-fw"></i> <?php $this->_("AppController.client_structure.text_logout");?></a></li>
									</ul>
								</li>
							</ul>
						</div>
					</div><!-- /.navbar-collapse -->
				</nav>
			</div>
		</div>
		<?php
			}
		}
		?>
		
		<!-- Begin Content -->
		<div class="container">
			<div class="row<?php echo (!$this->Html->ifSet($show_header, true) ? " login" : "");?>">
				<?php
				if (!empty($active_nav['secondary'])) {
				?>
					<div class="col-md-3">
						<div class="list-group">
							<?php
							foreach ($active_nav['secondary'] as $link => $value) {
							?>
								<a href="<?php $this->Html->_($link);?>" class="list-group-item left-nav <?php echo ($value['active'] ? "active" : "");?>">
									<i class="<?php $this->Html->_($value['icon']);?>"></i> 
									<?php
									$this->Html->_($value['name']);
									?>
								</a>
							<?php
							}
							?>
						</div>
					</div>
					<div class="col-md-9">
						<div class="row">
							<?php echo $content;?>
						</div>
					</div>
				<?php
				}
				else {
					echo $content;
				}
				?>
			</div>
			<div class="row footer">
				<div class="col-md-12">
					<hr />
					<p class="text-center">Powered by <a href="http://www.blesta.com/">Blesta</a>, &copy; Phillips Data, Inc.</p>
				</div>
			</div>
		</div>
		
		<div class="modal fade" id="global_modal" tabindex="-1" role="dialog" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="global_modal_title"></h4>
					</div>
					<div class="modal-body"><i class="fa fa-spinner fa-spin"></i></div>
					<div class="modal-footer"></div>
				</div>
			</div>
		</div>
        
		<?php echo $this->Javascript->getFiles("body");?>
		<?php echo $this->Javascript->getInline();?>
		<?php echo $this->Html->ifSet($body_end);?>
    </body>
</html>

What I don't know of course is how to reference these files in order to create a static page.

I am fine with having Powered By in the footer so is that all I'd need to have for a branded service?

At some point I would like to have a fully blank slate so I can copy HTML generated from my CMS into these templates, which I am guessing is the best way to go to begin with rather than introduce server code from another CMS.

Link to comment
Share on other sites

30 minutes ago, Blesta Addons said:

you can use Admin Tools plugin to add pages to your cms portal with a simple click .

 

Hi and thank you for responding.

Can those pages exist outside of the Blesta Directory and would they include all but the branding in the footer or is there some other branding (required or not) I'm not aware of?

I look forward to your replying.

Link to comment
Share on other sites

13 hours ago, compositor said:

So I gather there is technically no way to do what I'm asking then?

I'm not sure what you are trying to do? Are you trying to do a Adobe dreamweaver where you make the pages and it's just static in the end? then you want Hugo or dreamweaver. The ones above are using Blesta for your website aka licensecart.com that is Blesta. Every page on my site is blesta.

Link to comment
Share on other sites

11 minutes ago, compositor said:

From what I can gather, so-called static pages can only be generated in the same directory as where Blesta is installed, whereas I am wanting to have them separate so I can use Blesta as a CMS as well as a billing system but billing only occur in /billing and not the / directory

You can change the client route to billing if that helps. But none that I know generate static files. Give it a spin? /config/routes.php and change client to billing.

Link to comment
Share on other sites

19 minutes ago, compositor said:

Hi Michael,

I looked at the kb for that:

https://docs.blesta.com/display/user/Installing+Blesta

but it won't get me one level up from the installation directory.

If only there was a way, I'd be signing up today.

You can move the files up one, Paul stated you can but it will require a re-issue. If you sign up that would be all you need :). And as for the routes. You just change this file: /config/routes.php and change:

/**
 * Client panel directory name
 */
Configure::set("Route.client", "client");

to

/**
 * Client panel directory name
 */
Configure::set("Route.client", "billing");

 

Link to comment
Share on other sites

Hi Michael,

I just did that and now I get: examplehost/billing/billing/login so I gather that if I have the installation location as / I will then have my clients logging in via /billing/login while everyone would be accessing the "site" via /

I did it for admin as well:

Configure::set("Route.admin", "billing");

That sounds better, I was merely using the recommended settings but would physically moving the installation files to the root require a license re-issue?

I think you'd said in another post:

this would be fine but with Pauls' graciousness I'd say he would allow me to restart my trial.

Cheers

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...