geekpete Posted February 8, 2018 Share Posted February 8, 2018 Hi All, First post here so wanted to start by saying how much I'm liking ProcessWire. Come from an ExpressionEngine / CraftCMS background I'm building a backend type service website where I have about 10 'admin' pages to view orders, upload orders (as well as a few other entities) extract data etc. We are not talking about millions of records, thousands a month top so I thought I could use the 'page for everything' approach. Initially I was just going to use the PW 'backend' and let the end users onto it i.e. The part you log into by default at /processwire and write some modules but having things like the settings tab on pages and some of the other bits an end user might not understand made me feel my own frontend would be a better idea. I've got things up and running with a custom login that uses the PW authentication system and am building a nav no problem, using selectors for data etc (which by the way are awesome!). So now I've settled in a bit I've come to structure my template files better and have read here.... https://processwire.com/docs/tutorials/how-to-structure-your-template-files/ Delayed output looked like the most flexible strategies (and easy enough to implement). However, bear in mind each of the pages are unique in their functions so essentially I have a header / nav etc, then the page specific block and then a footer. The page specific stuff is quite large and a lot of the time HTML with a sprinkle of PW / PHP bits. I didn't want to do this.... $main content="<div><ul>.........." ($main_content gets used in main.inc as per 'structuring' link above) Its gets quite cumbersome with a large block not to mention I lose some nice features in PHPStorm as it just sees it as a string. So what I've been doing is this.... <?php require("./includes/login.inc"); require("./includes/init.inc"); $main_content = $page->render("partials/" . $page->template->name .".inc"); require("./includes/main.inc"); ?> I now need to keep creating the matching .inc files. Is there a way I can use just the one template file file to set $main_content in some cunning way that enables me not to manage the string building? Am I approaching things right? I know I can just include a header, splurg the content and then include a footer but I liked the 'Delayed Output' approach for the flexibility. Sorry if its a silly question everyone, still learning, only a few days in and I'm no PHP demon, no giggling at the back hahaha 1 Link to comment Share on other sites More sharing options...
geekpete Posted February 8, 2018 Author Share Posted February 8, 2018 Just found out about markup regions, these look sexy and what I might be what I'm after https://processwire.com/blog/posts/processwire-3.0.62-and-more-on-markup-regions/ Any other ways or anything I should know? Link to comment Share on other sites More sharing options...
Robin S Posted February 8, 2018 Share Posted February 8, 2018 48 minutes ago, geekpete said: Just found out about markup regions Markup Regions are a godsend if you want to code HTML directly rather than adding it as strings to PHP variables. 48 minutes ago, geekpete said: Any other ways Alternatively you can use output buffering (which is what I preferred before Markup Regions were introduced). <?php ob_start(); // $main_content ?> <div>Your markup</div> <?php $main_content = ob_get_clean(); ?> 1 hour ago, geekpete said: Initially I was just going to use the PW 'backend' and let the end users onto it i.e. The part you log into by default at /processwire and write some modules but having things like the settings tab on pages and some of the other bits an end user might not understand made me feel my own frontend would be a better idea. For a project like yours I would be inclined to try building it within the PW admin as a first approach - you can do a lot with the admin (it's just an application built using the PW API) and it's pretty easy to tweak it with hooks and custom CSS. I think it would be much quicker that way. @bernhard has written a helpful blog post for getting started with Process modules, and check out his Showcase topic for the kinds of things that are possible: 2 Link to comment Share on other sites More sharing options...
Sergio Posted February 9, 2018 Share Posted February 9, 2018 Hi @geekpete, welcome to the forums. As Robin S. said, there are better alternatives. I'd like to suggest @tpr's module Template Latte Replace This is a great template engine that I'm truly happy to use on more complex websites. 1 Link to comment Share on other sites More sharing options...
geekpete Posted February 9, 2018 Author Share Posted February 9, 2018 Cheers Guys, Great info! Very helpful indeed Link to comment Share on other sites More sharing options...
bernhard Posted February 9, 2018 Share Posted February 9, 2018 Hi and welcome! 12 hours ago, geekpete said: I'm building a backend type service website where I have about 10 'admin' pages to view orders, upload orders (as well as a few other entities) extract data etc. Advice: Definitely stay in the admin! I had exactly the same thoughts before I created my CRM because modifying the admin seemed totally complex and out of my scope. But once you get the concept it is REALLY simple and you get all the benefits that the pw backend offers (all fields, all functionality like login, sanitization, field collapsing, hooks etc). That's why I created the blogpost that Robin linked to (thx btw ). The ROI (return on invest) of digging into the PW admin is huge and it will help you a lot to improve all your pw related work, because you will understand everything a lot better. I wish you good luck and a lot of fun 3 1 Link to comment Share on other sites More sharing options...
geekpete Posted February 9, 2018 Author Share Posted February 9, 2018 Thanks again all, I am sold Just setup a dev install so I can start to understand how I can use the PW admin in more detail. 2 Link to comment Share on other sites More sharing options...
elabx Posted February 9, 2018 Share Posted February 9, 2018 4 hours ago, bernhard said: The ROI (return on invest) of digging into the PW admin is huge and it will help you a lot to improve all your pw related work, because you will understand everything a lot better. This, every day of the week! Always keep in mind that the PW admin is basically a blank page with a masthead (or sidebar haha), everything else is optional through roles and permissions. 1 Link to comment Share on other sites More sharing options...
kongondo Posted February 9, 2018 Share Posted February 9, 2018 @geekpete, Welcome to ProcessWire and the forums. In addition to what has been said, especially the comment about roles and permissions, just remember to test your work/module as both a superuser and a normal user. Some stuff will not be viewable, editable, etc, by default for non-superusers. 2 Link to comment Share on other sites More sharing options...
geekpete Posted February 10, 2018 Author Share Posted February 10, 2018 Thank you all once again, amazingly helpful Link to comment Share on other sites More sharing options...
geekpete Posted February 12, 2018 Author Share Posted February 12, 2018 (edited) I just wanted to follow-up for anybody reading in a similar situation. After spending more time with the admin and understanding things I can say using it as opposed to recreating an admin at the 'frontend' is 100% the way to go, will be saving a ton of time, so glad I got a good steer from you all. Edited February 12, 2018 by geekpete Typo :) 6 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