Jump to content
fruid

ProcessEventCalendar

Recommended Posts

Hi friends,

just 7 months ago, I was "just" a designer and a rather semi-developer, still struggling with WordPress sites and more often than not delegating that work to pros. ProcessWire really helped me realising that it's not that hard after all (well it's still hard but it's doable) and you learn a lot just by doing it which has to be true for all developers anyway. So I started coding myself, I might also have to thank the 2020 pandemic to help me focus a bit more than usual, I created a bunch of websites using PW already – one of which I can't wait to put on showcases but it's still not live yet. That is one big personal milestone for me. The next milestone would be to give something back, and so I'd like to take on contributing some code I wrote, namely a event calendar for anyone to use. It's my first attempt doing this so please don't eat me alive. It's not a PW module yet (that's the plan however) just a git but I'm positive it will be useful once it works – well it works but it still needs more work – because if I had found a module that came close I wouldn't have started coding it myself :D

With that, I will appreciate all input, be it how to improve the .js (probably especially), or the templates, or guidance how to proceed turning this into a PW-module, and of course, in that last process, no pun intended, suggestions to make it more versatile for different needs.

git: github.com/bbblgmsp/ProcessEventCalendar
demo: http://foobar.roofaccess.org/events/

Thank you!

  • Like 9

Share this post


Link to post
Share on other sites

I made some progress with this, but I have some basic questions, because of some basic obstacles.

Since the module I'm trying to build makes an AJAX-request, how can I call the file? Obviously I want to put the ajax-called file inside the modules/EventsCalendar/ folder, and not inside the root folder.
My .js does the following at the moment which doesn't work for obvious reasons (forbidden):

pullEvents.open("GET", "../site/modules/EventsCalendar/_loadevents.php?m="+m+"&y="+y+"&d="+d+"&view="+view, true);

Also, I need to know how to include a javascript in that module. It's required for at least two of the class's functions. Is there a way to not require the user to add the

<script type="text/javascript" src="/path/to/js/file/"></script>

manually? How about css, how can I include that automatically?

Ideally I want to put .php, .js and .css files inside the module's-folder and everything gets included with no further ado from the user. The user would just need to call the methods inside their markup, add some additional css if needed and that's it.

Many thanks for help.

  • Thanks 1

Share this post


Link to post
Share on other sites
On 11/19/2020 at 4:51 PM, fruid said:

manually? How about css, how can I include that automatically?

Are you talking about adding the script in the PW backend or frontend? If backend, then it's simple:

// in your init() method of the module
$url = $this->wire->config->urls($this); // url to current module
$this->wire->config->scripts->add($url."YourScript.js");

 

On 11/19/2020 at 4:51 PM, fruid said:

Since the module I'm trying to build makes an AJAX-request, how can I call the file? Obviously I want to put the ajax-called file inside the modules/EventsCalendar/ folder, and not inside the root folder.

You can hook ProcessPageView::pageNotFound and define custom endpoints so you don't need to create a file for the ajax endpoint manually. A simple example can look like this:

  public function init() {
    $this->addHookBefore('ProcessPageView::pageNotFound', $this, 'handleWebhooks');
  }

  public function handleWebhooks($event) {
    $url = trim($event->arguments(1),"/");

    switch($url) {
      case "api-create-user":
        $this->createUser();
      break;
      case "api-delete-user":
        $this->deleteUser();
      break;
      // by default we exit early and don't do anything
      default: return;
    }

    // show 200 status code instead of 404
    // this could also be done in the method calls above
    http_response_code(200);
    die("success");
  }

 

There's also this thread with lots of infos: 

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By CachePuzzles
      Hi there,
      I'm probably missing something simple, but I'm just setting up my first site so I guess that's bound to happen.
      I've installed the LoginRegistration module and at first I was thinking that the confirmation emails weren't being sent. However I now see that new user confirmation emails are taking 20+ minutes to arrive. Is there a way to speed this up?
      Also the email is coming from processwire@mydomain - I couldn't found a place to change this.
      Any advice or help would be great!
      Brian
    • By Lmwt
      Hi there,
      I am new to PW but already very convinced. I need to build a dropdown button to browse in a collection of authors by country and language. The dropdown should be editable in the BACK and displayed on the same as the authors collection. I tried my luck with "PageField Creator" but I don't know how to display the dropdown, I simply used: 
      "$content .=$page->Land;" (the name of the select field)
      but nothing is displayed...
      I see there is a 2nd module out there to achieve this : "Select Options Fieldtype". I am not sure what is the difference, anyone has a tip?
      And a clear tutorial with the necessary steps to build this? I am a bit confused which should be the parent template or page, if it should have a file or not...
      Thanks a lot in advance!
    • By Noel Boss
      👋 PW Pros…
      I have some hooks that I need to bind at the init phase (or even __construct) and I was wondering, and I couldn't find a good and simple way to determine if I'm in the admin. Would be nice if there is a reliable short option to do so, but I can't seem to find one… Is there a coherent way to tell this no matter where I am?
      Right now, I use the following method inside one of my modules:
      public function isAdmin($page = null) { if ( strpos($this->input->url, $this->urls->admin) !== false || $this->process instanceof ProcessPageList || $this->process instanceof ProcessPageEdit || ($page instanceof Page && $page->rootParent->id == $this->config->adminRootPageID) ) { return true; } return false; } @ryan wouldn't it be nice to have something like wire()->isAdmin(); like wire()->user->isLoggedin(); to tell if we are in admin – very early on (probably even in __construct() phase of modules?
    • By benbyf
      Hi!
      Been doing some basic Twilio implementation for a client to enable them to automatically send text messages to registered users on page publish. As an upshot, I thought I would strip out the site specific work and stick up on github here: https://github.com/benbyford/TwilioChannels
      This modules pulls in the Twilio APi and enables you to send SMS messages from your front or backend.
      Send SMS message Truncate message to single message character limit Auto-select number from range of numbers depending on $To number country of origin–this enables you to send messages with a local number to that user if one added to the config. Templates usage:
      $twilio = $modules->get("TwilioChannels"); $twilio->sendSMS($toNumber, $message);  
×
×
  • Create New...