SlideShare a Scribd company logo
1 of 72
Download to read offline
Naomi Royall
Tips and Tricks for
LiveWhale Development
2016
Getting the Ingredients Together
Global theme plus theme for special feature
Getting the Ingredients Together
Script numbers control loading order.
Modernizr need to go in site head.
Getting the Ingredients Together
Default widget format templates.
New defaults for different themes.
Getting the Ingredients Together
Widgets.less gets used by the widget editor preview.
Getting the Ingredients Together
Widget preview.
Getting the Ingredients Together
Template structure.
Separate templates for different group types.
Details templates are used for dynamic content.
Getting the Ingredients Together
Global can contain site-wide templates.
Getting the Ingredients Together
Includes contains reusable template elements.
<widget type="file"><arg id="path">/_ingredients/templates/includes/head.html</arg></widget>
Getting the Ingredients Together
Office templates group.
Getting the Ingredients Together
Getting the Ingredients Together
Getting the Ingredients Together
- Set up group template permissions.
- Save group.
- Set default page editing templates.
- Used when anyone in that group
creates a new page.
Default Templates
Default Templates
Default Templates www.nursing.upenn.edu/its/
Looking Out for Opportunities (or Potential Headaches)
- Do I need a new template?
- Would it be best to create a new theme?
- Themes keep styles, JavaScript and templates cleanly compartmentalized.
- Protect the rest of your site from experimental work.
- LESS is automatically compiled for you and error logs are generated.
- Simply add the theme variable to the page. You can place it in an editable area.
<xphp var="theme">timeline</xphp>
Keeping Widgets in Check
Keeping Widgets in Check Widgets → All Widgets
The widget manager shows us which widgets are used where. Only works for saved widgets.
Keeping Widgets in Check
- Use widget names that can easily be understood at a glance.
- The name can be changed any time. The widget ID is the only part used by LiveWhale.
- Add a thoughtful widget description:
- a summary of what it does
- why it is unique
- an example of where the widget is used
Keeping Widgets in Check
- Duplicate an existing widget when you’d like to alter the appearance for a new use-case.
- Or, carefully add the widget to the page and change one or two arguments with the source
code button (mother widget method).
- Save widgets in the widget manager.
- Keeps everything neat and organized…
- Which helps us to fix widgets
- Makes it easy to duplicate widgets
Avoid Stray Widgets!
- Only show html if a variable exists (you can nest conditionals two levels deep):
{<div class="news-date"> {date} </div><div class="news-summary"> |summary| </div>}
- Show another widget variable if a variable is empty:
{!summary:location_title}
- Remove markup from a variable by appending _clean (useful for removing links):
{title_clean}
Widget Formatting Options
- For regular content, from any group.
- Used when anyone creates a new widget.
- Useful for global widgets.
- Use the class .lw_widget_news
to style the widget (applies to
all news widgets).
- Different default formats for each theme: /theme/fancy-theme/widgets/news.format.html
Widget Default Format Templates
Remove the stuff you don’t need.
Clean Markup: for unique, snazzy widgets.
No need for list of items here!
An <article> would be better.
Always add custom classes to
widgets when styling is unique:
- “Apply custom class”
- “Wrap widget with markup”
Add classes required for jQuery plugins.
Wrap widget output with markup: <div class="fancy-slider">{widget}</div>
Format results with:
<article class="fancy-slider-item" style="background-image:url({image_src});">
<a class="link" hef="{href}"></a>
<h4 class="headline">{headline}</h4>
<div class="summary">{summary}</div>
</article>
Clean Markup: for unique, snazzy widgets.
More Advanced Widgets
- Use xphp page variables to change widget content on a page-by-page basis.
- Use xphp group variables to change widget content on a per-group basis.
- Example: Show events tagged with the page title:
Example: Featured Topics www.nursing.upenn.edu
Example: Featured Topics www.nursing.upenn.edu
Example: Featured Topics
Display tagged widget content:
<widget id="49_news_research_stories_topics_details">
<if var="has_news"/>
<xphp var="tags"/>
<arg id="tag">research</arg>
</widget>
<widget type="galleries_inline">
<if var="has_galleries"/>
<xphp var="tags"/>
</widget>
Example: Featured Topics
Show next and previous tags:
<widget type="tags">
<arg id="header">Next Topic:</arg>
<arg id="max">1</arg>
<arg id="min_items">3</arg>
<arg id="only_starred">true</arg>
<arg id="min_size">1</arg>
<arg id="max_size">1</arg>
<arg id="item_url">/details/tags.php</arg>
<arg id="filter" name="title" action="greater_than"><xphp var="tag_title"/></arg>
<arg id="sort_order">alphabetical</arg>
<arg id="clean_markup">true</arg>
</widget>
Example: Profiles Search
Example: Profiles Search
Use Quick Access to search through the results of a saved widget:
<h2>Quickly browse faculty by research area or keyword:</h2>
<form class="quickaccess-form">
<label class="screen-reader-text" for="faculty-quicksearch">Search faculty</label>
<input id="faculty-quicksearch" class="lw_qa_widget_88" type="text"
placeholder="Search faculty" data-qa-none-found="No faculty found.">
</form>
Example: Profiles Search
Use the data attribute to search over profile fields without displaying them in the results:
<widget type="profiles">
<arg id="type">Faculty</arg>
<arg id="paginate">false</arg>
<arg id="sort_order">alphabetical</arg>
<arg id="format"><a href="{href}" data-keywords="{profiles_78_clean}
{tags_starred_clean}">{name_clean}</a></arg>
</widget>
Search over name, “Faculty Expertise” and starred profile tags.
Example: Profiles Search
Example: Profiles Search
While we’re talking about search…
Use data-qa-none-found to change the no results message:
<input type="text" id="quicksearch" class="lw_qa lw_qa_widget_60" name="q"
placeholder="Search programs, people, practice areas" autocomplete="off"
data-qa-none-found="No quick results found. Press Enter to search." data-qa-max-results="20"
value="">
- Use the .editable class to make an area editable.
<div id="sidebar-content" class="editable optional">
<!-- Your editable content goes here -->
</div>
- Each editable element must have a unique ID.
- The .optional class allows that element to be hidden if
it doesn’t contain any content.
- When this element is hidden, the body gets class
.sidebar-content_hidden
Mastering the Page Editor
Mastering the Page Editor
- Use the .sidebar-content_hidden class to change the page
layout when there’s no sidebar content.
body.sidebar-content_hidden .main-content {
width: 100%;
}
- Use the .editable class to add site-wide styles that only
apply to editable areas.
.editable .lw_image {
margin-bottom: 10px;
max-width: 100%;
height:auto;
}
Mastering the Page Editor
- Include a clearfix on all editable areas.
.editable:before,
.editable:after {
content:'';
display: table;
clear: both;
}
- Add header styling for editable areas that may not apply
to headers on the homepage etc.
.editable h2 {
font-size: 26px;
color: red;
}
Mastering the Page Editor
Mastering the Page Editor
Mastering the Page Editor
Use the class .lw_editor_on to change the appearance while the page is being edited.
Use the widget editor to
add the class .empty when
there’s no image.
<arg id="no_results">
<div class="header-image
empty"></div>
</arg>
Mastering the Page Editor
Mastering the Page Editor
Example: display a suggestion to include a header image on the page.
.header-image.empty {
display:none;
}
.lw_editor_on .header-image.empty {
display: block;
background-color: #ccc;
}
.lw_editor_on .header-image.empty:after {
content: 'Tag an image "header image" to appear here.';
display: block;
}
Mastering the Page Editor www.ursinus.edu/uc-magazine/
Mastering the Page Editor www.ursinus.edu/uc-magazine/
Mastering the Page Editor
Example: Insert images in the page editor and move them around after the page is saved.
/* position title image left of article divider */
#title img {
position: absolute;
left: 0;
top: 0;
transform: translate(-90.5%, -7%);
}
/* this treatment allows images to be positioned correctly and stay visible */
.lw_editor_on #title img {
position: relative;
transform: translateX(0);
}
Mastering the Page Editor
- Add buttons to the page editor toolbar.
$_LW->CONFIG['TOOLBAR_ADD_BUTTONS']=array('blockquote’, ‘hr');
- Edit the Formats dropdown to provide more styling options.
$_LW->REGISTERED_APPS['pages_editor']['custom']['style_formats']= array(
array('title'=>'Text styles:','selector'=>'p,h2,h4'),
array('title'=>'Small type','selector'=>'p,h2,h4','classes'=>'font-small'),
array('title'=>'Link styles:','selector'=>'a'),
array('title'=>'Button','selector'=>'a','classes'=>'button1'),
​);
Mastering the Page Editor
- Customize the default gallery type used when adding a slideshow in the page editor.
$_LW->REGISTERED_MODULES['galleries']['custom']['default_type']='mini';
- Also customizes the gallery type for “Get Code” links in the gallery manager.
- Custom galleries are kept in the theme under /my_theme/galleries/
Mastering the Page Editor
- Call a JavaScript function after the page is edited.
$('body').bind('stopEdit.lw', function(){
// do this after LiveWhale page edit/save
});
- Similarly for the calendar:
$('body').bind('calLoad.lwcal', function() {
​ // do this each time the calendar view is refreshed
});
Owning Your Site
- Create a style guide for editors.
- Write informative widget descriptions.
- Add twice as many comments to your code as you think you need.
- Keep file paths predictable and file names understandable.
- Document everything unique to your site for future developers, for us, for yourself.
- Where’s the best place to keep all this documentation?
GetHelp.livewhale.com
Owning Your Site
Owning Your Site
Owning Your Site
Add a navigation widget to the dashboard in livewhale/client/private.config.php:
$_LW->CONFIG['DASHBOARD'] = array(
'left' => array(
array(
'LiveWhale CMS Help',
'<br/><widget id="127_help_navigation"></widget>'
),
),
);
GetHelp.livewhale.com
Example: Careers Microsite www.lakeforest.edu/careers/pathways
- Use a new theme (CSS & JavaScript).
- Add new default widget formats.
- Create new templates.
- New LiveWhale theme structure makes it easy
to keep everything bundled together.
Example: Careers Microsite www.lakeforest.edu/careers/pathways
Example: Careers Microsite www.lakeforest.edu/careers/pathways
Example: Digital Publishing www.ursinus.edu/uc-magazine/
Example: Digital Publishing www.ursinus.edu/uc-magazine/
Example: Digital Publishing www.ursinus.edu/uc-magazine/
Example: Digital Publishing www.ursinus.edu/uc-magazine/
THE END
Bonus code snippets →
<head>
<title><xphp var="page_title"/> • <xphp var="group_title"/> • <xphp var="client_name"/></title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<widget type="file"><arg id="path">/templates/includes/head.html</arg></widget>
</head>
LiveWhale Template Head
<xphp content="true">
<if var="x" value=""/>
<content>
<!-- Show this if x is empty -->
</content>
<else content="true">
<content>
<!-- Show this if x is non-empty -->
</content>
</else>
</xphp>
LiveWhale Conditional Statements
https://livewhale.desk.com/customer/en/portal/articles/2490653-xphp-if-then-else-statement
<xphp content="true" ifmode="or">
<if var="profiles_22"/>
<if var="profiles_23"/>
<content>
<!-- one of these variables is non empty -->
</content>
</xphp>
LiveWhale Conditional Statements
https://livewhale.desk.com/customer/en/portal/articles/1522002-xphp-and-or-statements
<xphp content="true">
<if var="server_path" not_equals="{group_directory}index.php"/>
<content>
<!-- show this if it's not the group homepage -->
</content>
</xphp>
LiveWhale Conditional Statements
<xphp content="true">
<if var="has_tag_red"/>
<content>
<!-- Show this if tagged with "red" -->
</content>
</xphp>
LiveWhale Conditional Statements
https://livewhale.desk.com/customer/en/portal/articles/2488862-check-if-tag-exists-in-xphp
Tells the functions inside to use LiveWhale’s jQuery and keeps variables locally scoped.
http://adripofjavascript.com/blog/drips/an-introduction-to-iffes-immediately-invoked-function-express
ions.html
;(function($) {
// Assigns LiveWhale's jQuery to $
}(livewhale.jQuery));
LiveWhale jQuery IIFE
(Immediately Invoked Function Expression)
You can put the plugin JS in a custom theme OR call the plugin JavaScript on some pages only.
$.ajax({
url: "/scripts/plugin.js", // Use an IIFE in plugin.js if the plugin requires jQuery
dataType: "script",
cache: false
}).done(function() {
// Do stuff here using the plugin
});
Using Plugins in LiveWhale
Keeping Performance in Mind
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};
Example:
var myFunc = debounce( function() {
// do something here
}, 250, true);
Reduces the number of timed a function is called when resizing the window, scrolling, etc.
JavaScript debounce function from Underscore.js:
https://davidwalsh.name/javascript-debounce-function
Add this to you events detail file to display all events in the calendar instead of in their own
details template:
<?php
if (!empty($_GET['id'])) {
die('<html><head><meta http-equiv="refresh"
content="0;URL=/calendar/#event_id/'.(int)$_GET['id'].'/view/event">
</head><body><script
type="text/javascript">window.location.href="/calendar/#event_id/'.(int)$_GET['id'].'/view/event";
</script></body></html>');
};
require $_SERVER['DOCUMENT_ROOT'].'/livewhale/frontend.php';
?>
Displaying Events Only in the Calendar

More Related Content

What's hot

Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)Ivan Chepurnyi
 
