Jump to content

cb2004

Members
  • Posts

    548
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by cb2004

  1. This would certainly come in handy for me on a few projects. I do work for charities and set them up with hosting that is free, but there are a lot of restrictions put in place naturally. +1 from me.
  2. Remove the link and it should kick in again. Needs to just be plain text.
  3. You could potentially also use just CSS for this: :nth-child(3n+0) This would select all elements where an index is a multiple of 3.
  4. In the foreach it is limiting the year ranges to the current year, and the year from the $firstEntry. You would need to create a $lastEntry and edit the foreach. Let me know if you need a hand as I am currently on mobile so can help when I am back on desktop.
  5. But at what scale are we talking here where there will be a noticeable slowdown, because on some sites I setup lots of fieldsets to make things look nice. Are they loaded?
  6. If home_slider and journal_slider contain exactly the same details just go for 1, less to manage. No harm in having 2 though.
  7. For those people who cannot get this to work in PW3, the instructions say to put this in your head: <script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?sensor=false'></script> This actually needs to be: <script src="https://maps.googleapis.com/maps/api/js?key=<?= $modules->get('FieldtypeMapMarker')->get('googleApiKey') ?>"></script> Or however you like to include your JS files. The sensor=false is no longer needed, but the API key is. Seemed to work for me, I havent had time to investigate the inner workings of the module to see if this should be done or not but is just a bug. Happy mapping.
  8. Well that clears that up then, cheers @horst. What does the standard ProcessWire image resizing use as that handles transparency correctly?
  9. It looks like some PNG files with transparency, the areas which are transparent are changed to black. I will do some more testing when I can. They might be 8 bit PNGs with matte set which could be confusing things. I was just wondering if this was a common occurrence. As it isn't I will dig some more.
  10. Nice module, I am using it to add canvas to some images so they are all the same size. On the transparent regions they are being changed to black. Is there any way to stop this other than re-uploading a flattened image? $options = array( 'quality' => 100, 'upscaling' => false, ); $p->image_logo->pim2Load('logo')->setOptions($options)->width(180)->canvas(180, 180)->pimSave()->url
  11. I noticed the 404 page and admin page are always in the same place in the admin and even when moved, the position is not saved. Is it possible to fix a certain page above the 404 page?
  12. Whats the best way to put checkboxes in a form and sanitize them etc? I found an old forum post but I was just wondering if there are new techniques? I have been looking at $sanitizer->options and was just wondering if this is the best way to go. Cheers.
  13. So yeah, turns out add and append were exactly the same, must have been having a tough week as I thought my testing skills were ok :). I had to go with php array_unique to achieve what I wanted. I will post a code snippet in the morning. Thanks all.
  14. append() kept the order that the items were added to the array, add() kept the order that is setup within admin.
  15. $results = $pages->find("parent=$page->children, date_1>=today, parent.status<" . Page::statusHidden); $parents = new PageArray(); foreach ($results as $p) $parents->append($p->parentID); Append will get around the sort issue, cheers all.
  16. Thanks @LostKobrakai, that works well. The array is being automatically sorted to how the admin page tree is setup (I think), is there anyway to ignore this and have the order as they were added to the array?
  17. I have been doing battle for the last couple of hours on this, I think I have got it but I just want to double check. Also I couldnt find anything on the forums so this could serve as help for other users. I have a set of child pages that hold a date. I want to do a find on those children for those with date>=today and then spit out the parents to then handle further logic. I feel like I am missing something that ProcessWire can do here so please let me know if you know of a better way. $results = $page->find("date_1>=today, sort=date_1, parent.status<" . Page::statusUnpublished); foreach ($results as $p) $parents[] = $p->parentID; $results = new PageArray(); $results->add($parents); ProcessWire should handle the unique parents as the first $results may return 1001,1002,1001 for example. Thanks as always people.
  18. On a homepage I have got some calls to action and I was just wondering whats the most optimised method. Does PW have this in the API? <?php $ctas = [ 1038, 1039, 1040, ]; foreach ($ctas as $cta): $p = $pages->get("$cta"); ?> <div class="home-cta"> <a href="<?= $p->url ?>"> <img src="<?= $p->image_cta->url ?>"> <h2><?= $p->get("text_1|title") ?></h2> </a> </div> <?php endforeach; ?> Cheers.
  19. I rock at regex regex:^[0-9-]+$
  20. I must admit, regex is certainly not my strong point. What would I have to put in to allow for an urlSegment of say 2015-2016? Thanks people.
  21. We had to add this to our latest project and I am happy to share here. I couldn't find anything on the forums for this so apologies if it has been done before. But there are always different ways of doing things: $firstEntry = $pages->find("parent_id=1037, sort=date_1, limit=1"); foreach (range(date("Y"), date("Y", $pages->get("$firstEntry")->date_1)) as $year) { $start = strtotime(date("$year-01-01")); $end = strtotime(date("$year-12-31")); $count = $pages->count("parent_id=1037, date_1>=$start, date_1<=$end"); if ($count > 0) echo '<li><a href="' . $page->parent->url . $year . '/">' . $year . '(' . $count . ')</a></li>'; } So what is going on: first of all, our pages were children, so we set the parent_id, and our date field is called date_1 we need to get the year of the oldest entry, so that happens with $firstEntry and a simple find next we create an array using a range of years, we start with the current year, then we get the year from our $firstEntry (note: if you have an output format for your date set in the field settings you will want to use $pages->get("$firstEntry")->getUnformatted("date_1") within the foreach) next we create a start date and end date for the year we count if there are any entries for that year if there are display them in a list Your next step would be to create the $input->urlSegment code to display your pages.
  22. Good work tpr foreach ($page->children("(date_1=), (date_1>today)") as $news)
  23. I have added an expiry field (date) to a template for articles which would need to expire. Some articles would not have an expiry date set, so I need to in theory display articles with a blank date or >today. I am wracking my brains but it is tired today, so I am looking for something along the lines of: foreach ($page->children("date_1=|>today") as $news) Cheers
×
×
  • Create New...