Jump to content

onjegolders

Members
  • Posts

    1,147
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by onjegolders

  1. Would be interesting to see if this is the way Ryan would go about this in PW or if there was another cleaner way.
  2. Yeah I initially had a problem with footer too but on reload all was well.
  3. Thanks Apeisa, I just checked and it is set to image, can ->size not be called in that way?
  4. This is my new code but the page won't load : foreach ($page->children as $entry) { // add classes to first and last boxes. $class = 'blog_box'; if ($entry == $page->children->first()) { $class .= ' blog_box_first'; } elseif ($entry == $page->children->last()) { $class .= ' blog_box_last'; } else { $class .= ''; } // make blog images 200 X 150 $image = $entry->single_image->size(200,150); echo "<div class='$class'>"; echo "<div class='blog_text'>"; echo "<h3>$entry->title</h3>"; echo "<p>$entry->body</p>"; echo "</div><!-- /.blog_text -->"; echo "<img src='$image->url' alt='alt text' />"; echo "<div class='clear'></div>"; echo "</div><!-- /.blog_box -->"; } If I leave out the resizing however, the image is called and the page works : foreach ($page->children as $entry) { // add classes to first and last boxes. $class = 'blog_box'; if ($entry == $page->children->first()) { $class .= ' blog_box_first'; } elseif ($entry == $page->children->last()) { $class .= ' blog_box_last'; } else { $class .= ''; } // make blog images 200 X 150 $image = $entry->single_image; echo "<div class='$class'>"; echo "<div class='blog_text'>"; echo "<h3>$entry->title</h3>"; echo "<p>$entry->body</p>"; echo "</div><!-- /.blog_text -->"; echo "<img src='$image->url' alt='alt text' />"; echo "<div class='clear'></div>"; echo "</div><!-- /.blog_box -->"; }
  5. Looks good, some great photos too.
  6. I have a very similar experience to yours stillmoving, though I never was involved with txp. Would be interested to hear what problems, if any, you found when moving from EE and what you did to solve them... Was there anything that was particularly different or difficult? EDIT: I splitted this topic from it's original thread (this was getting little off topic there and definitely earns own thread anyways). -apeisa
  7. Apeisa, I can't seem to reference the image at all.
  8. Thanks guys, I'm running into a few problems setting image dimensions within the foreach loop. If I want to set it, should it be before the loop is called or after? <?php $blog_entry = $page->children(); foreach ($blog_entry as $entry) { $image = $entry->single_image->size(200,100); echo "<div class='blog_box'>"; echo "<div class='blog_text'>"; echo "<h3>$entry->title</h3>"; echo "<p>$entry->body</p>"; echo "</div>"; echo "<img src='$image->url' alt='alt text' />"; echo "<div class='clear'></div>"; echo "</div>"; } ?>
  9. I tend to use these overly long class names in fear that I'll double reference them in some way. Old bad habits die hard!
  10. Thanks to both of you, that's got that working.
  11. Thanks Diogo, using your method adapted to my code, I'm getting "Parse Error syntax error, unexpected $end" I've obviously left something out but can't see it! <?php include("./header.inc"); ?> <?php $testimonial = $page->children(); foreach ($testimonial as $item) { echo "<div class='testimonial_box"; if($testimonial->getItemKey($item) % 2) { echo " testimonial_box_even"; } else { echo " testimonial_box_odd"; }; if($item == $testimonial->first()) { echo " testimonial_box_first"; }; if($item == $testimonial->last()) { echo " testimonial_box_last"; }; echo ">"; echo $item->body; echo "<p>$item->title</p>"; echo "</div><!-- /.testimonial_box -->"; ?> <div class="clear"></div><!-- /.clear --> <?php include("./footer.inc"); ?>
  12. Thanks Soma, I just changed $testimonial to $tm as per rest of your code and that works great. The +1 is just making it odd right?
  13. Tacking on Diogo's suggestion, I think I have it all working, code's probably a bit messy compared with you guys but get's the job done! <?php $testimonial = $page->children(); $i = 0; $i++; foreach ($testimonial as $item) { $i++; if(!0 == $i % 2) { $class = 'testimonial_box_odd'; } else { $class = ''; } ?> <div class="testimonial_box<?php echo " $class"; ?><?php if ($item == $testimonial->first()) { echo " first"; } ?><?php if ($item == $testimonial->last()) { echo " last"; } ?>"> <?php echo $item->body; ?> <p><?php echo $item->title; ?></p> </div><!-- /.testimonial_box --> <?php } ?>
  14. Thanks Soma, I don't suppose it would be possible to do a quick example of a div with a class set for first, last and odd using getItemKey? That would really help me understand the whole thing together!
  15. Woh, you guys are quick, just about to put that your code worked, so thanks! Don't suppose there is any way similar code could be used to get 1st, last etc? Or would that be ->first(); ? Is there any difference between using getItemKey or not? Thanks again both of you.
  16. Thanks Diogo, I tried using the examples of Soma and Netcarver, so far I have the following: <?php include("./header.inc"); ?> <?php $testimonial = $page->children(); $i = 0; $i++; $class = ""; foreach ($testimonial as $item) { $i++; if(0 == $i % 2) { $class = 'odd'; } ?> <div class="testimonial_box<?php echo " $class"; ?>"> <?php echo $item->body; ?> <p><?php echo $item->title; ?></p> </div><!-- /.testimonial_box --> <?php } ?> <?php include("./footer.inc"); ?> When I look at page source, I see that all the boxes end up with the "odd" class.
  17. Thanks Diogo, I was hoping there was a more API way of doing this. I've seen Ryan say many times that most differences between EE and PW boil down to template language versus native PHP. Is there no "in-house" way of referencing "count" within a loop? Eg: if ($page->children->count(1)) { echo "class=\"first_box\""; } ?>
  18. Thanks anyway Diogo! Thanks netcarver, I don't really understand the % reference
  19. Wow thanks all of you for helping out, I was ideally looking for a simple-ish PW way of doing this, I was getting used to things being quite simple and intuitive! Ideally I'd just like to count which number of the loop I was on and add classes to it. It was relatively simple in EE and I figured there'd be something a little similar here. Sample code in EE: <div class="box{if count == 1} first_box{/if}"</div> <div class="box {switch="even|odd"}"</div> <div class="box{if count == total_results} last_box{/if}"</div> In PW? I'm a bit stuck!
  20. Thanks Soma, that could be one way of doing it but not sure if that CSS is universal? Any way of getting values other than first/last? I'd like to have every other box float right, as an example.
  21. Sorry to start another post Was just wondering how to replicate ""if count = 1", if count = total_results as well as switch classes in PW? I'm guessing it's some sort of standard PHP but can't seem to figure it out. The aim is to have divs with different margins, paddings, floats dependent on which number it is, ie. first one will have no margin-top, every second div will be floated right. Thanks
  22. Was wondering what the best way to handle unneeded parents was? For example I have a testimonials page that will only contain it's children, it won't have any of its own content. Should this be locked and if so, is there a quicker way for the end-user to enter many children? Can a parent and child have separate templates? Am just trying to get my head around this as a former EE (channels) user. Thanks
  23. Thanks Nico, that works exactly as expected. Is that the way that you'd go about it? Was wondering if it is, then whether you could add an icon so that the user doesn't have to remember that shortcut?
×
×
  • Create New...