User Tools

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 are usually unique to each and every template. That's when separating HTML from the PHP logic becomes 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::$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');
?>

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: 2022/01/08 23:27 by tim