Skip to content

Instantly share code, notes, and snippets.

Avatar

Karl Hinze karlhinze

View GitHub Profile
@karlhinze
karlhinze / private.application.global_search.php
Last active Feb 10, 2017
A custom module for LiveWhale: easy global searches by ID
View private.application.global_search.php
<?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
@karlhinze
karlhinze / public.application.server_path.php
Last active Apr 19, 2017
LiveWhale custom module to save the current URL segments as XPHP variables
View public.application.server_path.php
<?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 / myscript.php
Created Nov 27, 2017
Example private LiveWhale script
View myscript.php
<?php
// Load LiveWhale
require $_SERVER['DOCUMENT_ROOT'].'/livewhale/nocache.php';
// Show errors
ini_set('display_errors', 1);
// Require logged-in user
if (!$_LW->isLiveWhaleUser()) {
View public.application.my_module.php
<?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 / private.application.custom_fields.php
Last active Dec 19, 2017
This new-and-improved LiveWhale module uses five handlers to get and set a custom field on an existing LiveWhale datatype.
View private.application.custom_fields.php
<?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 {
View suggest_to.js
// 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 / sample_create_event.php
Last active Apr 15, 2020
Sample LiveWhale event creation code
View sample_create_event.php
<?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,