Introduction to ZendX jQuery
Introduction to ZendX jQueryIntroduction to ZendX jQuery
Introduction to ZendX jQuerydennisdc
 
Customizing the Django Admin
Customizing the Django AdminCustomizing the Django Admin
Customizing the Django AdminLincoln Loop
 
Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017Elyse Kolker Gordon
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsEPAM Systems
 
Mason - A Template system for us Perl programmers
Mason - A Template system for us Perl programmersMason - A Template system for us Perl programmers
Mason - A Template system for us Perl programmersJerome Eteve
 
Empowering users: modifying the admin experience
Empowering users: modifying the admin experienceEmpowering users: modifying the admin experience
Empowering users: modifying the admin experienceBeth Soderberg
 
Training in Android with Maven
Training in Android with MavenTraining in Android with Maven
Training in Android with MavenArcadian Learning
 
Intro to emberjs
Intro to emberjsIntro to emberjs
Intro to emberjsMandy Pao
 
How to make a WordPress theme
How to make a WordPress themeHow to make a WordPress theme
How to make a WordPress themeHardeep Asrani
 
Angular presentation
Angular presentationAngular presentation
Angular presentationMatus Szabo
 
WordPress: Adding user-role
WordPress: Adding user-roleWordPress: Adding user-role
WordPress: Adding user-roleMayeenul Islam
 
