ARG

Template associated to an _include.php page: possible???

5 posts in this topic

Hello. Sorry in advance for the super basic question, from a total begginer: 
-when I want to create a new template in the admin, I have to create firstly a ''new.php'' page in the site/template folder. 
-Is it possible to do the same in an ''_new-include-some-page.php''  in the site/template/include folder?
I was thinking to a solution: removing the Include folder, and put all the .php pages in the template folder.
But, I am sure I am missing something, and other solutions exist.
An advice?
Thank you for your time.

Share this post


Link to post
Share on other sites

yes it is doable

however, you don't have to create a file anytime you create a new template in admin. you create a template file if you want to 'view' the page using that template

2 people like this

Share this post


Link to post
Share on other sites

Doable? 
Ok. I probably missed something.
I will digg deeper in the doc.
Thank you monchu.

Share this post


Link to post
Share on other sites

Not sure I'm getting exactly what you want to do.

You can specify a different file for a template. Edit your template and in the Files tab, look for "Alternate Template Filename". I've never tried pointing to a subdirectory there, but don't see a reason for it not to work.

You can, as monchu stated, simply not create the file. I use file-less templates all the time, whenever the frontend doesn't require an actual page to exist.

Share this post


Link to post
Share on other sites

I do something like this, see the 'includes' and 'views' folders. I find it easier structured like this but you can do it any way you like :)

structure.thumb.png.f999441737ad55fe3659bbf13c2f5018.png

I set templates to 'main' in the alternate template section:

alt-template-filename.thumb.PNG.153cc344e875ae8b7858068f9c64d94c.PNG

...then once you've created a page using the 'about' template (created in the admin), when you visit 'site.com/about', main is used to output the contents of 'views/about.php' and a couple of includes:

// main.php

<?php namespace ProcessWire; ?>
<html>
<head></head>
<body>
    <?php include("./includes/_header" . ".php"); ?>
    <?php include("./views/{$page->template->name}" . ".php"); ?>
    <?php include("./includes/_footer" . ".php"); ?>   
</body>
</html>

I never got used to the delayed output. I like the simplicity of this approach.

This is just one of the many ways you can do things in PW, experiment, have fun :) hope this helps.

1 person likes this

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By louisstephens
      I wasn't quite sure where to post this, as this is a question regarding the module (sorry if it is in the wrong place). I was wondering if anyone has used the Email to Page module and figured out a way to "move" incoming css to another field, or how to render the css so the message just renders utilizing the css. 
      Right now all of the message contents get dropped into a textarea field and display in a template as a jumbled mess. Perhaps I am missing a formatting option in the text area field to render the css and html.
    • By Sipho
      I wish to access a template's allowed templates for it's children from the API. This one:

      I am pretty sure this is possible, but I can't seem to find it anywhere in the documentation. If this is not possible, is there some way of assigning properties to templates? So like fields that already have a value on all pages using that template.
    • By nusu
      My site works very well until today I fill a bunch of multilanguage fields than suddenly it start to this.
      I can't reach any page, everything gives 500 error.
      and log is:
      2017-07-12 09:33:56    guest   Error:     Class 'Twig_Loader_Filesystem' not found (line 338 of /home/petform/public_html/site/modules/TemplateTwigReplace/TemplateTwigReplace.module)
      How can I fix this?
       
    • By didhavn
      Hey everbody.

      I wanted to share something I have been working for quite some time, in total currently three premium Templates or Site-Profiles for ProcessWire 3 including a onepage template, a blog template and a blog+sidebar template.
       
      Here are some Quick Facts:
      Fully responsive Multilanguage support Full SEO support Optional Google Analytics Easily create new pages out of multiple predefined sections Lazyload the sections of a page [Group and update website-information into blogs] (blog, blog+sidebar) [Use tags to tag and group blog entries] (blog, blog+sidebar) [Create each page with or without sidebar] (blog+sidebar) Website-wide search by text or tags Password protect each page individually with sophisticated page-encryption with dummy texts and pixelated images
      Just go to https://pwtemplates.de to test the demos and purchase them for a small expense allowance.

      Hope you like it!
    • By psy
      I am using regions with the tag <region id="whatever"> in the _main.php file. Config file is set up as follows:
      $config->useMarkupRegions = true; $config->prependTemplateFile = '_init.php'; $config->appendTemplateFile = '_main.php'; When I use a page template that changes a region, all goes well. However, I set up the _main.php file to reflect the output for a basic page. The basic-page.php template needed no customisation so was simply as follows:
      <?php namespace ProcessWire; ?> When a page with the basic-page template was output, all the <region> tags remained in the HTML, ie were not stripped.
      When I added a customised region to the basic-page.php template, all the <region> tags were stripped from the output _main.php HTML.
      Did I do something wrong or is this a bug?
      Using ProcessWire 3.0.63 © 2017