Jump to content

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


ARG
 Share

Recommended Posts

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.

Link to comment
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.

Link to comment
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.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
On ‎2017‎-‎07‎-‎20 at 10:05 AM, SamC said:

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

This describes a kind of liberty ... (this is why I find Processwire so attractive).... but...
..''Is the technology an instrument of liberation or enslavement?'' 
You have four hours. GO !
Just joking :-)
Thank you for the answers: each of them open up the door a little more.

  • Like 2
Link to comment
Share on other sites

On 01/08/2017 at 1:42 AM, ARG said:

This describes a kind of liberty ... (this is why I find Processwire so attractive).... but...
..''Is the technology an instrument of liberation or enslavement?'' 
You have four hours. GO !
Just joking :-)
Thank you for the answers: each of them open up the door a little more.

Have some fun with it. There's no magic, it's all in the docs. Go to the docs, read, test, read some more, test again. This was a total boost for me at the beginning. The docs are excellent and explain a lot of things. For example, you could start here:

https://processwire.com/api/variables/pages/

What I'm saying is, the help pages link so well together that every time new questions are kicked up, the answer is just a few clicks away. And this forum is phenomenal for support. Stick with it, you'll be able to make some cool things in no time. Once you find a way that suits you in terms of organising your data in your site, the templates, fields etc... then it's just a matter of getting stuck into the docs to find a way to print these values to a webpage. Further in, you'll probably want to do some more complex things with the data, but deal with that when you get there.

  • Like 1
Link to comment
Share on other sites

1 hour ago, SamC said:

you'll be able to make some cool things in no time

Oh no ! Cool things need time to be done. The difference between mediocrity and quality, is, frequently, the addition of time to talent, and work. 
But I am patient...
Thank you again.

  • Like 2
Link to comment
Share on other sites

12 hours ago, SamC said:

Once you find a way that suits you in terms of organising your data in your site, the templates, fields etc...

Yep, it is worth spending the time on this stage, I 100% agree! This is the key to get to speed with ProcessWire based development.

  • 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

×
×
  • Create New...