How To Create A Page
Cím
No changesPermalink
No changesTartalom
Old | New | ||
---|---|---|---|
1 | # How To Create A New Page | 1 | # How To Create A New Page |
2 | 2 | ||
3 | Creating a new page in LiteCart is pretty simple. Basically just place a | 3 | 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. |
4 | file in the pages folder and name it name.inc.php. The .inc in the | 4 | |
5 | extension prevents the file from being executed alone. The .php in the | 5 | ```php pages/mypage.inc.php |
6 | extension tells us this is PHP logic. | 6 | <?php |
7 | 7 | document::$snippets['title'][] = 'Your head title here'; | |
8 | ```php pages/mypage.inc.php | 8 | document::$snippets['description'] = 'Your meta description here'; |
9 | 9 | ?> | |
10 | Hello World | 10 | <h1>Hello World</h1> |
11 | 11 | <p>Lorem ipsum dolor...</p> | |
12 | Lorem ipsum dolor... | 12 | ``` |
13 | ``` | 13 | |
14 | 14 | The page is then accessed by http://www.yourdomain.com/mypage | |
15 | The page is then accessed by | 15 | |
16 | 16 | ## How To Create A New Page Using A View | |
17 | # How To Create A New Page Using A View | 17 | |
18 | 18 | 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. | |
19 | The look or layout of pages is usually unique to each and every | 19 | |
20 | template. That's when separating HTML from the PHP logic comes in | 20 | This is how simple it is to create a new page that can be uniquely styled within each template: |
21 | handy. | 21 | |
22 | 22 | ```php pages/mypage.inc.php | |
23 | This is how simple it is to create a new page that can be uniquely | 23 | <?php |
24 | styled within each template: | 24 | |
25 | 25 | document::$layout = 'default'; // Uses includes/templates/...catalog/layouts/default.inc.php to wrap the content of the page | |
26 | ```php pages/mypage.inc.php | 26 | |
27 | 27 | document::$snippets['title'][] = 'Your head title here'; | |
28 | 28 | document::$snippets['description'] = 'Your meta description here'; | |
29 | 29 | ||
30 | ``` | 30 | $_mypage = new ent_view(); |
31 | 31 | ||
32 | # See Also | 32 | $_mypage->snippets = [ |
33 | 33 | 'title' => 'Hello World', | |
34 | [How To Create A View](how_to_create_a_view) | 34 | 'content' => 'Lorem ipsum dolor', |
35 | ]; | ||
36 | |||
37 | echo $_mypage->stitch('pages/mypage'); // Uses includes/templates/...catalog/pages/mypage.inc.php for content | ||
38 | ``` | ||
39 | |||
40 | Here is an example of a template view file: | ||
41 | |||
42 | ```php includes/templates/mytemplate.catalog/pages/mypage.inc.php | ||
43 | <main id="content"> | ||
44 | <h1><?php echo $title; ?></h1> | ||
45 | <p><?php echo $content; ?></p> | ||
46 | </main> | ||
47 | ``` | ||
48 | |||
49 | ## See Also | ||
50 | |||
51 | * [How To Create A View](how_to_create_a_view) |
Edited by tim on 28 dec. 2023 at 06:12