Html5, a gentle introduction
Html5, a gentle introduction Html5, a gentle introduction
Html5, a gentle introduction Diego Scataglini
 
Rails 3 Beginner to Builder 2011 Week 8
Rails 3 Beginner to Builder 2011 Week 8Rails 3 Beginner to Builder 2011 Week 8
Rails 3 Beginner to Builder 2011 Week 8Richard Schneeman
 
Fernando F. Gallego - Efficient Android Resources 101
Fernando F. Gallego - Efficient Android Resources 101Fernando F. Gallego - Efficient Android Resources 101
Fernando F. Gallego - Efficient Android Resources 101Fernando Gallego
 
How to migrate Cakephp 1.x to 2.x
How to migrate Cakephp 1.x to 2.xHow to migrate Cakephp 1.x to 2.x
How to migrate Cakephp 1.x to 2.xAndolasoft Inc
 

What's hot (20)

Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)Making Magento flying like a rocket! (A set of valuable tips for developers)
Making Magento flying like a rocket! (A set of valuable tips for developers)
 
Introduction to ZendX jQuery
Introduction to ZendX jQueryIntroduction to ZendX jQuery
Introduction to ZendX jQuery
 
Customizing the Django Admin
Customizing the Django AdminCustomizing the Django Admin
Customizing the Django Admin
 
Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017
 
