Goca Posted June 18, 2021 Share Posted June 18, 2021 Hi there! I'm very new to ProcessWire, just found the system about a month ago and have been toying around with it a bit, and I'm loving everything I'm seeing! I'm coming over from the Concrete5 CMS, which I've been working with for 10 years, and one of the primary things that's so alluring to me about this CMS / Framework is that it doesn't try to get in your way. It seems like it's very much built with the mentality of providing the tools to build what you need, rather than forcing you to work around systems built for a specific purpose, and along with that, it seems like the community is incredibly helpful and friendly, which is always a big plus! One of the concepts that I'm used to from Concrete5 is the concept of Single Pages - one-off pages that are made for a specific purpose, and all of its code is self-contained, rather than part of a reusable templates. I am currently building a system that somewhat resembles an LMS - essentially needing Students, Student Records, quizzes / tests, and answers to them for each student record. The perfect example for my case is a user dashboard, to be able to view current tasks, know where to go next, etc. which won't be re-used anywhere else except on one page. From what I'm seeing with ProcessWire, it seems the base concept is that if you want a page to display on the front end of the site, it needs a .php template in the /site/templates/ directory, and even if the template is used in multiple pages, or only one, it makes no difference, and this is where it would / should go. Am I correct in this thinking? I want to make sure that as I learn ProcessWire, I get used to the standards and best practices that people have come up with, and I'm sure there's an answer to this somewhere already that I possibly overlooked, but I wasn't able to find it. Any insight on this would be much appreciated! Thanks! 4 Link to comment Share on other sites More sharing options...
virtualgadjo Posted June 19, 2021 Share Posted June 19, 2021 Hi, you're right, if you want a page to be displayed on the front end it needs a .php template (be this template used by one or several pages) the reason is very simple, this template is used to "echo" the content you want to see, surrounded by your html markup you'll see that pw allows several ways in the coding field and as you said, doesn't get in your way, actually, it behaves a lot like a framework offering multiple template systems have a nice day Link to comment Share on other sites More sharing options...
BillH Posted June 19, 2021 Share Posted June 19, 2021 Hi @Goca and welcome to the forums! There's a useful description of how templates work at https://processwire.com/docs/start/templates/ Don't miss the link to the pages about output strategies in the 'Next steps' section at the end. Note that if you'll have a lot of pages where each needs a slightly different template, you may find that the best approach is for them to share a template containing a little conditional logic, for example: if($page->name == 'page1') { // Display something } elseif($page->name == 'page2') { // Display something else } elseif... 1 Link to comment Share on other sites More sharing options...
BillH Posted June 20, 2021 Share Posted June 20, 2021 And another thought: consider using URL segments as described at https://processwire.com/docs/front-end/how-to-use-url-segments/. Link to comment Share on other sites More sharing options...
elabx Posted June 21, 2021 Share Posted June 21, 2021 On 6/18/2021 at 4:00 PM, Goca said: Am I correct in this thinking? I'd say you are, basically it's your decision to just use a template that is just used by one page, that render a specific file and that's it. You can even prohibit the template from being used more than once under the template's Family settings. Link to comment Share on other sites More sharing options...
bernhard Posted June 22, 2021 Share Posted June 22, 2021 Hi @Goca welcome to the forum ? There's nothing wrong about creating a template that is only used for one single page. On the contrary. We even have a setting for that in the template's settings: As alternative to what the others have already said you can also use URL hooks that we have since 3.0.173: https://processwire.com/blog/posts/pw-3.0.173/ Note that when using url hooks you need to take care of access control yourself while when creating a template file you can use PW's access control system from the backend ? Link to comment Share on other sites More sharing options...
Goca Posted June 23, 2021 Author Share Posted June 23, 2021 Thank you all for your answers and insight! The more I look at ProcessWire the more I like what I see, and I appreciate you all clearing up my question for me. I'm looking forward to continue experimenting with this system, but honestly one of the biggest things I love about this so far is the community. Good documentation and ability to get questions answered is a big deal for me. So far I love how extensive ProcessWire's documentation is, and I thank you all for the warm welcomes! 5 Link to comment Share on other sites More sharing options...
wbmnfktr Posted June 23, 2021 Share Posted June 23, 2021 This might be some kind of an unpopular opinion but... ProcessWire gets even better while reading the docs, recreate all tutorials available, and through repeating each and every step from installation to writing a hook within a module. That's how I started to love ProcessWire - coming from Textpattern with a background in Drupal, Wordpress and other CMSs. I'm everything but a programmer, coder or developer... still I can do so many things I always wanted and needed to do. My very first project (2014/2015) with ProcessWire was awesome back in the days. It had so many features, functions, options, and what-ever... yet... looking into the code today... I was a foolish guy back in the days. Yet the project is still alive, running, and the client is happy as ever. You will grow with each and every project, while reading in the forum. Yes... reading each and every post here (top right corner: unread; thats a nice link you might want to add as your starting page) will help you so much. I'm into ProcessWire for quite a long time... yet I find so many things it can do... without even knowing. To be fair... you are right... the community here is way more than awesome than anywhere else! IMO* Final words to this loose rambling... Welcome to ProcessWire! * IMO 6 Link to comment Share on other sites More sharing options...
dotnetic Posted June 24, 2021 Share Posted June 24, 2021 On 6/18/2021 at 11:00 PM, Goca said: if you want a page to display on the front end of the site, it needs a .php template in the /site/templates/ directory This is the normal way of rendering output, but as with almost everything in ProcessWire it is up to you. For example you could use your own render logic via _init.php without the need for any other .php file. Or you could integrate a template language like Twig or Smarty via Template Engine Factory. 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