Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by a-ok

  1. Any thoughts about SASS/CSS variable names? My guess would be to follow CSS naming convention but then they look like class names rather than variables (but maybe that is also okay). This hole is deep...
  2. YES! What about assets? symbol__arrow--next.svg? symbol-arrow-next.svg?
  3. This answer. Perfect. What about template and field names within PW? Thoughts?
  4. Go on... I wonder if Atom does this...
  5. Not sure if this has been brought up before (probably not because it's a bit mental) but do you have any specific file name conventions? I struggle between matching the file extension language (phpFile.php, jsFile.php, appWtf-dunno__v1.scss) and just OS naming (hyphen only). Am I overthinking this? Does the consistency matter? I've noticed the ProcessWire filenames vary (sometimes even PascalCase) and wondered if there was a pattern I was missing?
  6. Is it possible to get this working for a repeater? I seem to get the error Exception: Method RepeaterPageArray::chunk does not exist or is not callable in this context
  7. Apologies to bring this back up but I'm curious to know why this doesn't work for standard repeaters? They use a separate template, for example 'repeater_about', so even if I change this by editing the template by showing the system templates it still doesn't work. Considering repeater rows are 'pages' and use their own template... you would think it would work?
  8. Any thoughts? Even a manual fix for now (hook or otherwise?)
  9. When I add a new user, even if the 'UIkit' theme is selected (by default), upon creating the user then logging in as said user the theme is the default theme. If I go to the profile, no options are selected. If I select 'UIkit' here and save it's all fine. Any thoughts? I'm on Processwire 3.0.123 but I've had this issue since using v3. *UPDATE* I actually just uninstalled the default theme but it's just the 'non' theme that it seems to use even though UIkit is selected on creation.
  10. $submissions = $pages->get("template=home")->submissions; foreach ($submissions as $s) { $s->delete(); $s->save(); } $pages->get("template=home")->save(); This worked! But so many saves? I never know.
  11. Thanks. This doesn't seem to work either, weirdly. $submissions = $pages->get("template=home")->submissions; foreach($submissions as $s) { $s->delete(); } $submissions->save();
  12. Sorry, I'm confused. I'd like to remove all rows but keep the repeater. Upon removing the ->of(false) it still doesn't delete all the rows.
  13. No, sorry. I haven't set up the cronjob yet... just testing the code. It returns: Exception: Method RepeaterPageArray::of does not exist or is not callable in this context
  14. Does anyone know why the following doesn't work? The page would be called via a cronjob... if ($input->get->run) { // Reset submissions if ($input->get->run == "resetSubmissions") { $submissions = $pages->get("template=home")->submissions; $submissions->of(false); $submissions->removeAll(); $submissions->save(); bdb('resetSubmissions has been run'); } }
  15. This is very cool. Much appreciated. @BitPoet Many thanks for your help. I ended up using your example and doing something like so.. $submissionsNames = array(); foreach ($page->submissions as $submission) { $name = ucwords(strtolower($submission->submissions_firstname . " " . $submission->submissions_lastname)); array_push($submissionsNames, $name); } $submissionsNames = array_count_values($submissionsNames); ksort($submissionsNames); arsort($submissionsNames); $submissionsNames = array_slice($submissionsNames, 0, 5); Let me know if you think I've missed a trick?
  16. Is there any reason why the CPU on my server would spike to above 70% and crashing (effectively) when entering a really long title for a page? The title in question is: Arts Facades: incorporating Duke of York’s Theatre, Harold Pinter Theatre, Phoenix Theatre, Fortune Theatre This has never happened to me before so any advice/debugging you can suggest would be appreciated.
  17. I've got a basic AJAX submission form set up for a poll – the user enters a first and last name or a person they'd like to nominate and upon submission it stores the first and last name, as well as IP address and timestamp within a repeater row. The user can only submit, using the same IP address, once within a 24 hour period (done by cross-checking their IP with entries in the repeater as well as the difference between timestamps). I now want to return a 'live top 5' – like a leaderboard – (taking all first and last name entries and doing a 'count'). This is where I'm stuck at the most efficient way to do this. Counts need to be case-insensitive (michael jordan and MICHAEL JORDAN and miCHAel joRdaN would total three, not one each) and then should, ideally, sentence-case the returned top 5 along with the count What do you think? Thanks in advance for any advice.
  18. Ahh. Your example was fine though; it was my original that wasn't. Who knows. Hate that! Thanks for all the help, you too @bernhard
  19. Now I'm confused. That didn't work but that made it almost 100% like your example. I commented mine out and put back yours and it worked. Bizarre. I even put wire()-> back in instead of $this and it still worked – maybe a hidden glyph or something?
  20. Brilliant. That does work. Why would the first code work, but not the second? if ($this->page->template == 'admin') { function customPageName(HookEvent $event) { $dummy = 'hook-generated'; $page = $event->arguments(0); if ($page->template->name == 'work-detail') { if ($page->global_text) { $pageName = wire()->sanitizer->pageName($page->title . '-' . $page->global_text, true); } else { $pageName = wire()->sanitizer->pageName($page->title, true); } $page->setOutputFormatting(false); $page->name = $pageName; } } $this->addHookAfter('Pages::saveReady', null, 'customPageName'); }; function myHook(HookEvent $event) { $page = $event->arguments(0); if ($page->template->name == 'work-detail') { if ($page->global_text) { $pageName = wire()->sanitizer->pageName($page->title . '-' . $page->global_text, true); } else { $pageName = wire()->sanitizer->pageName($page->title, true); } $page->setOutputFormatting(false); $page->name = $pageName; } } wire()->addHookAfter('Pages::saveReady', null, 'myHook');
  21. Many thanks for this. I haven't tried it yet but what's the fundamental difference here? The "$page->name =" rather than "setAndSave"?
  22. Bit of an update. Using TraceyDebugger it looks as if the name does change (so to speak), it even says so in the session, but it isn't updated on the backend or the frontend.
  23. Thanks for the reply! It does not, sadly. Grrrr.
  24. I'm attempting to change the page name of a page, when it is saved, using the API. Below is my hook. The message appears (as a test) but the change never happens. Any thoughts? function myHook(HookEvent $event) { $page = $event->arguments(0); if ($page->template->name == 'work-detail') { if ($page->global_text) { $pageName = wire()->sanitizer->pageName($page->title . '-' . $page->global_text, true); } else { $pageName = wire()->sanitizer->pageName($page->title, true); } wire()->message($pageName); $page->setOutputFormatting(false); $page->setAndSave('name', $pageName); } } wire()->addHookAfter('Pages::save', null, 'myHook'); // On page SAVE run this hook
  25. Why does this return null? $page->products_sku->type I thought you could check a field's type? I know this works... $fields->products_sku->type But if I have the following, how could I check the type? $slides = $page->products_sku; // I need to return $slides type bd($fields->products_sku->type);
  • Create New...