Jump to content

File to append to template file


pwired
 Share

Recommended Posts

If in pw 2.5 I go to:

Admin => Setup => Templates => basic-page => Files => Append File

it says:

File to append to template file during page render. Must be relative to /site/templates/.

then there is a bar underneath where you can enter a path to a file to append ?

what is the format used to enter something in that bar ?

No matter what I enter in that bar and click on Save, nothing happens.

Instead of _main.php, I want to append _circle.php only to template file basic-page.php

Is that possible ? Is the idea behind it to let each template file have it´s own markup append file ?

Is this a replacement for header.inc and footer.inc or am I only wishful thinking ?

Link to comment
Share on other sites

It is correct to use template appending and prepending for your purposes. I use it to display my header and footer - it makes the code a little 'cleaner', as you do not need to manually import the files into a rendered template.

What version of PW are you using? I am using 2.5.0, and everything works as expected.

Link to comment
Share on other sites

Thanks for your replies.

Is site/config.php a global setting for all template files but you can do this

for each template file with

$config->prependTemplateFile = '_init.php'; 
$config
->appendTemplateFile = '_main.php';

Looks like some kind of initialising you can do in your template file ?

But in Admin => Setup => Templates => basic-page => Files => Append File

how do you enter something in that bar underneath

File to append to template file during page render. Must be relative to /site/templates/.

Link to comment
Share on other sites

No there are no errors but it seems no matter what I enter in that bar and click on save

nothing happens or changes.

Edit:

If I deliberately change the name _circle.php into _ccircle.php

it throws an error that the file does not exist,

so that is good news. Leaves me only how I can select

between _main.php and _circle.php

Link to comment
Share on other sites

Under the bar where you can enter the append file name it says:

Disable automatic append of file: _main.php

After entering my file _circle.php I expected to appear there:

Disable automatic append of file: _circle.php


I checked spelling in /site/templates/ and _circle.php is ok there

Link to comment
Share on other sites

The checkbox is only to disable the inclusion of the globaly set file. The one which is declared in your config.php. To disable the one you set on the template level you just remove it again from the field in the backend. The global "$config->appendTemplateFile" and the template specific field you're entering the filename are independent from each other. 

If you want to replace _main.php with _circle.php you disable the _main.php inclusion with the checkbox and add _circle.php in the field above. This way this template now skips the _main.php and includes _circle.php.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...