Skip to content

Instantly share code, notes, and snippets.

@jonwilcox
jonwilcox / private.application.profile_templates.php
Created June 25, 2015 14:26
Adds a custom "Profile Template" field to the LiveWhale Profile Type editor and uses its value to automatically display profiles of that type in that template.
<?php
$_LW->REGISTERED_APPS['profile_templates']=array(
'title'=>'Profile Templates',
'handlers'=>array('onSaveSuccess', 'onAfterEdit', 'onOutput', 'onEditor')
);
class LiveWhaleApplicationProfileTemplates { // overrides backend interfaces
/* The onAfterEdit() handler allows you to load additional custom data from the database after the default editor data is loaded in. */
@jonwilcox
jonwilcox / script
Last active August 29, 2015 14:07
Add News Story Featured Video
$('.lw_related_url:contains("YouTube Video")').each(function(){ // Get any related content links that contain the text "YouTube Video"
var link = $(this).find('a').attr('href'); // Get the href of the YouTube Link
var ID = RegExp('[?&]v=([^&]*)').exec(link)[1]; // Use a regular expression to get the video ID from the 'v' parameter
var $iframe = $('<iframe width="700" height="394" src="https://www.youtube.com/embed/'+ID+'" frameborder="0" allowfullscreen></iframe>'); // construct an iframe using the video ID
$('.news_image').addClass('video').prepend($iframe).fitVids(); // Add a class of 'video' to the .news_image div, prepend the iframe, and run fitvids on it
if($('.lw_related_url').length == 1) { // if that was the only link in the related content section
$('.related_content').remove(); // remove the whole section
} else {
@jonwilcox
jonwilcox / page.html
Last active December 18, 2015 09:09
Tag Selector Customizations
<!-- Example widget with class added to change tag selector to radio-button-behavior -->
<widget type="profiles">
<arg id="type">Faculty and Staff</arg>
<arg id="show_tags">true</arg>
<arg id="class">radio-selector</arg>
</widget>
<!-- Example widget with class added to change the tag selector label to "Departments" -->
<widget type="profiles">
<arg id="type">Faculty and Staff</arg>
@jonwilcox
jonwilcox / Profile Type
Last active December 11, 2015 17:39
Office Hours in Profile
// Your profile type editor should include custom fields similar to this
Monday Office Hours -> text (one line)
ID: profiles_4
Tuesday Office Hours -> text (one line)
ID: profiles_5
Wednesday Office Hours -> text (one line)
ID: profiles_6
@jonwilcox
jonwilcox / page.html
Last active December 19, 2018 17:07
YouTube Player from a Feeds Widget
<div class="youtube_widget">
<widget type="feeds">
<arg id="url">https://www.youtube.com/feeds/videos.xml?channel_id=UCouAv6HRsF5l6z-Opqy_Zgg</arg>
<arg id="format">{title}</arg>
<!-- You can set the max arg to whatever you want -->
<arg id="max">4</arg>
</widget>
</div>
@jonwilcox
jonwilcox / page.html
Last active October 8, 2015 23:48
Tabs from a Blurbs Widget
<widget type="blurbs">
<arg id="type">...</arg>
<arg id="group">...</arg>
<arg id="format"><div class="lw_blurbs_title">{title}</div><div class="lw_blurbs_body">{body}</div></arg>
<arg id="class">tabbed</arg>
</widget>