Jump to content

creativejay

Members
  • Posts

    259
  • Joined

  • Last visited

Everything posted by creativejay

  1. Very nice! It has some features I can see wanting in the larger scale site I'm building myself up to working on! I will give it a shot, and let you know if this solution was what I needed! Thanks fellas!
  2. Hi Soma, thanks for piping up! I'm happy to give your module a try, but I don't see ImagesManager either in your modules link in your signature or in ModulesManager. Am I missing it?
  3. Thanks for that start, Wanze! So here's where my code is currently: function galleryMain() { // Load all the images of all galleries, sorted by create date echo "<div class='albumgrid'>"; $allImages = new PageArray(); foreach(wire("pages")->find('has_parent=/albums/') as $gal) { $allImages->import($gal->gallery); echo "Created an array from a page<br />"; } // Sort the images by created DESC $allImages->sort('-created'); echo "Sorted images <br />"; // get the images you are going to display $items_per_page = 4; $start = ($input->pageNum - 1) * $items_per_page; $total = count($allImages); echo $total . ' images counted<br />'; $images = $allImages->slice($start, $items_per_page); echo "Defined pagination math <br />"; // make this to give MarkupPagerNav what it needs $a = new PageArray(); echo "Created a new page array to hold everything <br />"; // add in some generic placeholder pages foreach($images as $unused) $a->add(new Page()); echo "Created a new page in the array for each slice of total image count<br />"; // tell the PageArray some details it needs for pagination // (something that PW usually does internally, for pages it loads) $a->setTotal($total); $a->setLimit($items_per_page); $a->setStart($start); echo "Delivered PageArray details for Pagination <br />"; $thumbsize = 140; echo "Set thumbsize value <br />"; // output your images foreach($images as $p) { echo "Beginning Image Output <br />"; $img = $p->img; echo "<a href='{$img->url}' title='{$img->description}' class='fancybox-button' rel='fancybox-button'><img src='{$img->size($thumbsize, $thumbsize)->url}' style='margin-right: 15px; margin-bottom:25px; border: solid 1px #000000;' height='{$thumbsize}' width='{$thumbsize}'></a>"; } // output the pagination navigation echo $a->renderPager(); echo "Rendered Pagination <br />"; echo "</div>"; } Using my echoes I can see that there are no images in the allImages array, so I think this section needs some tweaking: foreach(wire("pages")->find('has_parent=/albums/') as $gal) { $allImages->import($gal->gallery); echo "Created an array from a page<br />"; } (I tried it with parent and has_parent and neither worked but I believe has_parent is correct) I'll look at it again after lunch but if someone else has keener eyes than I do, that's where it stands at the moment. Thanks everyone!
  4. Thanks kongondo! This follows the gallery tutorial in the wiki, so the structure is actually: Example Tree portfolio (solo page no children) albums (parent page - hidden) bridal (child with 50 images in field "gallery") theatrical (child with 4 images in field "gallery") runway (child with 10 images in field "gallery") What I want to do is, from the page "portfolio," create an array with the total number of images in all the $gallery fields in the child pages of "albums" (so in this example, 64 images), then sort and paginate the newly created array to display 30 per page, with page 1 holding the newest images and the last page holding the oldest images. At the top of the "portfolio" page, once I conquered this, my plan was to include links to the individual pages, with their own internal pagination. It would feel, to the visitor, as though you were filtering the entire portfolio by category and a "clear filter" type button would actually be a link back to "portfolio." Please feel free not to just suggest code for the way I have it structured in the example site tree I give above, but any other structure that might make more sense! I just followed the wiki when I originally set this up.
  5. Thanks for that link, Wanze! I think it's close to what I'm looking for, though it does seem to rely on getting to the images without the two additional levels I'm implementing in my function right now. It seems like this is the function I need to focus on (thanks to Ryan): <?php // get the images you are going to display $items_per_page = 4; $start = ($input->pageNum - 1) * $items_per_page; $total = count($page->images); $images = $page->images->slice($start, $items_per_page); // make this to give MarkupPagerNav what it needs $a = new PageArray(); // add in some generic placeholder pages foreach($images as $unused) $a->add(new Page()); // tell the PageArray some details it needs for pagination // (something that PW usually does internally, for pages it loads) $a->setTotal($total); $a->setLimit($items_per_page); $a->setStart($start); // output your images foreach($images as $p) { $img = $p->img; echo "<img src='{$img->url}' alt='{$img->description}' />"; } // output the pagination navigation echo $a->renderPager(); ...but I'm still unclear on how to build an array from the combined gallery fields of multiple albums. I'm going to play around with it a bit and report back.
  6. Full disclosure: I'm starting in ProcessWire after having used MODX almost exclusively for the last four or five years. I still tend to think in terms of the parameters that I can set in a function call and, frankly, my knowledge of php has degenerated thanks to every need pretty much being covered by the snippet library there. I am trying to familiarize myself with ProcessWire by coding a simple gallery site (to work my way up to more complex sites as I get more comfortable). I've been able to look up everything I need between the cheat sheet, wiki and the existing forum topics until today. I have finally stumbled into something I can't quite work out (and can't figure out keywords with which to search). Staging site, the gallery in question: http://www.creativejay.com/xine/portfolio/ (I haven't finished setting up fancybox, that's fiddly stuff for later) In the portfolio I have three albums currently. Since these galleries will only grow, I want to add pagination now. I understand how to paginate with MarkupPagerNav and find(), which is how I retrieve the albums themselves, but the individual images in the album are retrieved with a double scoop of foreach. Here's the entire code of my function at the moment: <?php function galleryMain(){ $albums = wire("pages")->find("has_parent=/albums/"); echo "<div class='albumgrid'>"; $out =""; foreach($albums as $album) { $albumimages = $album->gallery; $thumbsize = 140; foreach ($albumimages as $albumimage) { $out .= "<a href='{$albumimage->url}' title='{$albumimage->description}' class='fancybox-button' rel='fancybox-button'>"; $out .= "<img src='{$albumimage->size($thumbsize, $thumbsize)->url}' style='margin-right: 15px; margin-bottom:25px; border: solid 1px #000000;' height='{$thumbsize}' width='{$thumbsize}'>"; $out .= "</a>"; } echo $out; } echo "</div>"; } ?> So what's happening above (as I understand it) is that it's fetching the children of /albums/ which results in three albums. It runs through each one "as $album" and within that it runs through all the items in the album's $gallery field, then loops back and repeats for each album. If I add my pagination limit in the initial find() call, it's actually just limiting the number of albums display. Since my desired thumbnail limit is 30 per page and there are three albums this is moot (aside from not being what I want). If I were to limit within the "as $album" call, or deeper, would it not limit the items displayed from each album, but not necessarily result in pagination in the resulting web page that would lead me to additional pages of thumbnails? So my question is: What syntax (and where) do I use to paginate the code above to display a maximum of 30 gallery thumbnail images, total, from three albums per page? Ideally I'd also like to order them so that the newest images appear first, exclusive of what album they are from. I should note I'm following the gallery tutorial from the wiki and I am more than happy to use different code in my function entirely if it achieves the goal more directly. Thanks a bunch in advance!
×
×
  • Create New...