Jump to content

a-ok

Members
  • Content Count

    663
  • Joined

  • Last visited

Community Reputation

69 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. 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
  2. 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?
  3. Any thoughts? Even a manual fix for now (hook or otherwise?)
  4. 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.
  5. $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.
  6. Thanks. This doesn't seem to work either, weirdly. $submissions = $pages->get("template=home")->submissions; foreach($submissions as $s) { $s->delete(); } $submissions->save();
  7. 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.
  8. 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
  9. 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'); } }
  10. 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?
  11. 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.
  12. 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.
  13. 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
  14. 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?
  15. 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');
×
×
  • Create New...