Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/01/2020 in all areas

  1. We got hit by hurricane/tropical storm Zeta overnight Wednesday and it took down the power lines in our neighborhood, and in many places in Atlanta. We aren’t supposed to get the electricity back till Monday, though I’m hoping they might surprise us and have it back sooner. But I’m basically offline other than my cell phone, charged in the car. I work off a desktop computer (iMac) so not able to do any kind of computer work until the electricity is back. As a result, I don’t have any updates for you this week. Though I was making great progress on the ProcessWire modules directory site up until the storm came through and we lost electricity. For now my job is to keep the flashlights working and find ways to keep what’s left of the food from going bad (since the fridge/freezer is also offline). The same thing happened with hurricane Irma, back in ProcessWire 3.0.75. It took out the power for several days. Though we weren’t in the middle of a covid hotspot back then. The deal is that Atlanta has a lot of big old trees, and all the power lines are above ground. So any time a significant storm rolls through, it knocks down a tree, the tree knocks down a power line, and the power goes out. Atlanta is pretty big, so multiply that by a few hundred trees and power lines (and a pandemic), and much of the city is out for awhile. Even a little storm sometimes knocks out the power for a few hours. That’s just one of the joys of where I live. I’m sorry about that, but since we’re supposed to be back online by Monday, I expect to have good updates for you next week. Thanks for reading and have a great weekend!
    3 points
  2. @modifiedcontent you can do $users->find("roles=superuser"); $users->find("roles=superuser")->first; yes, PW doesn't limit the number of superusers to just one single user.
    1 point
  3. I don't think so... the trick with PW hooks is to find out which hook to use, and whether to use before or after. Page::loaded seems to be the wrong method to hook into for what you want to achieve. Here are some code-bits I used in the past, and they all work as expected (inside site/ready.php) $this->addHookAfter('Pages::saveReady', function (HookEvent $event) { $page = $event->arguments[0]; // ---------- $pages->addHookAfter("ProcessPageEdit::buildForm", function (HookEvent $event) { $page = $event->object->getPage(); $form = $event->return; // ---------- $this->addHookBefore('Pages::saved(template=invoice, parent=23444)', function(HookEvent $event) { $page = $event->arguments(0);
    1 point
  4. Yes, this is easiest to do if you apply the sorting as the page is saved. So you won't see the sorting immediately after the images are uploaded, but will see the sorting after the page is saved and Page Edit reloads. In the examples below you would add the hook code to /site/ready.php The sort settings for child pages prevents the editor from making any other sort order apart from the one specified. So if you want something like that for images, where the newest images are sorted first, it's very simple: $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); $pages = $event->object; if($page->template == 'your_template') { if($page->isChanged('your_images_field')) { // Sort the images from newest to oldest $page->your_images_field->sort('-created'); } } }); But if you want to sort newly uploaded images first once the page is saved, but still let your editors customise the sort order after that, then you can use this hook: $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); $pages = $event->object; if($page->template == 'your_template') { if($page->isChanged('your_images_field')) { // Get the old version of the page, without the current changes $old_page = $pages->getById($page->id, [ 'cache' => false, 'getFromCache' => false, 'getOne' => true, ]); // Get the names of the existing images on the old page $existing_image_names = $old_page->getFormatted('your_images_field')->implode('|', 'basename'); // Get the newly added images $new_images = $page->your_images_field->find("basename!=$existing_image_names"); // Prepend the new images to the start of the Pageimages WireArray foreach($new_images as $new_image) { $page->your_images_field->prepend($new_image); } } } });
    1 point
  5. I currently manage a webshop with 225k products from around 60 suppliers and few millions of euros in yearly sales. I will share a bit from my experience, the issues I encountered and the facts you will want to consider before you start picking your solution. Self or Client Questionnaire 1. What is the max number of products your shop will have in 5 years from now? based on that you will need yo explain and educate the client why he will need an erp or pim software. 2. How many supplies you estimate that you will have and how they deliver the data. how often the product data is updated? 3. Whats is the monthly /yearly marketing budget? (Looking for only long term partnerships, I usually avoid signing a DEV& SEO contract with someone who has no idea of their marketing budget. It might sound crazy... but there is a clear view that your client will have enormous SEO expectations with No or limited budget. Main Issues : - each supplier comes with their products in a different template, filetype and the way they notify their resellers about the price updates. - for a big shop you will always want to work with a product information management (PIM) software. Are you ready to build your own PIM? - in order to increase your sales you will always want to send your products feed to site like amazon, google shopping etc... are you ready to invest and develop those solutions? - most of the shops are required to be connected with an ERP solution and at the end of the day you will need to make those systems to work together as much as possible. SHOP-ERP-PIM and resellers websites if any. My advice is to choose the only solution that is stable, capable and really secure. The multitude of plugins in store its always a plus and i will always like to pay 200$ on a good plugin than to develop it from scratch with a final cost of 2k. Please don’t try to reinvent the weel !!! Give yourself the luxury to work on marketing and SEO. Increasing your sales and google rankings are the only things that really matters at the end. Good luck!
    1 point
  6. Here's a hook (add to /site/ready.php) that allows you to set a description and your own help notes for each checkbox in the Status field: // Add some extra notes to the options in the Status field of Page Edit $wire->addHookAfter('ProcessPageEdit::buildFormSettings', function(HookEvent $event) { /** @var InputfieldWrapper $form */ $form = $event->return; $status = $form->getChildByName('status'); if(!$status) return; // Add a description to the field if you like $status->description = 'You can apply various statuses to this page to control its visibility and editability.'; $options = $status->options; // Define your notes here $notes = [ 2048 => 'Peter Piper picked a peck of pickled peppers.', // Unpublished 1024 => 'How much wood would a woodchuck chuck, if a woodchuck could chuck wood?', // Hidden 4 => 'She sells sea shells by the seashore.', // Locked ]; foreach($options as $key => $value) { if(!isset($notes[$key])) continue; $options[$key] .= "[br]{$notes[$key]}[br] "; } $status->options = $options; });
    1 point
  7. There was a suggestion here in the forum recently that front-end editing works best when you are using the same version of jQuery in your template that PW uses in the admin back-end. So that is something to try.
    1 point
  8. $image = $page->images->get("name=picture.jpg");
    1 point
×
×
  • Create New...