Jump to content

a-ok

Members
  • Posts

    812
  • Joined

  • Last visited

Everything posted by a-ok

  1. I'm curious. In order to share a link via Twitter you do something like the following https://twitter.com/intent/tweet?text=<?php echo $page->title; ?>&url=<?php echo $page->httpURL; ?>&via=processwire And in most instances that works fine. However, if the page title has an ampersand in it then it breaks the text. I've looked at using $sanitizer for this but doesn't seem to do the job. What I've found out works is the following: htmlspecialchars(urlencode(html_entity_decode($page->title, ENT_COMPAT, 'UTF-8')), ENT_COMPAT, 'UTF-8'); However I'm wondering if there is a way to use $sanitizer to achieve this? Or some other way with the API? Thanks!
  2. I have a RepeaterMatrix set up on a parent page and within each 'type' there's two specific fields... one is a CheckboxField and another is a PageField – the CheckboxField allows the user to hide this 'type' (or row) from the overview page and the pageField allows the user to select some categories that the 'type' is connected to. On the category pages I want it to run through the RepeaterMatrix from the parent page and only return the rows where the PageField matches the category. So within my loop of the RepeaterMatrix I have the following: if ($page->template->name == 'about-detail') { if (!$module->global_flexible_modules_about_category->has($page)) { continue; } } And on the overview page I want it to only return the rows where the CheckboxField isn't ticked (so not hidden): if ($page->template->name == 'about-overview') { if ($module->global_flexible_modules_hide == 1) { continue; } } Two things... 1. To get this to work (which it does) on the first example I had to add the ! to the check but I'm sure this is backwards (if the category contains the current page then continue) but if I remove the ! it returns all the rows except the ones with the page selected as a category... adding the ! resolves this but I'm confused as I think this is backwards? Same with the second example... shouldn't it be if the checkbox isn't ticked then continue (!= 1)? They both seem backwards even though they're working. 2. Is there a more efficient/better way to achieve this as perhaps filtering the query before the loop?
  3. Sounds like they all sold our data imho...
  4. Ah I love it when a law isn't clear.
  5. GDPR question. If we're using GA with IP Anonymisation and without any advertising features thus it's not tracking personal data... do we still need to implement the old school 'This site uses cookies blah blah'? There's no need for opt in/out so I'm curious...
  6. I stuck the same test on the other template (count of the field and $page->viewable('field_name')) and the count is returned when logged out but on the other template it's not. I've checked all templates, fields, page etc. It's the same field on both templates. Is there a way to check a field access via API?
  7. Yep! I’m assuming so? No specific permissions set.
  8. I'm having a bit of a weird issue. I have a pageReferenceField on a couple of different templates (it's the same field) and under two of the templates it seems to work fine but under one of the templates the field will only return when I'm logged in. I have tested this with a few things (different browsers) and when checking the count it shows int(1) when logged in but int(0) on the other browser/incognito mode (not logged in). I then tested the viewability of the field with $page->viewable('field_name'); and on both logged in and logged out states they return bool(true) which made me even more confused. Is there anything I can be checking? I use ProCache on the site but I've turned it off locally for these tests.
  9. Hmm so no reason it shouldn’t work then?
  10. What version of PW does modifying the imageSizerOptions within config.php work? I've tried applying it in an older install and it throws a server error: Uncaught WireException: Method Config::imageSizerOptions does not exist or is not callable in this context $config->imageSizerOptions('sharpening', 'none'); $config->imageSizerOptions('quality', 100); $config->imageSizerOptions('defaultGamma', -1); I've used this on 3.0+ but this is 2.7.1
  11. You can’t use it in filters() I believe etc... only in a find selector which’ll be fine but I’m curious to find out what “today” is actually returning – as a UNIX timestamp...
  12. Thanks! I’ve used this before but in some circumstances you can’t use it. Do you know ‘today’ is outputting?
  13. What does a date, chosen in a date field, mark as the UNIX timestamp? For example, if I chose 21st April 2018 as my date; is the UNIX timestamp it returns 23:59:59 on the 21st April? Or is it 0:00:00 21st April? Or what does it depend on? I want to return events that are on today or after but when using a page selector of “template=detail, detail_date>=$today” and $today is declared as strtotime(“now”); it won’t be returned but I’m having a hard time working out what $today should be? Midnight today plus 23:59:59?
  14. What about $pages->findMany() – could that work? https://processwire.com/api/ref/pages/find-many/
  15. Thanks for this, Robin. One query is returning 60+ results... no pagination. As soon as I add a limit to it (18) it’s a lot faster. Guess that’s mainly it, right? Interesting to know re the wireCache... but apart from the odd few queries that I will make more efficient I guess it’s down to what’s being returned (rather than queried as you say).
  16. Thanks, Sergio but I was wanting to do a check if a page using either the template where-to-go-detail or our-guides-detail is updated to reset the cache... whereas you can seem to only check one template.
  17. Also if anyone has any suggestions on how to use WireCache $cache with multiple templates? $articles = $pages->find("template=where-to-go-detail|our-guides-detail, sort=sort"); The below doesn't work and returns the following error (which I guess is because I'm using $templates->find() rather than $templates->get() and the $cache expected a single template? PHP Notice: Object of class ProcessWire\TemplatesArray could not be converted to int in $template = $templates->find("name=where-to-go-detail|our-guides-detail"); $articles = $cache->get("wtg", $template, function($pages) { return $pages->find("template=where-to-go-detail|our-guides-detail, sort=sort"); });
  18. Thanks for your help, everyone. ProCache is working pretty well – it's just that initial load per page (before it's cached) that's causing me a few problems as that initial load is slow. I have about 3 $pages->find() queries on one of my pages where the initial load is slow – each of them querying about 150 pages. This would cause such slow initial load, right?
  19. Also this seems to be working but is this all correct? $eventsDetailTemplate = $templates->get("events-detail"); $wtgDetailTemplate = $templates->get("where-to-go-detail"); $mtlDetailTemplate = $templates->get("meet-the-locals-detail"); $related_events = $cache->get("relatedEvents", $eventsDetailTemplate, function($pages, $page) { return $pages->find("template=events-detail, id!=$page, location_venue!=$page, tags=$page->tags, events_detail_dates_final_date>=today, sort=random"); }); $related_wtg = $cache->get("relatedWTG", $wtgDetailTemplate, function($pages, $page) { return $pages->find("template=where-to-go-detail, id!=$page, tags=$page->tags, sort=random"); }); $related_mtl = $cache->get("relatedMTL", $mtlDetailTemplate, function($pages, $page) { return $pages->find("template=meet-the-locals-detail, id!=$page, tags=$page->tags, sort=random"); }); $related = $related_events->import($related_wtg)->import($related_mtl); $related->sort('random')->filter("limit=4");
  20. 81ms Ah yes I was reading about WireCache... is it possible to declare more than one template in the get statement? $template = $templates->get("events-detail|guides-detail"); // But this of course only grabs the first $articles = $cache->get("wtg", $template, function($pages) { return $pages->find("template=events-detail|guides-detail, sort=sort"); }); Thanks for your help!
  21. Hi everyone I’m super close on launching a site I have been working on for a while but upon some final testing the TTFB on the site is super slow... like 6s slow which is madness. The site uses a lot of page queries and includes but apart from that it’s generally pretty fast – the load times after TTFB are fine. I’m wondering about a few things... 1. ProCache – this works amazingly well when enabled but of course each page has to be cached first and if the TTFB on each is slow then do you think it’s a redundant move? Is there a way to cache the pages without visiting each one? And do you think if a page is saved the default should be to empty the cache for the whole site? Be nice to get some feelings on best practice for this. 2. I use a lot of includes (.inc) in my templates as I try to build everything quite modular. Is there a better way to do this (render?) or is this generally fine? 3. Template cache – would this help with TTFB or rather the issue is with the MySQL pages queries so template caching wouldn’t help with this. I’m a little confused on template caching... 3. Markup cache – could this be used for improving TTFB DB queries or not? Thanks everyone... just keen for a bit of discussion and best practice on this.
  22. Thanks but is there a way to do this via a hook myself?
  23. Sorry to bring this back up but is this possible with a hook for the admin page tree? I want to sort my pages in the admin, for a specific parent/child set up, by date then by status (so unpublished pages are at the top). Any thoughts?
  24. Hmm yep I am. When I try to log in it seems to just refresh the page...
×
×
  • Create New...