Jump to content

a-ok

Members
  • Content Count

    780
  • Joined

  • Last visited

Community Reputation

85 Excellent

About a-ok

  • Rank
    Hero Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I'm attempting to build a dynamic filtering menu. I have two main templates ('activities' and 'works') and these all share the same children template 'singleA'. Work - Work a (singleA) - Work b (singleA) Activities - Activity a (singleA) - Activity b (singleA) Within each (singleA) template you can tag it with as many keywords as you wish. These keywords all share the same template 'keyword' and can have infinite children. Keywords - Event (keyword) - Talk (keyword) - Exhibition (keyword) - Solo (keyword) - Group (keyword) What I am wanting to achieve is when a user clicks on 'Work' in a menu, it'll show all the keywords with a depth of 1 that have 'works' (singleA) tagged. Then, when the user clicks the keyword 'Exhibition', for example, it'll show all the keywords, with a depth of 2 etc. I'm using @Robin S's `Connect Page Fields` for this. All the data is set up it's just I'm getting stuck trying to work out how dynamically build this as the depths could be 1, 2, 3 or 40 (unlikely but still keen to keep it dynamic). Any thoughts? $menuPages = $pages->find("template=activities|works"); foreach ($menuPages as $menuPage) { $keywordsAll = $pages->find("template=keyword, singles.parent=$menuPage"); foreach ($keywordsAll as $keyword) { } }
  2. Thanks @MoritzLost for the reply! The token is simply one token for the whole API that expires every 60 days. If you refresh the token, before it expires, it gives you a new token, otherwise you have to go through the pain in the ass Facebook OG process setting up a token again. The initI’ll token, which I get manually, has to be set first and after 30 days (to give the 60 days expiry some cushion!) it should run the refresh call and replace it. And so forth. I guess I could just set up the cache with the init API manually, without it being programmatic, and then just run the usual expiry test but I thought it would be nice to have it work from the get go. Also I guess another issue is when it expires it needs to run the refresh call with the token that’s due to expire but at that point it will have already expired in the cache and therefore not exist...
  3. Hmm I just tested this and it removes it after it's expired so null regardless.
  4. Regarding the `$cache` API I need to check whether the cache requested has either expired OR doesn't exist. Normally I just do this usual check which creates the cache if the get method returns null or doesn't exist: $result = wire('cache')->get('instagramFeed', 3600); if (!$result) { $result = $instagramHttp->getJSON($instagramBase); wire('cache')->save('instagramFeed', $result, 3600); // Expire every hour } I need to store an access token in the cache also, which expires every month. However, I need to do a check whether the cache is expired (and run a query to fetch and store a new one) OR if it simply didn't exist (which in theory would only be called once to initiate the cache) which would populate it with a static token. I read this in the docs: Am I right in thinking if I call `wire('cache')->get('instagramFeed', 3600);` and the cache exists but is expired it wouldn't return null but rather an empty string? But if the cache doesn't exist then it returns null? And therefore I could do a check like so? $instagramHttp = new WireHttp(); $instagramAccessToken = wire('cache')->get('instagramAccessToken', WireCache::expireMonthly); if (!$instagramAccessToken) { // null = doesn't exist = use static token $instagramAccessToken = '123456789010'; } else { // 'blank' assumed expired $instagramAccessToken = $instagramHttp->getJSON("https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token=$instagramAccessToken") }
  5. Of course! That makes perfect sense. Doh. Your method of merging all the relevant text to one field makes sense, also. Thanks and nice work! The only issue is if someone searched 'Kettle's' it wouldn't return, would it, as the text it's returning doesn't have the apostrophe? Also, while I'm on the subject, has anyone attempted to implement a fuzzy search with PW?
  6. It’s having a weird conflict with the multiple pageField.title in the selector. If I have one and name, it works fine, if I have multiple without name it works fine. If I have multiple AND name it throws an error referenced here:
  7. Yeah tried them all. $results = $pages->find("$fieldsToSearch%=$searchQuery, template=$templatesToSearch, sort=sort, check_access=0"); $resultsToRemove = new PageArray(); foreach ($results as $result) { if ($result->template->name == 'repeater_modulesA' && ($result->getForPage()->is('unpublished') || $result->getForPage()->is('trash'))) { $resultsToRemove->add($result); } } $results = $results->not($resultsToRemove);
  8. Is it possible for a selector (for search results) to return a page if the title is 'Kettle's' but the search term is 'kettles'? I can't include 'name' in my fields to search (which would've worked) but then if someone searched 'Kettle's' for the page title 'Kettles' it wouldn't work. Thoughts?
  9. $results = $pages->find("$fieldsToSearch%=$searchQuery, template=$templatesToSearch, sort=sort, check_access=0"); $resultsToRemove = new PageArray(); foreach ($results as $result) { if ($result->template->name == 'repeater_modulesA' && ($result->getForPage()->is('unpublished') || $result->getForPage()->is('trash'))) { $resultsToRemove->add($result); } } $results = $results->not($resultsToRemove); I had to end up doing the above. Maybe this is correct but seems a bit crazy.
  10. I'm a bit stuck with this search result setup. $fieldsToSearch = 'title|text|textA|textarea|projectsCategories.title|projectsClients.title|aboutPressCategories.title|aboutPressClients.title'; $templatesToSearch = 'projectsSingle|shopSingle|typeSingle|typeCustomSingle|typeCustomSingleB|aboutPressSingle|repeater_modulesA'; $results = $pages->find("$fieldsToSearch%=$searchQuery, template=$templatesToSearch, sort=sort, check_access=0"); It should search all those templates (including the repeater). If the result is a repeater then it returns the `getForPage()` foreach ($results as $result) { if ($result->template->name == 'repeater_modulesA') $result = $result->getForPage(); } This is pretty straightforward. I just have an issue... 1. If the getForPage() is in the trash it's still getting returned (it shouldn't) but I guess that's because the repeater isn't in the trash. Is there anything I can apply to the selector to avoid this? Or before I loop through $results should I do a check to remove any $result where status is trash? $results = $pages->find("$fieldsToSearch%=$searchQuery, template=$templatesToSearch, sort=sort, check_access=0"); $results = $results->not("status<" . Page::statusTrash); Thoughts? I guess the issue with the above is that it'll be checking the repeater for trash, not the getForPage().
  11. It would appear `name` was throwing this off. $fieldsToSearch = 'title|text|textA|textarea|projectsCategories.title|projectsClients.title|aboutPressCategories.title|aboutPressClients.title'; Works fine.
  12. @Robin S Sorry to bring this back up. $fieldsToSearch = 'name|title|text|textA|textarea|projectsCategories.title|projectsClients.title|aboutPressCategories.title|aboutPressClients.title'; $templatesToSearch = 'projectsSingle|shopSingle|typeSingle|typeCustomSingle|typeCustomSingleB|aboutPressSingle|repeater_modulesA'; $results = $pages->find("$fieldsToSearch%=$searchQuery, template=$templatesToSearch, sort=sort, check_access=0"); I am getting a `Operator '%=' is not implemented in FieldtypePage` error when searching for numbers, also. However, my Page Reference Fields should all be searching `.title`?
  13. Thanks for the help 🙂 Does anyone have a solution for using Jumplinks with urlSegments?
  14. I couldn't find an answer to this. Is it possible to declare both a time and if a template is saved to expire a cache? wire('cache')->save('instagramFeed', $result, 1800); wire('cache')->save('instagramFeed', $result, WireCache::expireDaily); wire('cache')->save('instagramFeed', $result, "template=home"); Any thoughts?
×
×
  • Create New...