Concept:
I want to provider users the ability to click on a text link “add event” in a blog post, which will then open the scheduler lightbox with the fields “text”, “start_date” and “end_date” pre-populated.
I tried leveraging the information in this support page, but I haven’t gotten it to work: viewtopic.php?f=7&t=2990
What I’ve done so far:
Added “dhtmlxscheduler.js” to my wordpress template header page, so it is always available.
I added the following code so it appears at the bottom of each post: add event
Errors:
Upon first click of “add event” I get the following errors:
Uncaught TypeError: Object # has no method ‘time_picker’ - dhtmlxscheduler.js:31
scheduler.form_blocks.time.render - dhtmlxscheduler.js:31
scheduler._get_lightbox - dhtmlxscheduler.js:31
scheduler.showLightbox - dhtmlxscheduler.js:31
Upon second click of “add event” I get the following errors:
Uncaught TypeError: Cannot read property ‘getBoundingClientRect’ of undefined - dhtmlxscheduler.js:1
getOffset - dhtmlxscheduler.js:1
scheduler.showCover - dhtmlxscheduler.js:31
scheduler.showLightbox - dhtmlxscheduler.js:31
Just to validate, I checked the scheduler and no event is created.
Additional information: I have the private mode on Private Mode so users can only see their events, which when creating events I want to assure they get assigned to the current user.
I would appreciate any guidance in resolving this issue.
The problem is that addEventNow function is not completely separate from the scheduler and in fact it requires initialized scheduler object on the page.
So if you have scheduler on the page, you can create and use such link but if it’s completely unrelated page without scheduler then I am not quite sure.
Maybe it’s possible to trick scheduler — init it in some not visible div but that’s need to be verified
Or does anyone have any suggestions on opening the scheduler page and passing the AddEventNow variables in the url or via a post form to initiate the lightbox?
So I found a way to make it work, but it is not exactly as I had hoped, so if anyone has any other ideas I would like to hear them.
Anyway, here is what I did. I created a form tag at the end of each post that passes the title and other variables I want to the scheduler page when it is clicked. On the scheduler page (in PHP), I retrieve the first form element and then test if it is blank. If blank, it skips on to showing the normal scheduler page, as if they clicked on the scheduler page link. If not blank, then I add a div tag that contains the addEvent script (as noted in the previous posts) within an A tag. The text within the A tag is ‘Add to calendar’. When they click on the ‘Add to calendar’ link: (1) it opens the lightbox and allows them to then complete the calendar event creation and (2) hides the ‘Add to calendar’ link and shows a ‘Go back to previous page’ link.
I played with the idea of trying an onload() script, but I wasn’t comfortable with how the function would react on the page. This solution adds a few extra steps to the user experience, but at least they can always get back to where they came from.
I suggested different approach, check attachment. Tried it locally — seems to work Though note that with the current dhtmlxscheduler.js version lightbox will be displayed in the incorrect position. I will PM you with the latest (dev) version of this file, hopefully there won’t be additional issues. Though if they arise I can locate functions which are handling lightbox position so you could update only them.
Ilya, I have run into a challenge in trying the suggestion you provided.
The code I have generated is in the php templates versus a stand-along page. I tried echo do_shortcode(’[scheduler_plugin]’); to trigger the plugin, but it will not respond. I just echoes [scheduler_plugin] on the page. I have tried many different variations, outside and inside the loop, two brackets versus one bracket for the shortcode and nothing worked. I have done some research on do_shortcode() and all the suggestions I find are not helping.
Is there another way to trigger the scheduler_plugin job without the shortcode?
Try including scheduler.php (wordpress\wp-content\plugins\event-calendar-scheduler) on your page and when calling scheduler_init() function (it will should do same thing as [[scheduler_plugin]].
Thanks for the suggestion. I tried the include for schedule.php, here is the output on the html page.
[code]
Warning: include() [function.include]: URL file-access is disabled in the server configuration in [my blog site]/wp-content/themes/blogstew_Blue/my_index.php on line 7
Warning: include(http://[my blog site]/wp-content/plugins/event-calendar-scheduler/scheduler.php) [function.include]: failed to open stream: no suitable wrapper could be found in [my blog site]/wp-content/themes/blogstew_Blue/my_index.php on line 7
Warning: include() [function.include]: Failed opening ‘http://[my blog site]/wp-content/plugins/event-calendar-scheduler/scheduler.php’ for inclusion (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in [my blog site]/wp-content/themes/blogstew_Blue/my_index.php on line 7
I resolved this yet. The include is still causing issues, so I am still working on it. In the meantime, I do have the form passing parameter working. Not ideal but at least the concept is available to use.