User Tools

  • (Use the same account as the official website)

Site Tools


how_to_create_a_page

How To Create A New Page

Creating a new page in LiteCart is pretty simple. Basically just place a file in the pages folder and name it name.inc.php. The .inc in the extension prevents the file from being executed alone. The .php in the extension tells us this is PHP logic.

pages/mypage.inc.php
<?php
  document::$snippets['title'][] = 'Your head title here';
  document::$snippets['description'] = 'Your meta description here';
?>
<h1>Hello World</h1>
<p>Lorem ipsum dolor...</p>

The page is then accessed by http://www.yourdomain.com/mypage

How To Create A New Page Using A View

The look or layout of pages is usually unique to each and every template. That's when separating HTML from the PHP logic comes in handy.

This is how simple it is to create a new page that can be uniquely styled within each template:

pages/mypage.inc.php
<?php
 
  document::$layout = 'default'; // Uses includes/templates/...catalog/layouts/default.inc.php for to wrap the content of the page
 
  document::$snippets['title'][] = 'Your head title here';
  document::$snippets['description'] = 'Your meta description here';
 
  $_mypage = new ent_view();
 
  $_mypage->snippets = array(
    'title' => 'Hello World',
    'content' => 'Lorem ipsum dolor',
  );
 
  echo $_mypage->stitch('pages/mypage');  // Uses includes/templates/...catalog/pages/mypage.inc.php for content

Here is an example of a template view file:

includes/templates/mytemplate.catalog/pages/mypage.inc.php
<main id="content">
  <h1><?php echo $title; ?></h1>
  <p><?php echo $content; ?></p>
</main>

See Also

how_to_create_a_page.txt · Last modified: 2023/01/16 16:23 by s22_tech