Django Vs Rails
Django Vs RailsDjango Vs Rails
Django Vs Rails
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript Basics
 
Mason - A Template system for us Perl programmers
Mason - A Template system for us Perl programmersMason - A Template system for us Perl programmers
Mason - A Template system for us Perl programmers
 
Empowering users: modifying the admin experience
Empowering users: modifying the admin experienceEmpowering users: modifying the admin experience
Empowering users: modifying the admin experience
 
Mobile themes, QR codes, and shortURLs
Mobile themes, QR codes, and shortURLsMobile themes, QR codes, and shortURLs
Mobile themes, QR codes, and shortURLs
 
Training in Android with Maven
Training in Android with MavenTraining in Android with Maven
Training in Android with Maven
 
Intro to emberjs
Intro to emberjsIntro to emberjs
Intro to emberjs
 
How to make a WordPress theme
How to make a WordPress themeHow to make a WordPress theme
How to make a WordPress theme
 
Angular presentation
Angular presentationAngular presentation
Angular presentation
 
An Introduction to Drupal
An Introduction to DrupalAn Introduction to Drupal
An Introduction to Drupal
 
Fundamental JQuery
Fundamental JQueryFundamental JQuery
Fundamental JQuery
 
WordPress: Adding user-role
WordPress: Adding user-roleWordPress: Adding user-role
WordPress: Adding user-role
 
Html5, a gentle introduction
Html5, a gentle introduction Html5, a gentle introduction
Html5, a gentle introduction
 
Rails 3 Beginner to Builder 2011 Week 8
Rails 3 Beginner to Builder 2011 Week 8Rails 3 Beginner to Builder 2011 Week 8
Rails 3 Beginner to Builder 2011 Week 8
 
Fernando F. Gallego - Efficient Android Resources 101
Fernando F. Gallego - Efficient Android Resources 101Fernando F. Gallego - Efficient Android Resources 101
Fernando F. Gallego - Efficient Android Resources 101
 
How to migrate Cakephp 1.x to 2.x
How to migrate Cakephp 1.x to 2.xHow to migrate Cakephp 1.x to 2.x
How to migrate Cakephp 1.x to 2.x
 

Similar to Tips and tricks for optimizing LiveWhale development

