Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/25/2021 in all areas

  1. Excited to be learning REACT/NextJS. It's so 'on-trend'. I can double my hourly rate, take 3x as long to deliver a website with 2/3 of the Google Lighthouse results and who doesn't love the spinner while the component content loads? Doing a well optimised PW site with minimal JS, fast page loads, accessibility, SEO and more built in is so old hat. And even better, with JS frontends, the code maintenance goes on and on. No end to revenue possibilities. FML
    13 points
  2. Would showing the path instead of the title be okay ? I thought of a hook first but you could do the trick with a bit of CSS ul.pw-dropdown-menu-shorter li.ui-menu-item a::before { content: attr(title); margin-right: 3px; } ul.pw-dropdown-menu-shorter li.ui-menu-item a span { display: none; } (hopefully it doesn't target anything else, but from my quick testing it looks ok !) Before: After:
    3 points
  3. ? I was going to mention the 2 migrations modules, but they are not part of the core. I have taken a look at RockMigrations and will do again - it's just that my last migration was too messy to use as an initial attempt. I will try using it for a simple migration first, to get the hang of it.
    1 point
  4. @monollonom That's great, thanks for pointing me to this. Exactly what I was looking for.
    1 point
  5. The PHP timezones are stored in timezonedb, which is updated regularly: https://pecl.php.net/package/timezonedb You can check which version is used in your environment via timezone_version_get().
    1 point
  6. Not sure if this is what you're looking for (or if you already know about it) but explaining the focus feature to your editors might come handy for you when generating variations for srcset. If cropped, the image returned will respect the focus point and try to keep it centered.
    1 point
  7. Issue with screencast posted: https://github.com/processwire/processwire-issues/issues/1335
    1 point
  8. Did a little tinkering since I'm going to need another API endpoint for a new project soon and came up with this PoC: https://github.com/BitPoet/WireApi-PoC It's very crude and all as its just meant as a playground for ideas for now (wouldn't dare to clutter up the Wire namespace), and it does still use pages behind the scene (though not the implicit 404 redirect). Perhaps hiding the endpoints from the tree for everybody but superusers might be an option, but I haven't fully thought that out. Here are a few very simple examples of an API template (in fact, very close to what I thought up above): <?php namespace ProcessWire; $api->routeGET('/api/hello/{name}/', null, 'helloWorldApi', true); $api->routeGET('/api/pagelist/', 'apitemplates/pagelist') ->roles('superuser') ->setDebug(true) ; $api->route(['GET'], '/api/custom/{value}/', function($url, $values) { wire('api')->jsonResponse([ 'success' => true, 'youare' => wire('user')->name, 'data' => $values ]); })->check(function($url, $route, $check, $values) { return ctype_digit($values['value']); }); $api->handleRequest(['debug' => true]); // ________________Only function declarations below_____________________ function helloWorldApi($url, $values) { wire('api')->jsonResponse(['Hello', $values['name']]); } Oh, and it ships with a near-one-click endpoint installer ? Let me know what you think, and if you have any ideas about improvements or doing things differently, bring it on.
    1 point
  9. Yes, that's correct. The default value is only used for the interface, it's not applied to any existing pages. You can fix that in two ways: 1. Anywhere you use the value in your code, assume the default if no value is set. Something like this: // default to behavior option one $behaviorField = $fields->get('speciality_text_behavior'); $textBehavior = $page->speciality_text_behavior->id ?: $behaviorField->type->getOptions($behaviorField)->get('id=1')->id; You could also put that in a hook to get that behaviour anywhere you use this field. 2. Write a script to manually change the value of all pages with an empty value in that field to your new default: $valueMissing = $pages->find('speciality_text_behavior=""'); foreach ($valueMissing as $p) { $p->of(false); $p->speciality_text_behavior = 1; $p->save(); } You can quickly execute that snippet in the Tracy Debugger console module. BTW am I the only one who's annoyed by the field name? "speciality" in British English but "behavior" in American English, who does that ?
    1 point
  10. @ryan - what do you think about having a referencesRaw() page method. If you're outputting a long list of pages referenced to another page, often all you need are the title and url field values. As an example, I am outputting a list of publications for a staff member. I believe this would really speed things up. Thanks for considering.
    1 point
  11. This is the way. Performance is relative. Using a hook to check if a duplicate record exists will always be fast, or at the most have linear complexity. How many users do you expect to add each day? How many users / people entries in total do you have? If it's 10 million, then you'll have to start thinking about the performance of a uniqueness check, but if it's significantly less ... Besides performance, what other benefits do you hope to gain by using a unique index in SQL as opposed to a custom check on the interface-level (i.e. a ProcessWire hook)? The only thing I can think of is that uniqueness is guaranteed at database level, but is that going to matter to you? If you use the right hook, you can prevent duplicate entries from both the CMS interface and ProcessWire's API, so unless someone is going to manually insert records to your database through the command line, the result is identical. By the way, the unique setting for pages guarantees a globally unique page name, not uniqueness of an individual field. Just set the name to include the first name, last name and address (you can do that through the template settings or use a hook if you need more control) and use a hook to set new pages to unique. This will guarantee uniqueness for that combination of fields. Granted, it's only guaranteed on API level, not database level, but again, this might be absolutely enough for your use-case.
    1 point
  12. Surely this is the simplest approach, or maybe I am misunderstanding? foreach($page->fields as $f) { echo $page->$f; }
    1 point
  13. Hi @adrianmak You can achieve this by using hooks and my ReCaptcha module. First install the MarkupGoogleReCaptcha module then in file ready.php, write the following code : /* * replace the LAST occurence of $search by $replace in $subject */ function str_lreplace($search, $replace, $subject) { return preg_replace('~(.*)' . preg_quote($search, '~') . '~', '$1' . $replace, $subject, 1); } /* * replace the FIRST occurence of $search by $replace in $subject */ function str_freplace($search, $replace, $subject) { $from = '/'.preg_quote($search, '/').'/'; return preg_replace($from, $replace, $subject, 1); } $captchamod = wire('modules')->get("MarkupGoogleRecaptcha"); wire()->addHookProperty('Page::captcha', function($event) use ($captchamod) { $event->return = $captchamod; }); wire()->addHookAfter('Page::render', function($event) { $template = $event->object->template; $page = $event->object; if ($template == 'admin' && !wire('user')->isLoggedin()) { $captchaScript = $page->captcha->getScript() . '</body>'; $captchaHtml = $page->captcha->render() . '</form>'; $event->return = str_freplace('</form>', $captchaHtml, $event->return); $event->return = str_lreplace('</body>', $captchaScript, $event->return); } }); wire()->addHookAfter('Session::authenticate', function($event) { $page = wire('page'); $template = $page->template; if ($template == 'admin') { if ($page->captcha->verifyResponse() == false) { wire('session')->logout(); wire('session')->redirect(wire('config')->urls->admin); } } });
    1 point
  14. Here comes a small Christmas Present Go to setup > templates or setup > fields and find 2 important (or exportant) buttons below the list in the right corner to go here:
    1 point
×
×
  • Create New...