Joss Posted November 28, 2012 Share Posted November 28, 2012 Sorry, I am full of questions at the moment. But it is my birthday and I have been spending the day avoiding clients a messing around! I want to render a row of pages (as blocks) in my bootstrap template. The idea is that you can create these special pages and it will display the most recent three in a row - the whole rendered page in each case. So I think I want to do something like: $footers = $pages->get("/home/blocks/footer-blocks")->children(); foreach($footers as $footerblocks) { echo $footerblocks->render(); } Then do a limit=3 somewhere. I am sure I read something somewhere that had at least part of the answer, but I cannot find it! Am I heading the right direction? Joss Link to comment Share on other sites More sharing options...
adamspruijt Posted November 28, 2012 Share Posted November 28, 2012 $footers = $pages->get("/home/blocks/footer-blocks")->children('limit=3'); I know right, too easy. That all you need for the limit at least. Generally the rest sounds doable, ProcessWire won't dictate the method so it's up to you really. Link to comment Share on other sites More sharing options...
DaveP Posted November 28, 2012 Share Posted November 28, 2012 Certainly heading in the right direction. I would try $footers = $pages->get("/home/blocks/footer-blocks/")->children("limit=3"); (Completely untested - I'm sure someone will correct me.) <edit>adamspruijt beat me to it</edit> Link to comment Share on other sites More sharing options...
Joss Posted November 28, 2012 Author Share Posted November 28, 2012 Ah, replies in harmony! I approve. You have to remember that all the so-called coding I do is cutting and pasting little bits from everywhere and guessing whether I have done the right thing. So, I tend to err on the side of ... "Oh, that will never work!" with most things I do Generally the rest sounds doable, ProcessWire won't dictate the method so it's up to you really. I keep holding out for the system where I can literally write in my page "Look, I sort of want to do this, lay it out a bit like this, and then control it by pressing a big blue button." And the system will go - "What, like this?" And voila, it works! Joss Link to comment Share on other sites More sharing options...
DaveP Posted November 28, 2012 Share Posted November 28, 2012 I keep holding out for the system where I can literally write in my page "Look, I sort of want to do this, lay it out a bit like this, and then control it by pressing a big blue button." And the system will go - "What, like this?" And voila, it works! PW is about as close as you'll find, for now. (And I did have an extra '/' in my answer ) Link to comment Share on other sites More sharing options...
Joss Posted November 28, 2012 Author Share Posted November 28, 2012 ooh, I will have to see whether that sounds out of tune.... Link to comment Share on other sites More sharing options...
Joss Posted November 28, 2012 Author Share Posted November 28, 2012 Okay, Part way there - the render() bit isn't working. If I put $footerblocks->body; - then it outputs the body field, so the idea is right, just not quite doing what I hoped. I will continue digging. Joss Link to comment Share on other sites More sharing options...
adamspruijt Posted November 28, 2012 Share Posted November 28, 2012 I believe render is meant to be used on an array: $footers = $pages->get("/home/blocks/footer-blocks/")->children("limit=3"); $footers->render(); I'm not certain though, never really used it. Link to comment Share on other sites More sharing options...
ryan Posted November 28, 2012 Share Posted November 28, 2012 Happy birthday Joss. You'd want to render each individual page $items = $pages->get('/home/blocks/footer-blocks/')->children('start=0, limit=3'); foreach($items as $item) { echo $item->render(); } I added that "start=0" into the selector, just in case you are using pagination somewhere on the page. Otherwise, that isn't necessary. Link to comment Share on other sites More sharing options...
Joss Posted November 28, 2012 Author Share Posted November 28, 2012 Hi Ryan, thanks - going out for a serious Thai later. Take a break from cooking (http://www.foodloversdiary.com) Yes, that is what I have been doing: <?php $footers = $pages->get('/home/blocks/footer-blocks/')->children('start=0, limit=3'); foreach($footers as $footerblocks) { ?> <div class="span3"> <?php echo $footerblocks->render(); ?> </div> <?php } ?> Which is outputting nothing. However, the following works with a specific field: <?php $footers = $pages->get('/home/blocks/footer-blocks/')->children('start=0, limit=3'); foreach($footers as $footerblocks) { ?> <div class="span3"> <?php echo $footerblocks->body; ?> </div> <?php } ?> So, I am a bit confused. Link to comment Share on other sites More sharing options...
diogo Posted November 28, 2012 Share Posted November 28, 2012 render() renders the template of the page, do the children of footer-blocks have a working template? edit: and happy birthday!! Link to comment Share on other sites More sharing options...
Joss Posted November 28, 2012 Author Share Posted November 28, 2012 Yes they do - but I better check that all the fields are in there .... good call! Edit: and thanks! Link to comment Share on other sites More sharing options...
Soma Posted November 28, 2012 Share Posted November 28, 2012 Do the pages u render have a template file? Link to comment Share on other sites More sharing options...
Joss Posted November 28, 2012 Author Share Posted November 28, 2012 I just checked their template. It is not very busy at the moment! <div> <?php echo $page->body; ?> </div> But seems to be all there. Link to comment Share on other sites More sharing options...
Joss Posted November 28, 2012 Author Share Posted November 28, 2012 GOT IT! Anyone notice I had a superfluous "home" in the first line??? Removed that and it works. So my final code is: <?php $footers = $pages->get("/blocks/footer-blocks/")->children("limit=3"); foreach($footers as $footerblocks) { ?> <div class="span3"> <?php echo $footerblocks->render(); ?> </div> <?php } ?> Thanks everyone! 2 Link to comment Share on other sites More sharing options...
adamspruijt Posted November 28, 2012 Share Posted November 28, 2012 render() renders the template of the page, do the children of footer-blocks have a working template? edit: and happy birthday!! WOW, ok so I was wrong, and that... is awesome. Link to comment Share on other sites More sharing options...
Joss Posted November 28, 2012 Author Share Posted November 28, 2012 The result, which is directly aimed at Bootstrap, means that I can line up blocks in a row and the client can change them just by re-ordering the pages. I might add a count so that if there are 3, the class is Span4, if there are 2 it is span6, if 4, span3 and so on. Might be fun ..... or confusing! Joss Link to comment Share on other sites More sharing options...
Soma Posted November 28, 2012 Share Posted November 28, 2012 U can line up blocks in a row I'll connect the dots. Wait. I thought 2 were 5. Confusing Link to comment Share on other sites More sharing options...
Joss Posted November 28, 2012 Author Share Posted November 28, 2012 Hey, my maths is fine .... it is only my sense of humour that is badly out of line! Link to comment Share on other sites More sharing options...
Soma Posted November 28, 2012 Share Posted November 28, 2012 No probs. Mine mabe too.. 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