Easy Guide to WordPress Theme Integration
Easy Guide to WordPress Theme IntegrationEasy Guide to WordPress Theme Integration
Easy Guide to WordPress Theme IntegrationSankhala Info Solutions
 
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014Chad Windnagle
 
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ..."Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...DrupalCamp Kyiv
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme EnlightenmentAmanda Giles
 
Miva ReadyThemes for Store Owners
Miva ReadyThemes for Store OwnersMiva ReadyThemes for Store Owners
Miva ReadyThemes for Store OwnersMiva
 
integrasi template admin lte terbaru dengan laravel 7
integrasi template admin lte terbaru dengan laravel 7integrasi template admin lte terbaru dengan laravel 7
integrasi template admin lte terbaru dengan laravel 7Adi Nata
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017Amanda Giles
 
ViA Bootstrap 4
ViA Bootstrap 4ViA Bootstrap 4
ViA Bootstrap 4imdurgesh
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes ramakesavan
 
Wordpress workflow for an agency world
Wordpress workflow for an agency worldWordpress workflow for an agency world
Wordpress workflow for an agency worldChris Lowe
 
Writing your own WordPress themes and plugins
Writing your own WordPress themes and pluginsWriting your own WordPress themes and plugins
Writing your own WordPress themes and pluginsStephanie Wells
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction DjangoWade Austin
 
Why NextCMS: Layout Editor
Why NextCMS: Layout EditorWhy NextCMS: Layout Editor
Why NextCMS: Layout EditorPhuoc Nguyen Huu
 
Joomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic TemplatesJoomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic TemplatesAndy Wallace
 
Joomla Day UK 2009 Basic Templates
Joomla Day UK 2009 Basic TemplatesJoomla Day UK 2009 Basic Templates
Joomla Day UK 2009 Basic TemplatesChris Davenport
 
Developing formultisite
Developing formultisiteDeveloping formultisite
Developing formultisiteMarty Thornley
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practicesmarkparolisi
 
Html 5, a gentle introduction
Html 5, a gentle introductionHtml 5, a gentle introduction
Html 5, a gentle introductionDiego Scataglini
 
Modern Theming & The Future of WordPress- Working with Full Site Editing and ...
Modern Theming & The Future of WordPress- Working with Full Site Editing and ...Modern Theming & The Future of WordPress- Working with Full Site Editing and ...
Modern Theming & The Future of WordPress- Working with Full Site Editing and ...WP Engine
 
Designing for magento
Designing for magentoDesigning for magento
Designing for magentohainutemicute
 

Similar to Tips and tricks for optimizing LiveWhale development (20)

Easy Guide to WordPress Theme Integration
Easy Guide to WordPress Theme IntegrationEasy Guide to WordPress Theme Integration
Easy Guide to WordPress Theme Integration
 
May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014May the core be with you - JandBeyond 2014
May the core be with you - JandBeyond 2014
 
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ..."Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...
"Paragraphs are more powerful than you can expect" from Vasily Jaremchuk for ...
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 
Miva ReadyThemes for Store Owners
Miva ReadyThemes for Store OwnersMiva ReadyThemes for Store Owners
Miva ReadyThemes for Store Owners
 
integrasi template admin lte terbaru dengan laravel 7
integrasi template admin lte terbaru dengan laravel 7integrasi template admin lte terbaru dengan laravel 7
integrasi template admin lte terbaru dengan laravel 7
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 
ViA Bootstrap 4
ViA Bootstrap 4ViA Bootstrap 4
ViA Bootstrap 4
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes
 
Wordpress workflow for an agency world
Wordpress workflow for an agency worldWordpress workflow for an agency world
Wordpress workflow for an agency world
 
Writing your own WordPress themes and plugins
Writing your own WordPress themes and pluginsWriting your own WordPress themes and plugins
Writing your own WordPress themes and plugins
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction Django
 
Why NextCMS: Layout Editor
Why NextCMS: Layout EditorWhy NextCMS: Layout Editor
Why NextCMS: Layout Editor
 
Joomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic TemplatesJoomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic Templates
 
Joomla Day UK 2009 Basic Templates
Joomla Day UK 2009 Basic TemplatesJoomla Day UK 2009 Basic Templates
Joomla Day UK 2009 Basic Templates
 
Developing formultisite
Developing formultisiteDeveloping formultisite
Developing formultisite
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
 
Html 5, a gentle introduction
Html 5, a gentle introductionHtml 5, a gentle introduction
Html 5, a gentle introduction
 
