Skip to content

Instantly share code, notes, and snippets.

View karlhinze's full-sized avatar

Karl Hinze karlhinze

View GitHub Profile
@karlhinze
karlhinze / sample_create_event.php
Last active April 15, 2020 18:45
Sample LiveWhale event creation code
<?php
// Sample event creation code
require $_SERVER['DOCUMENT_ROOT'].'/livewhale/nocache.php'; // load LW functions
$gid = 1; // id of group where the event should be created
$data_to_save = array( // create sample event
'gid'=>$gid,
// JS functionality for a redundant checkbox above the group suggest selector box, providing a checkbox for users to select to a specific chosen group (like the homepage or main communications team).
(function($, LW) {
// Make adjustments below to match the group id and group name
// to the calendar group you want to use for this feature.
var group_id = '8';
var group_name = 'Homepage';
if (LW.page === 'events_edit' || LW.page === 'events_sub_edit' || LW.page === 'news_edit') { // define pages to target with this transformation
if (livewhale.group_title != group_name) { // if we're not in the target group
@karlhinze
karlhinze / private.application.custom_fields.php
Last active December 19, 2017 20:09
This new-and-improved LiveWhale module uses five handlers to get and set a custom field on an existing LiveWhale datatype.
<?php
/*
This is a sample application designed to demonstrate how to add an additional custom field to a backend editor.
The example provided adds a "Dress Code" field to the existing event editor in LiveWhale. To add a custom field to the news editor, for example, follow the same example but change all references from events to news below.
*/
$_LW->REGISTERED_APPS['custom_fields'] = array( // configure this application module
'title' => 'Custom Fields',
'handlers' => array('onLoad', 'onAfterValidate', 'onSaveSuccess', 'onAfterEdit', 'onOutput')
);
class LiveWhaleApplicationCustomFields {
@karlhinze
karlhinze / public.application.my_module.php
Created November 27, 2017 15:48
Example LiveWhale module
<?php
// Save this file in /livewhale/client/modules/mymodule/ and login to LiveWhale to load the module for the first time.
$_LW->REGISTERED_APPS['my_module']=array(
'title'=>'My Module',
'handlers'=>array('onFormsSubmission'),
);
class LiveWhaleApplicationMyModule {
@karlhinze
karlhinze / myscript.php
Created November 27, 2017 15:40
Example private LiveWhale script
<?php
// Load LiveWhale
require $_SERVER['DOCUMENT_ROOT'].'/livewhale/nocache.php';
// Show errors
ini_set('display_errors', 1);
// Require logged-in user
if (!$_LW->isLiveWhaleUser()) {
@karlhinze
karlhinze / public.application.server_path.php
Last active April 19, 2017 14:30
LiveWhale custom module to save the current URL segments as XPHP variables
<?php
// Provide access to each segment of the server path with the variable: <xphp var="url_segment_[x]" />
$_LW->REGISTERED_APPS['server_path']=array(
'title'=>'Server Path',
'handlers'=>array('onLoad')
);
class LiveWhaleApplicationServerPath {
@karlhinze
karlhinze / private.application.global_search.php
Last active February 10, 2017 16:08
A custom module for LiveWhale: easy global searches by ID
<?php
$_LW->REGISTERED_APPS['global_search']=array( // configure this module
'title'=>'Global Search',
'handlers'=>array('onLoad')
);
class LiveWhaleApplicationGlobalSearch {
public function onLoad() { // in back-end search, if admin searching for ID, automatically search globally