pwired Posted September 20, 2014 Share Posted September 20, 2014 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 More sharing options...
Mike Rockett Posted September 20, 2014 Share Posted September 20, 2014 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 More sharing options...
LostKobrakai Posted September 20, 2014 Share Posted September 20, 2014 It should be the template specific form of this. If you use one of those in your config, you can also disable the global setting to just use the template specific one. $config->prependTemplateFile = '_init.php'; $config->appendTemplateFile = '_main.php'; Link to comment Share on other sites More sharing options...
pwired Posted September 20, 2014 Author Share Posted September 20, 2014 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 More sharing options...
LostKobrakai Posted September 20, 2014 Share Posted September 20, 2014 Haven't tried it but just like in the config? _side.php includes/something.php So in you're case "_circle.php" should work if it's directly in the templates folder. Link to comment Share on other sites More sharing options...
pwired Posted September 20, 2014 Author Share Posted September 20, 2014 So in you're case "_circle.php" should work if it's directly in the templates folder. I tried exactly that but did not work. Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 20, 2014 Share Posted September 20, 2014 Any errors with debug on? I just tried it on 2.5.0 and it's working as expected. Are you sure, that your file is in site/templates/ and no further subfolder and it's named _circle.php not circle.php? Could just be a typo. Link to comment Share on other sites More sharing options...
pwired Posted September 20, 2014 Author Share Posted September 20, 2014 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 More sharing options...
LostKobrakai Posted September 20, 2014 Share Posted September 20, 2014 If there's no file found, nothing can be included while template rendering, so nothing changes. That's why I asked for potential spelling issues in the filename. Link to comment Share on other sites More sharing options...
pwired Posted September 20, 2014 Author Share Posted September 20, 2014 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 More sharing options...
LostKobrakai Posted September 20, 2014 Share Posted September 20, 2014 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. 1 Link to comment Share on other sites More sharing options...
pwired Posted September 20, 2014 Author Share Posted September 20, 2014 Thanks LostKobrakai that makes a lot of sense. I guess what you enter in config.php will show up as Disable automatic append of file: _yourfile.php Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 20, 2014 Share Posted September 20, 2014 Exactly, the checkbox does in fact only show up, if there is a file defined in the config.php. 1 Link to comment Share on other sites More sharing options...
pwired Posted September 20, 2014 Author Share Posted September 20, 2014 Where to find more about $config->prependTemplateFile = '_init.php'; $config->appendTemplateFile = '_main.php'; Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 20, 2014 Share Posted September 20, 2014 http://processwire.com/docs/tutorials/how-to-structure-your-template-files/page3 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now