Modern Theming & The Future of WordPress- Working with Full Site Editing and ...
Modern Theming & The Future of WordPress- Working with Full Site Editing and ...Modern Theming & The Future of WordPress- Working with Full Site Editing and ...
Modern Theming & The Future of WordPress- Working with Full Site Editing and ...
 
Designing for magento
Designing for magentoDesigning for magento
Designing for magento
 

Recently uploaded

MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 

Recently uploaded (20)

MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 

Tips and tricks for optimizing LiveWhale development

  • 1. Naomi Royall Tips and Tricks for LiveWhale Development 2016
  • 2. Getting the Ingredients Together Global theme plus theme for special feature
  • 3. Getting the Ingredients Together Script numbers control loading order. Modernizr need to go in site head.
  • 4. Getting the Ingredients Together Default widget format templates. New defaults for different themes.
  • 5. Getting the Ingredients Together Widgets.less gets used by the widget editor preview.
  • 6. Getting the Ingredients Together Widget preview.
  • 7. Getting the Ingredients Together Template structure. Separate templates for different group types. Details templates are used for dynamic content.
  • 8. Getting the Ingredients Together Global can contain site-wide templates.
  • 9. Getting the Ingredients Together Includes contains reusable template elements. <widget type="file"><arg id="path">/_ingredients/templates/includes/head.html</arg></widget>
  • 10. Getting the Ingredients Together Office templates group.
  • 14. - Set up group template permissions. - Save group. - Set default page editing templates. - Used when anyone in that group creates a new page. Default Templates
  • 17. Looking Out for Opportunities (or Potential Headaches) - Do I need a new template? - Would it be best to create a new theme? - Themes keep styles, JavaScript and templates cleanly compartmentalized. - Protect the rest of your site from experimental work. - LESS is automatically compiled for you and error logs are generated. - Simply add the theme variable to the page. You can place it in an editable area. <xphp var="theme">timeline</xphp>
  • 19. Keeping Widgets in Check Widgets → All Widgets The widget manager shows us which widgets are used where. Only works for saved widgets.
  • 20. Keeping Widgets in Check - Use widget names that can easily be understood at a glance. - The name can be changed any time. The widget ID is the only part used by LiveWhale. - Add a thoughtful widget description: - a summary of what it does - why it is unique - an example of where the widget is used
  • 21. Keeping Widgets in Check - Duplicate an existing widget when you’d like to alter the appearance for a new use-case. - Or, carefully add the widget to the page and change one or two arguments with the source code button (mother widget method).
  • 22. - Save widgets in the widget manager. - Keeps everything neat and organized… - Which helps us to fix widgets - Makes it easy to duplicate widgets Avoid Stray Widgets!
  • 23. - Only show html if a variable exists (you can nest conditionals two levels deep): {<div class="news-date"> {date} </div><div class="news-summary"> |summary| </div>} - Show another widget variable if a variable is empty: {!summary:location_title} - Remove markup from a variable by appending _clean (useful for removing links): {title_clean} Widget Formatting Options
  • 24. - For regular content, from any group. - Used when anyone creates a new widget. - Useful for global widgets. - Use the class .lw_widget_news to style the widget (applies to all news widgets). - Different default formats for each theme: /theme/fancy-theme/widgets/news.format.html Widget Default Format Templates
  • 25. Remove the stuff you don’t need. Clean Markup: for unique, snazzy widgets. No need for list of items here! An <article> would be better. Always add custom classes to widgets when styling is unique: - “Apply custom class” - “Wrap widget with markup”
  • 26. Add classes required for jQuery plugins. Wrap widget output with markup: <div class="fancy-slider">{widget}</div> Format results with: <article class="fancy-slider-item" style="background-image:url({image_src});"> <a class="link" hef="{href}"></a> <h4 class="headline">{headline}</h4> <div class="summary">{summary}</div> </article> Clean Markup: for unique, snazzy widgets.
  • 27. More Advanced Widgets - Use xphp page variables to change widget content on a page-by-page basis. - Use xphp group variables to change widget content on a per-group basis. - Example: Show events tagged with the page title:
  • 28. Example: Featured Topics www.nursing.upenn.edu
  • 29. Example: Featured Topics www.nursing.upenn.edu
  • 30. Example: Featured Topics Display tagged widget content: <widget id="49_news_research_stories_topics_details"> <if var="has_news"/> <xphp var="tags"/> <arg id="tag">research</arg> </widget> <widget type="galleries_inline"> <if var="has_galleries"/> <xphp var="tags"/> </widget>
  • 31. Example: Featured Topics Show next and previous tags: <widget type="tags"> <arg id="header">Next Topic:</arg> <arg id="max">1</arg> <arg id="min_items">3</arg> <arg id="only_starred">true</arg> <arg id="min_size">1</arg> <arg id="max_size">1</arg> <arg id="item_url">/details/tags.php</arg> <arg id="filter" name="title" action="greater_than"><xphp var="tag_title"/></arg> <arg id="sort_order">alphabetical</arg> <arg id="clean_markup">true</arg> </widget>
  • 33. Example: Profiles Search Use Quick Access to search through the results of a saved widget: <h2>Quickly browse faculty by research area or keyword:</h2> <form class="quickaccess-form"> <label class="screen-reader-text" for="faculty-quicksearch">Search faculty</label> <input id="faculty-quicksearch" class="lw_qa_widget_88" type="text" placeholder="Search faculty" data-qa-none-found="No faculty found."> </form>
  • 34. Example: Profiles Search Use the data attribute to search over profile fields without displaying them in the results: <widget type="profiles"> <arg id="type">Faculty</arg> <arg id="paginate">false</arg> <arg id="sort_order">alphabetical</arg> <arg id="format"><a href="{href}" data-keywords="{profiles_78_clean} {tags_starred_clean}">{name_clean}</a></arg> </widget> Search over name, “Faculty Expertise” and starred profile tags.
  • 37. While we’re talking about search… Use data-qa-none-found to change the no results message: <input type="text" id="quicksearch" class="lw_qa lw_qa_widget_60" name="q" placeholder="Search programs, people, practice areas" autocomplete="off" data-qa-none-found="No quick results found. Press Enter to search." data-qa-max-results="20" value="">
  • 38. - Use the .editable class to make an area editable. <div id="sidebar-content" class="editable optional"> <!-- Your editable content goes here --> </div> - Each editable element must have a unique ID. - The .optional class allows that element to be hidden if it doesn’t contain any content. - When this element is hidden, the body gets class .sidebar-content_hidden Mastering the Page Editor
  • 39. Mastering the Page Editor - Use the .sidebar-content_hidden class to change the page layout when there’s no sidebar content. body.sidebar-content_hidden .main-content { width: 100%; } - Use the .editable class to add site-wide styles that only apply to editable areas. .editable .lw_image { margin-bottom: 10px; max-width: 100%; height:auto; }
  • 40. Mastering the Page Editor - Include a clearfix on all editable areas. .editable:before, .editable:after { content:''; display: table; clear: both; } - Add header styling for editable areas that may not apply to headers on the homepage etc. .editable h2 { font-size: 26px; color: red; }
  • 43. Mastering the Page Editor Use the class .lw_editor_on to change the appearance while the page is being edited. Use the widget editor to add the class .empty when there’s no image. <arg id="no_results"> <div class="header-image empty"></div> </arg>
  • 45. Mastering the Page Editor Example: display a suggestion to include a header image on the page. .header-image.empty { display:none; } .lw_editor_on .header-image.empty { display: block; background-color: #ccc; } .lw_editor_on .header-image.empty:after { content: 'Tag an image "header image" to appear here.'; display: block; }
  • 46. Mastering the Page Editor www.ursinus.edu/uc-magazine/
  • 47. Mastering the Page Editor www.ursinus.edu/uc-magazine/
  • 48. Mastering the Page Editor Example: Insert images in the page editor and move them around after the page is saved. /* position title image left of article divider */ #title img { position: absolute; left: 0; top: 0; transform: translate(-90.5%, -7%); } /* this treatment allows images to be positioned correctly and stay visible */ .lw_editor_on #title img { position: relative; transform: translateX(0); }
  • 49. Mastering the Page Editor - Add buttons to the page editor toolbar. $_LW->CONFIG['TOOLBAR_ADD_BUTTONS']=array('blockquote’, ‘hr'); - Edit the Formats dropdown to provide more styling options. $_LW->REGISTERED_APPS['pages_editor']['custom']['style_formats']= array( array('title'=>'Text styles:','selector'=>'p,h2,h4'), array('title'=>'Small type','selector'=>'p,h2,h4','classes'=>'font-small'), array('title'=>'Link styles:','selector'=>'a'), array('title'=>'Button','selector'=>'a','classes'=>'button1'), ​);
  • 50. Mastering the Page Editor - Customize the default gallery type used when adding a slideshow in the page editor. $_LW->REGISTERED_MODULES['galleries']['custom']['default_type']='mini'; - Also customizes the gallery type for “Get Code” links in the gallery manager. - Custom galleries are kept in the theme under /my_theme/galleries/
  • 51. Mastering the Page Editor - Call a JavaScript function after the page is edited. $('body').bind('stopEdit.lw', function(){ // do this after LiveWhale page edit/save }); - Similarly for the calendar: $('body').bind('calLoad.lwcal', function() { ​ // do this each time the calendar view is refreshed });
  • 52. Owning Your Site - Create a style guide for editors. - Write informative widget descriptions. - Add twice as many comments to your code as you think you need. - Keep file paths predictable and file names understandable. - Document everything unique to your site for future developers, for us, for yourself. - Where’s the best place to keep all this documentation? GetHelp.livewhale.com
  • 55. Owning Your Site Add a navigation widget to the dashboard in livewhale/client/private.config.php: $_LW->CONFIG['DASHBOARD'] = array( 'left' => array( array( 'LiveWhale CMS Help', '<br/><widget id="127_help_navigation"></widget>' ), ), ); GetHelp.livewhale.com
  • 56. Example: Careers Microsite www.lakeforest.edu/careers/pathways - Use a new theme (CSS & JavaScript). - Add new default widget formats. - Create new templates. - New LiveWhale theme structure makes it easy to keep everything bundled together.
  • 57. Example: Careers Microsite www.lakeforest.edu/careers/pathways
  • 58. Example: Careers Microsite www.lakeforest.edu/careers/pathways
  • 59. Example: Digital Publishing www.ursinus.edu/uc-magazine/
  • 60. Example: Digital Publishing www.ursinus.edu/uc-magazine/
  • 61. Example: Digital Publishing www.ursinus.edu/uc-magazine/
  • 62. Example: Digital Publishing www.ursinus.edu/uc-magazine/
  • 63. THE END Bonus code snippets →
  • 64. <head> <title><xphp var="page_title"/> • <xphp var="group_title"/> • <xphp var="client_name"/></title> <meta name="description" content="" /> <meta name="keywords" content="" /> <widget type="file"><arg id="path">/templates/includes/head.html</arg></widget> </head> LiveWhale Template Head
  • 65. <xphp content="true"> <if var="x" value=""/> <content> <!-- Show this if x is empty --> </content> <else content="true"> <content> <!-- Show this if x is non-empty --> </content> </else> </xphp> LiveWhale Conditional Statements https://livewhale.desk.com/customer/en/portal/articles/2490653-xphp-if-then-else-statement
  • 66. <xphp content="true" ifmode="or"> <if var="profiles_22"/> <if var="profiles_23"/> <content> <!-- one of these variables is non empty --> </content> </xphp> LiveWhale Conditional Statements https://livewhale.desk.com/customer/en/portal/articles/1522002-xphp-and-or-statements
  • 67. <xphp content="true"> <if var="server_path" not_equals="{group_directory}index.php"/> <content> <!-- show this if it's not the group homepage --> </content> </xphp> LiveWhale Conditional Statements
  • 68. <xphp content="true"> <if var="has_tag_red"/> <content> <!-- Show this if tagged with "red" --> </content> </xphp> LiveWhale Conditional Statements https://livewhale.desk.com/customer/en/portal/articles/2488862-check-if-tag-exists-in-xphp
  • 69. Tells the functions inside to use LiveWhale’s jQuery and keeps variables locally scoped. http://adripofjavascript.com/blog/drips/an-introduction-to-iffes-immediately-invoked-function-express ions.html ;(function($) { // Assigns LiveWhale's jQuery to $ }(livewhale.jQuery)); LiveWhale jQuery IIFE (Immediately Invoked Function Expression)
  • 70. You can put the plugin JS in a custom theme OR call the plugin JavaScript on some pages only. $.ajax({ url: "/scripts/plugin.js", // Use an IIFE in plugin.js if the plugin requires jQuery dataType: "script", cache: false }).done(function() { // Do stuff here using the plugin }); Using Plugins in LiveWhale
  • 71. Keeping Performance in Mind function debounce(func, wait, immediate) { var timeout; return function() { var context = this, args = arguments; var later = function() { timeout = null; if (!immediate) func.apply(context, args); }; var callNow = immediate && !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); if (callNow) func.apply(context, args); }; }; Example: var myFunc = debounce( function() { // do something here }, 250, true); Reduces the number of timed a function is called when resizing the window, scrolling, etc. JavaScript debounce function from Underscore.js: https://davidwalsh.name/javascript-debounce-function
  • 72. Add this to you events detail file to display all events in the calendar instead of in their own details template: <?php if (!empty($_GET['id'])) { die('<html><head><meta http-equiv="refresh" content="0;URL=/calendar/#event_id/'.(int)$_GET['id'].'/view/event"> </head><body><script type="text/javascript">window.location.href="/calendar/#event_id/'.(int)$_GET['id'].'/view/event"; </script></body></html>'); }; require $_SERVER['DOCUMENT_ROOT'].'/livewhale/frontend.php'; ?> Displaying Events Only in the Calendar