Custom templates

Post Reply
ctuxboy
Ssr. Bludit
Posts: 12
Joined: Sat Dec 15, 2018 11:37 pm

Hello,

Try understand how adding my own template pages:
- city.php
- province.php
-..

For testing add a new php-file in the active theme ../php dir:
city.php

In the dashboard, add new content and adding a template-name: city in the options-tab (se screenshot).
Schermafbeelding 2021-06-28 om 12.44.38.png
Schermafbeelding 2021-06-28 om 12.44.38.png (91.56 KiB) Viewed 238 times
Adding this code in index.php (and temporary remove the old code):

Code: Select all

switch ($WHERE_AM_I) {
			case 'page':
				if ($page->template()) {
					include(THEME_DIR_PHP.$page->template().'.php');
				} elseif($page->categoryTemplate()){
					include(THEME_DIR_PHP.$page->categoryTemplate().'.php');
				} else {
					include(THEME_DIR_PHP.'page.php');
				}
			break;
			default:
				include(THEME_DIR_PHP.'home.php');
			break;
		}
Based on this workaround: viewtopic.php?f=20&t=2000&p=9559&hilit=template#p9559.

But it doesn't work. Searching this forum, Github, but can't find a (small) and clear tutorial how using my own page-templates (not only 'home' and 'page').

Hope someone can give me a hint or help with this?
ctuxboy
Ssr. Bludit
Posts: 12
Joined: Sat Dec 15, 2018 11:37 pm

Found it!
If click 'Preview' then the custom template doesn't load!
But if you looking the 'complete' website, then it's works!
Is this an issue?
Post Reply