Joss Posted November 30, 2012 Share Posted November 30, 2012 Hi Obviously, I am still only a couple of weeks or so into ProcessWire, so still at the foothills of my learning. I needed to come up with a system so that if I want to radically change the construction of my site, I can without having to break into too many files. They way I am working works, but is it a sensible way to proceed? ######### Create three main files - header.inc, main_layout.inc, footer.inc and store them in a subdirectory - lets call in "includes" These contain the main construction for the site. Introduce some variables that will do the job of including specific markup for a specific template variation. For instance put this in your main_layout.php somewhere in the markup: <?php include("./includes/" . $maincontent); ?> Create a file in your subdirectory that will have the markup (including fields) for some particular content. Lets call it my_template.inc. Create a specific template file as normal in the main template directory - for instance, my_template.php. Add the following content to the file: <?php $maincontent = "my_template.inc"; include("./includes/header.inc"); include("./includes/main_layout.inc"); include("./includes/footer.inc"); ?> When this template is called, it will construct the template, adding the content from "my_template.inc" where the variable $maincontent is called. This has now simplified the template process. If you want to change the layout of the site entirely, you only need to follow the same basic rules and edit the three main files. ######### Obviously, this is pretty basic. In my working example I have three variables rather than just the one, but the principle holds. What I am trying to do is keep it all as simple as possible without introducing a lot of php that a) I don't understand properly ( ) and b) I will have trouble following in a years time when I want to change things round! Interested in any opinions Joss Link to comment Share on other sites More sharing options...
Soma Posted November 30, 2012 Share Posted November 30, 2012 Don't know if you seen this thread about similar setups: Link to comment Share on other sites More sharing options...
Joss Posted November 30, 2012 Author Share Posted November 30, 2012 Morning Soma Yes, I read through that just after I posted, though I need to look at a processwire installation to understand it properly. I hadn't noticed you can create a template without a file! I notice that my system is possibly a little closer to Ryan's (well, sort of, but without all his clever bits), The main difference is that I split header, footer and the bit in the middle. The only reason I have done that is that in the site I am doing, I need to vary the header and footer for some parts of the sites, so I already had them split up. The good thing about PW is there are so many ways to skin a cat. It is less clear, however, which is the BEST way to skin it!! Joss Link to comment Share on other sites More sharing options...
Soma Posted November 30, 2012 Share Posted November 30, 2012 Morning Soma Yes, I read through that just after I posted, though I need to look at a processwire installation to understand it properly. I hadn't noticed you can create a template without a file! Well you can create a template without a file, but my approach is to use the aternative template field and use "main" for all templates, as this allows me to have one main template with all the main markup, and just the content part is being included via a template file that has the name of the template in PW. This allows to put all templates in a subfolder. The good thing about PW is there are so many ways to skin a cat. It is less clear, however, which is the BEST way to skin it!! Joss That's true, however I don't believe there's a BEST way. It has to be BEST way for you. Link to comment Share on other sites More sharing options...
diogo Posted November 30, 2012 Share Posted November 30, 2012 I need to look at a processwire installation to understand it properly. The blog profile has a completely different approach from the default install. Have a look at it http://modules.processwire.com/modules/blog-profile/ Link to comment Share on other sites More sharing options...
Joss Posted November 30, 2012 Author Share Posted November 30, 2012 Hi Diogo Yes, I had already looked at that and decided going out and getting drunk was the next move. Once I feel more secure with the system, I will creep up behind it and have another go ..... Joss 1 Link to comment Share on other sites More sharing options...
diogo Posted November 30, 2012 Share Posted November 30, 2012 It's simpler than you might think, maybe I can convince you to have another look at it by explaining the basics To make it very short. you have two important includes, main.php and blog.php. in main.php there is all the structural html that builds the page, in blog.inc you have the functions that will create most of the dynamic content. In almost all templates, both will be included, being main.php always the last thing in the file. This means that the variables that appear in the main.php code will get their content from blog.inc and from anything that comes in the middle of them. Here's a simple example focusing on the $headline variable: in basic-page.php we have: (this is actually all there is in the file) <?php /** * Basic Page template * */ include_once("./blog.inc"); $headline = $page->get('headline|title'); include("./main.inc"); in main.inc we have: if($headline) echo "<h2>$headline</h2>"; and in blog.inc we have: $headline = ''; In blog.inc, $headline appears also as a parameter in some functions that will be later used in main.inc, but for making the point this is enough. So, in the case of a basic-page we will have a heading with either the headline field content, or the page title; On a template that doesn't define a headline variable between including blog.inc and main.inc, we wouldn't even have the <h2> tags printed (case of home.php); And on the search page we have the result of this: $headline = sprintf(__('You searched for: %s'), $query); that will print "You searched for: whatever" Link to comment Share on other sites More sharing options...
Joss Posted November 30, 2012 Author Share Posted November 30, 2012 hehe Thanks Diogo I will go through it properly at some point soon - I have a lot of other stuff to learn too, like some basic php! I have bookmarked this post, however, to help me. The problem is that I am not a developer king, I am a cut and paste jester, which means I somehow manage to get things working, but more by luck than judgement. I spend a lot of time being surprised when things actually work! I get there eventually... sometimes! Joss 1 Link to comment Share on other sites More sharing options...
diogo Posted November 30, 2012 Share Posted November 30, 2012 The problem is that I am not a developer king I am a graphic designer 2 Link to comment Share on other sites More sharing options...
Joss Posted November 30, 2012 Author Share Posted November 30, 2012 Really? I sometimes need one of those .... Edit: Well, at least it is related. In real life I was a sound engineer and dubbing mixer for 25 years (with lots of copywriting and padvertisign thrown in) and been a composer for the last 10 - I do things like this: https://www.youtube.com/watch?v=ISaXZ5j6gv8&list=PLF9DEA78045F0988C&index=6&feature=plcp But I don't get a lot of call for commissioned music on websites. Pity, audio is really rubbish on the internet - very underused. 4 Link to comment Share on other sites More sharing options...
diogo Posted November 30, 2012 Share Posted November 30, 2012 very cinematographic, great! Link to comment Share on other sites More sharing options...
arjen Posted November 30, 2012 Share Posted November 30, 2012 The problem is that I am not a developer king, I am a cut and paste jester. You used to be drunk when you drank 2 pints. Now you can handle 10 of those. The great thing about ProcessWire with some help from the likes of diogo and others and some logical thinking, a bit of exploring and some confidence you'll get there! Link to comment Share on other sites More sharing options...
Joss Posted November 30, 2012 Author Share Posted November 30, 2012 I had a birthday this week ... I am now a bit further into my second half century. I probably ought to speed up a little ..... hah! Oh, and I had to give up drinking (more or less) because of the first half century. I am sure there is something deeply philosophical in there somewhere. Now, I must get back to my new PW site. I have just found a right old headache between how PW likes to be organised and how Bootstrap menus work. Typical. 1 Link to comment Share on other sites More sharing options...
OrganizedFellow Posted December 2, 2012 Share Posted December 2, 2012 Yes, I had already looked at that and decided going out and getting drunk was the next move. Once I feel more secure with the system, I will creep up behind it and have another go ..... I feel the same way Joss.After I downloaded and tried ProcessWire, I later found the Blog Profile, installed that into a new setup. While I really like how well it's designed (html and css wise). I couldn't grasp HOW things were getting pulled together into the page output. Diogo explained it simply, and I think I may have to give it another go soon. Link to comment Share on other sites More sharing options...
NorbertH Posted September 13, 2014 Share Posted September 13, 2014 Whoa great music, who is the singer at 10:30 ? Link to comment Share on other sites More sharing options...
Joss Posted September 13, 2014 Author Share Posted September 13, 2014 ah - that would be me.... sorry 4 Link to comment Share on other sites More sharing options...
NorbertH Posted September 14, 2014 Share Posted September 14, 2014 Why sorry ? Checked the youtube channel ... like it very much! Link to comment Share on other sites More sharing options...
Joss Posted September 14, 2014 Author Share Posted September 14, 2014 Well, I hate to give people indigestion over breakfast! I normally use proper singers (or rather, singers who did not wreck their voices smoking, like I did), but I do occasionally like to give myself an outing other than backing vocals. Link to comment Share on other sites More sharing options...
Pete Posted September 14, 2014 Share Posted September 14, 2014 ...but I do occasionally like to give myself an outing other than backing vocals. *pictures Joss in a sparkly dress swaying and singing into a microphone* 2 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 14, 2014 Share Posted September 14, 2014 Like this: (Thanks Sugur Lee Hooper) 2 Link to comment Share on other sites More sharing options...
Joss Posted September 14, 2014 Author Share Posted September 14, 2014 Okay, don't even go there! (Damn, must throw that old spandex suit out!) 1 Link to comment Share on other sites More sharing options...
Pete Posted September 14, 2014 Share Posted September 14, 2014 Nothing quite that alarming, no. Link to comment Share on other sites More sharing options...
zota Posted December 5, 2016 Share Posted December 5, 2016 On 11/30/2012 at 3:42 AM, Soma said: Don't know if you seen this thread about similar setups: The thread reference doesn't show up. Can someone fix this? please... thnks Link to comment Share on other sites More sharing options...
adrian Posted December 5, 2016 Share Posted December 5, 2016 26 minutes ago, zota said: The thread reference doesn't show up. Can someone fix this? please... thnks Done! 1 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