Jump to content

Jozsef

Members
  • Content Count

    148
  • Joined

  • Last visited

Posts posted by Jozsef


  1. On 4/18/2016 at 5:19 PM, kixe said:

    Yes. The Backup is triggered by the hook function cronBackup() expecting a HookEvent as single argument, which is in fact not needed. If you want to trigger the backup from anywhere, just create a HookEvent object and call the cronBackup() function. Done.
     

    
    $event = new HookEvent;
    $modules->get('CronjobDatabaseBackup')->cronBackup($event);

    Thanks for the module, it is installed on all PW sites I've ever made.
    For the code snippet I still couldn't figure out how to run a database backup from an ordinary cron job.
    Will I have to create a php file with the hook and call that from the cron r can I call a module file directly from cron?
    Or is it possible to integrate it with the PWCron module?

    Update: I got it working in a PHP file this way based on @kixe's answer:

    <?php
    namespace ProcessWire;
    
    include_once("./index.php");
    
    $event = new HookEvent();
    $cron_backup = $modules->CronjobDatabaseBackup;
    $cron_backup->cronBackup($event);
    
    

     

    • Like 1

  2. I've played around with this module, thanks @Gadgetto, really impressive work. The demo was up and running in no time including registration etc… and I'be been looking for a feature-rich PW e-commerce solution for quite a while.

    One question though: is it possible to link the Snipcart customer to a Processwire user?
    I'm thinking of access control for membership sites.
    Is there an easy way to add/remove a role depending on the subscription status?

    Thanks again


  3. Hi, I'm thinking to implement your solution for a couple of primary school websites (they would comfortably fit into the free plan).
    I can see the module requires a separate title and message field for templates.
     

    Is it not possible to just use the existing title/headline and summary/body fields for the message purpose? 

    My purpose would be to provide parents to possibility to get notified each time a news article is published on the website.
    Thanks for the great work!


  4. @Robin S, Thanks that's well spotted, I haven't thought about the circular reference, I did run into that one when trying to preselect the current page in a form page reference field. But in that case I guess there's not much I could do, except for saving the field manually that doesn't seem to do any harm.
    Thanks again, I would have never thought about this.

    I do get the current page in the selector for $orders but that's why I tried to use the $page->id instead of the $page object itself. Didn't help much though, the changes only save for the second time. The strange thing is that the changed field values do populate in the hook and saved to all order but than it's lost between the hook and the actual save.


  5. I added a hook in ready.php to do some extra processing when the "price" field is changed in a page with "event" template.
    Now the hook is triggered but the price reverts back to the original one on the page after saving it in the admin.
    Changing and saving the second time saves the new price.
    Running ProcessWire 3.0.114.

    Why could that be? I presume this is not the expected behaviour.
    Here's my code:

    // Change prices and totals in orders on ticket price change
    $this->addHookAfter('Pages::saveReady(template=event)', function($event) {
      $page = $event->arguments('page');
      if($page->isChanged('price')) {
        $price = $page->price;
        // Get all orders for this event
        $orders = wire('pages')->find("template=order, order_event=$page->id");
        if (count($orders) > 0) {
          // Change order values based on the new ticket price
          foreach ($orders as $o) {
            $o->of(false); // Turn off output formatting so field values can be changed
            // Calculate new order values
            $o->price = $price; // Single price
            $o->total = $price * $o->quantity; // Total price for all tickets
            $o->handling = $o->total * 0.05; // 5% handling fee on the total price
            $payments_sum = wire('pages')->sum("template=payment, order_id=$o->id", "total"); // Calculate the total payments
            $o->balance = $o->total + $o->handling - $payments_sum; // Calculate the new balance based on the new price
            $o->save(['uncacheAll' => false]); // Save order but don't reset the page cache
            $o->of(); // Turn back on output formatting
          }
          // Add a new notification to confirm the changes
          $no_changed = count($orders);
          wire('notices')->message("{$no_changed} orders have been updated with the new price.");
        }
      }
      // Save field otherwise it only saves for the second time
      $page->save('price');
    });

    The only way I could get the page to save properly (for the fist time) was to add this at the end of the hook:

    // Save field otherwise it only saves for the second time
    $page->save('price');

    Can someone spot anything wrong with the code? Or is this a bug?


  6. I'm creating a new page from a form submission. It has been working perfectly but now it fails to save the new page with the error message:

    Error saving field "title" - Unable to save to 'field_title' for page that doesn't exist in pages table

    Can any of you spot any error in my code? It's directly in a template file.
    I probably just can't see the wood for the trees after hours of searching.
    The funny thing is that I haven't changed anything in that part of the template.

       // create the page
        $order = new Page();
        // Set the template
        $order->template = $templates->get("order");
        // Set the parent page
        $order->parent = $pages->get("/orders/");
    
        // Set the title/name field
        $order->title = $event_title . " - " . $u->first_name . " " . $u->last_name;
        // $order->headline = $headline;
        $order->order_event = $event;
        $order->order_user  = $u->id;
        $order->quantity = $qty;
        $order->price = $price;
        // Calculate and save total
        $order->total = $total;
        $order->handling = $handling;
        $order->balance = $balance;
    
        // save the order
        $order->of(false);
        $order->save();

    Update:

    New pages don't save from the backend either, giving the same error message for each field as admin notifications.


  7. On 10/13/2011 at 12:44 PM, ffub said:

    You are right to point out that the webcal: uri is informally used to denote iCal feeds. You can do this with the links in my examples above. While the [tt]->render[/tt] method will send the page as a download when accessed directly, I've tried it out with iCal and Google Calendar and it works just fine as a feed. If you wish to use the feed differently, such as sending different headers then [tt]->renderFeed[/tt] will let you do that. In addition to your suggested webcal:// link I tend to add Google Calendar links as many people use this now. Here's an example:

    
    <?php
    $gcalLink = urlencode($pages->get("/")->httpUrl . "events/ical");
    echo "<a href='webcal://{$config->httpHost}/events/ical'>Subscribe to Calendar</a><br/>";
    echo "<a href='https://www.google.com/calendar/render?cid=$gcalLink'>Add to Google Calendar</a>";
     

    I've just implemented the module on a new site after replacing the iCalcreator library with the latest one as the bundled one doesn't work on PHP 7. 
    I've done it the URL segment way suggested in the first post and used the ->render method.
    A few notes to the subscription links to save you some time:

    • webcal:// links worked on my Mac in Safari offering to subscribe in the Calendar app. When using https://, Safari just downloads the .ics file instead.
    • For iOS the link must be https://, not webcal:// and also had to modify the URL segment to "ical.ics" to be properly recognised.
      iOS tries to add the events, not the subscription without the .ics extension. Webcal:// links did not do anything when tapped on iOS13, simply nothing happened.
    • The Google Calendar link must contain an ULR encoded HTTP:// link, https links will give an error message and won't work.

  8. But again, I wouldn't disturb my visitors with yet another popup once they are happy that the original one has disappeared and they can finally get to their business. It's a legal necessity, I get it but most users I talk to hate them, myself included. So I stick to the very minimum that must be done and don't overdo it. I have a link in the footer that brings up the banner (as per instructions) but I won't invite the visitor to change their minds. 😉

    • Like 2

  9. Question on behalf of those who are not fluent in JS.
    I read through the js code but still not much smarter on how to setup Google Tag Manager so a tag would fire once consent was given.

    If I understand correctly I can setup a trigger in GTM that it checks. But would that trigger without page reload?
    I want Google Analytics report the current page load as soon as the consent is given so I won't loose tracking the entry page.

    Does the tag manager automatically tracks changes in the dataLayer or only on page load?


  10. Sorry if it was covered, I haven't found an answer by searching in Google or on the forum.
    The client is an estate agency and they want that all images, pdf brochures etc… would disappear from their site when they unpublish or delete a property page.

    Is that only possible with a custom module that hooks into unpublish or delete? It seems that ProcessWire doesn't delete the folder associated with the page from assets/files/ automatically. Similarly, if the page is unpublished, file uploads are still publicly available with the direct url.
    As a result, Google would keep them in their index forever giving false results.

    I understand that images can be used elsewhere in the site so it makes sense to keep them available, however since images/files belong to a page, keeping their public status synced could also make sense.
    Any suggestion is welcome, maybe I haven't thought of something else.


  11. 1 minute ago, Mikie said:

    Hey @kongondo, speaking of classnames, has there been any thought of rebranding to something more accessible for people outside the PW community, like eg Procommerce or Commercewire 🙃? Just feel like the name was always pretty random and doesn't really seem to have any particular meaning – worlds smallest turtle? – or evoke feelings of a power and capability.

    Yes, I completely agree with that and wanted to bring it up. Especially in the backend when previously we got "Padloper Orders" and "Padloper Reports" etc… It feels much more integrated when you look at something like "Craft Commerce" or "Perch Shop"

    • Like 1

  12. 10 minutes ago, kongondo said:

    The only core Fieldtype Padloper 2 uses are Pagefields (2), Textarea(2, 1 of which is rich text), Title and Images.

    Does that mean that products are not going to be ProcessWire pages the same way as they were in Padloper 1?
    It was such a great integration and made it super easy to edit product templates.
    Or will they still be available in the Templates section in admin?

    Great progress, can't wait to test it out.

    • Like 1

  13. On 1/13/2019 at 2:03 PM, kongondo said:

    2-column layout with vertical sidebar menu on the left and main content on the right (maybe with an option to collapse the sidebar)

    I put my vote on this one too. Conventions play a big role in usability and people still use computers or large enough tablets to get work done (e.g. managing a shop).

    • Like 2

  14. 6 minutes ago, kongondo said:

    A couple of things have derailed me some, so I cannot promise this. Beta testing will also take a bit of time, sorry.

    Count me in too. 🙂 I'm also waiting for this for a project where the website is done and I have to add the shop in later. No point to go with the old version. Let me know if you need any testing done, happy to help and pay the price.

    • Like 2
×
×
  • Create New...