Jump to content

kongondo

PW-Moderators
  • Posts

    7,529
  • Joined

  • Last visited

  • Days Won

    160

Everything posted by kongondo

  1. He's "hiding" it here http://processwire.com/talk/topic/3219-images-manager-alpha/ and here https://github.com/somatonic/ImagesManager Don't be put off by the alpha tag though
  2. "Shameless plug"! Wasn't the idea not to piggyback on MarkupPagerNav module, hence "enable" pagination? http://processwire.com/talk/topic/390-images-pagination/?p=2928 I'd still go for the ready-made IM solution though
  3. kongondo

    Hit 1000+ likes

    Why you acting all surprised? Totally deserved of course...
  4. Apologies. Of course it works! This is Soma's code! I had a typo in my code. I'll go away and hide in shame until later... The typo: In the second foreach, I had ('slides.disable_slides=0') instead of ('disable_slides=0') OK, now am really confused!! Soma, doing it your way doesn't work OK, now am really confused!! Soma, doing it your way doesn't work . I tested with my way first (as shown above and it worked). But using your way, it returns results where there are at least one checkbox unselected and outputs both unchecked and checked checkboxes...I think I know why...let me think a bit.. Edit: I think your last code doesn't work because of what I said in the post above. The first find will grab all pages that have at least one repeater checkbox that is unchecked irrespective of whether those pages have other repeaters with selected checkboxes. Remember though, it grabs the pages themselves but does not distinguish the repeater fields yet. Why the selected checkboxes are not eliminated in the second foreach I do not know though...
  5. Edit: Didn't read code properly..of course Soma's code works! . I had similar code earlier i.e., checking for checkbox state in the first find() but was not checking again in the inner foreach (as per my code above). Hence, I was getting and outputting results if at least one repeater on the page was unchecked even if others were checked.
  6. Thx Soma! Two lessons for the price of one!
  7. @Macrura, Sorry to hijack your thread . I am also trying to further understand how I can use the API to access repeaters (and hopefully assist fellow newbies ). So, I will post the following code for the gurus to comment on please, thanks! $r = $pages->find("template=basic-page, slides.count>0");// find pages with at least 1 slides (repeater) foreach ($r as $p) { $v = $p->slides; foreach ($v as $b) { if ($b->disable_slide==0) {//checkbox "disable_slide" not checked echo "<p>$b->title</p>"; } } } This works for me. The first selector find will grab all pages that have at least 1 "slides" (which is the name of the repeater). The pages found have multiple instances of the repeater "slides" - meaning arrays within arrays, hence, nested foreachs which I traverse...For each result, I check that the checkbox "disable_slide" is not checked and only output those repeaters.. @Others Dear gurus...is there a shorter way (other than nesting the first selector find inside the first foreach) or more efficient way of achieving the same thing or this will do? Thanks. Edited for clarity (See Soma's post below about "selector" . Also see his more efficient code)
  8. @Soma, Should something like this not work? $slides = $pages->find("slides.disable_slide=0");// slides = repeater Currently not working for me...(returning incorrect results) Sorry, ignore: works fine... . It finds all pages with the repeater "slides" whose repeater fileds "disable_slide" are not checked.
  9. Duh! Of course, rookie mistake! Thanks Nik! I can't believe I missed that! (facepalm) Edited post above...
  10. OK, did some more tests with the checkbox as part of the repeater... slide = the repeater disabler = a checkbox inside the repeater foreach ($page->slide as $show) { if ($show->disabler!==1) { //edited to == echo "<li>$show->title</li>"; } else { echo "<li>I am hidden!</li>"; } } //!==1 works; !==0 works; ==0 works; ==1 works Edit: I had used assignment (=) operator rather than comparison (==)operator. See correction in post below by Nik
  11. Re-reading your post...I'm not sure I got your correctly... Are the checkboxes within the repeater field or are they an independent field on a page that has several repeaters? i.e., do you want to disable the page (including all its repeaters) or do you want to disable individual repeaters on a page? (e.g. show repeater instance 1, 3 and 4 of page x but disable repeater instance 2 and 5 of page x).
  12. This works for me just fine as follows: $test = $pages->find("template=basic-page, disabler=0") //$test is just a variable I create; disable is the name of the checkbox; basic-page is the template that has pages that have repeaters. I then traverse the repeaters... As for tips...repeaters are just pages under the page Admin. The repeater field itself (e.g. slides) is a page (whose parent is called "Repeaters") and the repeater instances on each page are its grandchild pages . The repeater's children are pages which have the repeaters. But you probably knew this already Repeaters slides (the repeater field itself) page 1 with repeater repeater instance 1 repeater instance 2 page 2 with repeater repeater instance 1 repeater instance 2 repeater instance 3
  13. creativejay, Welcome to PW! Just to make sure we understand what you are after...Is the following your situation? Example Tree gallery (parent page) Album A (child with 100 images) Album B (50 images) Album C (75 images) You want to grab a total of 30 images from Albums A - C and display them on the page gallery? Do you want to grab random images? I know you want to sort them by the latest (i.e. sort=-date). Do you want to grab the same number of images from each album? i.e. 10 each? I'm just trying to wrap my head round what you want to accomplish. Ryan's code above was for a situation where all the images were on one page (i.e. no child pages).
  14. Sorry, am rushing somewhere...the following will answer your question http://processwire.com/talk/topic/2786-request-seems-to-be-forged/ http://processwire.com/talk/topic/1563-this-request-was-aborted-because-it-appears-to-be-forged/ http://processwire.com/talk/topic/2102-using-previous-pw-installation-as-template-for-the-next-one/ http://processwire.com/talk/topic/2763-500-error-when-visiting-the-backend/ http://processwire.com/talk/topic/3668-internal-server-error-in-admin-page/
  15. You don't get anything because the pages are hidden. Add this to your selector include=hidden Please read this page: http://processwire.com/api/selectors/ and specifically this section in relation to access control in selectors.
  16. Hi Valery, See this page about using the API to add or remove repeater items There is a sample code on that page. As you can see, it can really be more simple compared to your code
  17. $pages->find() will find things; lots of things in some cases (pages) . You need to echo out the ouput. Do you get any errors? Is there really a template called "category"? Does it have any unpublished and hidden pages using it? In addition, have you read these documentation? http://processwire.com/api/selectors/ http://processwire.com/api/variables/page/ http://processwire.com/api/variables/pages/ By the way, normally, you don't want to do something like $pages->find() without including a "limit"; It can find lots of things...and eat into your server resources, maybe hang your pages, hence, frustrate your web visitors, etc... Edit: corrected typos
  18. I like this one too! Pity I can't wear both; maybe alternate every other week, hehe
  19. .... Yeah, where you place the $total = 0; determines whether you get cumulative totals, sub-totals or grand total
  20. Galaxy, See Diogo's code above. That should work for you. My problem was that I suggested code "independent" of your "result foreach" (I was starting with the $dollars = blah blah), which you don't need if you use your "result foreach" as Diogo suggests.. .....I'll eat my hat if Diogo's code doesn't work...I'm sure it will!
  21. OK, are those totals correct? E.g., is the total for YMCA = 2000?
  22. Galaxy, You haven't answered my questions above Have you tried to move the "grants foreach" outside the "result foreach" as I suggested above? Have you tried independently running the "grants foreach" as I suggested, in order to test the code?. It works for me here. At the moment, do not worry about the <li>s. The most important thing is to get the totals right, I think...
  23. That's why I suggested to move the grants foreach outside the result foreach. I don't see its use inside the very first (result foreach) ...I could be wrong though
×
×
  • Create New...