Page 2 of 3

Re: Custom template for the pages

Posted: Mon Sep 16, 2019 11:32 pm
by Torsten_Kelsch
Torsten_Kelsch wrote: Tue May 28, 2019 9:07 pm Nice workaround, but it would be better if editors could choose the template in the backend …
This is implemented in 3.9.2 (and perhaps in a few earlier minor versions).

Re: Custom template for the pages

Posted: Fri Dec 27, 2019 5:43 pm
by Carstenap
Torsten_Kelsch wrote: Mon Sep 16, 2019 11:32 pm
Torsten_Kelsch wrote: Tue May 28, 2019 9:07 pm Nice workaround, but it would be better if editors could choose the template in the backend …
This is implemented in 3.9.2 (and perhaps in a few earlier minor versions).
@torsten, could you please explain how to achieve this?

In backend under "options" i see the field for "template" but how do I choose my own new template so that it works?

I made a new file called "newpage.php" and put it in the folder PHP, but how do I actually get it to select this new php file template?

/Carsten - New member

Re: Custom template for the pages

Posted: Wed Jan 01, 2020 12:26 am
by Torsten_Kelsch
Manage > Content > Edit > Options > Advanced > Template
Verwalten > Inhalte > Bearbeiten > Einstellungen > Erweitert > Template

Re: Custom template for the pages

Posted: Thu Oct 29, 2020 1:06 pm
by puschmie
Torsten_Kelsch wrote: Wed Jan 01, 2020 12:26 am Manage > Content > Edit > Options > Advanced > Template
Verwalten > Inhalte > Bearbeiten > Einstellungen > Erweitert > Template
Could you maybe explain a little bit more? Is the template a template for a page? What should a template file look like? Should I save it in the php folder?
Thanks :)

Re: Custom template for the pages

Posted: Fri Oct 30, 2020 10:17 pm
by Torsten_Kelsch
@puschmie: Yes, it is a template file for pages, and it should look similar to those in your theme folder (/bl-themes/[theme-name]/php), and you can name it as you wish, let’s say special-page.php or whatever. Also see https://docs.bludit.com/en/themes/theme-basics.

Re: Custom template for the pages

Posted: Sat Oct 31, 2020 4:00 pm
by overcat
Hi and hello from Vienna. After trying various flat file CMS's, i've finally found BLUDIT and it is all i have been looking for. Thanks a lot for this!

I am now having issue with this new page template function - newest version fresh install.
So if i understand correctly, i shall

1 - create a template php file in my /bl-mytheme/php/ folder as
/bl-mytheme/php/my-static-page.php
with some content, or for starters i will just copy the page.php code with some markers to be able to distinguish it from the original :mrgreen:

2 - in backend, at page edit, i will enter the "my-static-page.php" in ->options -> template

Here, i've tried both
my-static-page.php
and
my-static-page

but neither seems to work. Am i omitting something?
I've checked the bl-content/databases/page.php and the template is being correctly written to the file, but obviously not used.
Thanks!
Danke und Grüße

Re: Custom template for the pages

Posted: Sat Oct 31, 2020 11:19 pm
by Edi
overcat wrote: Sat Oct 31, 2020 4:00 pm 2 - in backend, at page edit, i will enter the "my-static-page.php" in ->options -> template
This function does not work yet work.

The template is defined in the file index.php of the theme:

Code: Select all

<?php
   // $WHERE_AM_I variable detect where the user is browsing
   // If the user is watching a particular page/post the variable takes the value "page"
   // If the user is watching the frontpage the variable takes the value "home"
   if ($WHERE_AM_I == 'page') {
      include(THEME_DIR_PHP.'page.php');
   } else {
      include(THEME_DIR_PHP.'home.php');
   }
?>
Here you can add more conditions. For example:

Code: Select all

<?php
   if ($WHERE_AM_I == 'page') {
      if ($page->slug() == 'contact') {
         include(THEME_DIR_PHP.'contact.php');
      } else {
         include(THEME_DIR_PHP.'page.php');
      }
   } else {
   include(THEME_DIR_PHP.'home.php');
}
?>

Re: Custom template for the pages

Posted: Sun Nov 01, 2020 1:05 am
by Torsten_Kelsch
Edi wrote: Sat Oct 31, 2020 11:19 pm
overcat wrote: Sat Oct 31, 2020 4:00 pm 2 - in backend, at page edit, i will enter the "my-static-page.php" in ->options -> template
This function does not work yet
It does not work yet? I did not know that, because I have not tried it already, but I’m wondering why this option isn’t greyed out then.

Re: Custom template for the pages

Posted: Sun Nov 01, 2020 9:19 am
by overcat
Hi, thanks. That is one of the things which makes me like bludit - pure PHP and very logical. :)
Too bad, that there is a function which "undocumented does not work yet" - but thanks for clearing this out for me.

8-) The index.php way works fine and it would be enough ;)
(no bloated UI - the text version in index.php is manageable better anyway)

Re: Custom template for the pages

Posted: Wed Jul 14, 2021 6:15 pm
by bnetz
This function does not work yet work.
Now it's some months later - is it planned that this function is coming to life maybe in Bludit 4.x?
The recent solution is not really working for me because I want to use a special template for many pages. (Perhaps a solution could be to use the php-switch Edi described for a category, but I don't know how to implement this …)