60
Stupid Index Block Tricks... they’re not just for navigation Dave Shaykewich University of Victoria

Stupid Index Block Tricks

Embed Size (px)

DESCRIPTION

This session will consider: - what data is available from index blocks - Cascade's object and data types and their implications on indexes - organizing transformation 'formats' for multi-/re-use Example widgets include: - Handy reports for project managers and site administrators - News aggregation and syndication blocks - Dynamic decision tree web widgets - XPath-based search and browse web widgets Bring your inspired indexing ideas and innovations for sharing.

Citation preview

Page 1: Stupid Index Block Tricks

Stupid Index Block Tricks...they’re not just for navigation

Dave ShaykewichUniversity of Victoria

Page 2: Stupid Index Block Tricks

Agenda

• UVic Cascade environment• Index block basics• Tricks• Navigation• Reporting• Content aggregation• Decision tree wizard• Content searching

• Is there something you’d like to share with the class?

Page 3: Stupid Index Block Tricks

The University of Victoria

• The University of Victoria is on an island on the west coast of Canada (~70 miles from Seattle)

• ~18,000 FTEs, 11 Faculties, ~70 Departments

Page 4: Stupid Index Block Tricks

UVic Cascade Environment

• Cascade WCMS is offered as a service to all faculties, departments/units, and research projects on campus (not to individuals)

• Currently ~190 sites, 850 users in Cascade

• Started with Cascade 6.x, now on 7.07

Page 5: Stupid Index Block Tricks

UVic Cascade Environment

• One template for all ‘UVic’ sites

• One config set/site (referencing central template, formats)• Many site-specific blocks/formats

• XSLT shop (history with Banner’s “Luminis” tools)

Page 6: Stupid Index Block Tricks

Index blocks

• Getting started with index blocks & formats• “An index block is a special type of block asset that

returns a listing of assets from the CMS directory structure in the form of XML data.”

• A format is a “transformation asset that can be applied at the region-level” … “the same way that a stylesheet can be applied.”

Page 7: Stupid Index Block Tricks

Index blocks

• XML representation of folders, pages, blocks, files, and external links• Folder, page and block attributes• modified date, by• published date, by• metadata (including custom metadata)

• Page (and block) content (HTML/XML)• “Default” region content on pages, and• Data definition structure and content

Page 8: Stupid Index Block Tricks

Index block tricks

• Index blocks know a whole lot about your site...

Let’s have a look at some tricks we can use to use them to our advantage.

Page 9: Stupid Index Block Tricks

Index blocks

• Rethinking index blocks• They’re more than just navigation generators...

• Index blocks are self-updating, query-able databases of site content (and all of its attributes)

• Formats are the means to query index blocks and output structured HTML markup • and/or CSS• and/or JavaScript • and/or server-side code (e.g., PHP)

Page 10: Stupid Index Block Tricks

Trick 1: Navigation

• Purpose: • Have Cascade generate navigation that maintains

context • i.e., highlights current page’s ancestors’ navigation

Page 11: Stupid Index Block Tricks

Trick 1: Navigation

• Sample: http://www.uvic.ca/future-students/undergraduate/programs/distance/index.php

Page 12: Stupid Index Block Tricks

Trick 1: Navigation

• Recipe: • Build out site structure in Cascade

• Folder hierarchy to correspond to navigational elements• Create index block of site folders and pages • Transform index block into navigation HTML

• Recursively step through folders to create a nested unordered list

• Add class of ‘selected’ to each with an descendant that’s “current”

• Add class of ‘expandable’ to each list item that contains child folders

Page 13: Stupid Index Block Tricks

Trick 1: Navigation

Page 14: Stupid Index Block Tricks

Trick 1: Navigation

• The good: • Navigation is automatically constructed as the site is constructed • Context is maintained (so users know where they are in a site)• Format code is relatively simple• Write format once, use it on all your sites, maintain consistency• Example scripts delivered with Cascade (example.com site)

• The bad:

• The ugly• When folders are added/removed, pages need to be re-published • Before index block caching, big sites were very slow to load

Page 15: Stupid Index Block Tricks

Trick 2: Content reporting

• Purpose:• Provide project managers, content contributors with on-

demand reports about the content in their site• Particularly useful during site development• Search within code/tags

• Answer questions like:• Are there any links to an old site in the content?• Are there any pages ready for me to work on?• Which pages are required for prototype usability testing?• Are there any unpublished pages?

Page 17: Stupid Index Block Tricks

Trick 2: Content reporting

• Recipe:• If applicable, create custom metadata for site for attributes you

want to search • Our default metadata set includes the development lifecycle

metadata• Create an index block of all site content (this may require changing

max index block size)• With your format, query index block• Display results

• Create links within Cascade to ‘View’, ‘Edit’, ‘Publish’ page/block (index block has “id” of assets)

Page 18: Stupid Index Block Tricks

`

Trick 2: Content reporting

Who?When?‘Bad’ links?

View |Edit |Publish

Page 19: Stupid Index Block Tricks

Trick 2: Getting started

• Reports:• Identify questions you have (or are continually asked) about a

site’s content• When was it last updated?• Who last published it?• Are there any ‘bad’ links to an old site/URL?

• Configure index block• Write format to query index block to answer the question• Make the output actionable with direct links to page options

(e.g., Edit, Publish, View)

Page 20: Stupid Index Block Tricks

Trick 2: Content reporting

• The good:• On-demand answers to common questions• Very fast to re-purpose and tweak • Example scripts delivered with Cascade (check the _common

site) • The bad:• The ugly:

• Writing the XPath queries can be challenging (especially when getting started)• using XML dev tools like oXygen can really help

Page 21: Stupid Index Block Tricks

Aside: Blocks in Default Region

• Our previous CMS supported ‘block’ equivalents in content areas

• We had to emulate this in Cascade• Created data definition for our standard page

• Content Group (repeatable)• WYSIWYG (for typed-in content)• Block chooser (render-content-depth="unlimited“)

• (we haven’t explored ‘bricks’ yet...)

Page 22: Stupid Index Block Tricks

Aside to the Aside: Structuring XSLT formats for your site

• We wanted the blocks in Default to be data definition blocks (not just straight XTHML/text)

• Therefore, the format for the Default region needed to be able to transform many different types of data definitions

Page 23: Stupid Index Block Tricks

Aside to the Aside: Structuring XSLT formats for your site

• XSLT formats in Cascade can ‘include’ others

<xsl:include href="site://UVicCa/_internal/formats/…"/>

• This can be really helpful• widget formats can be included into the standard page format (i.e., the format for the

Default region)• widget blocks can be added to pages Default regions via Data Definitions choosers

• then, if the Default region format <xsl:apply-templates> • > and the widget block has a unique namespace• > and there’s a <xsl:template > that matches that namespace

• > the widget XML will be transformed into the widget’s markup

Page 24: Stupid Index Block Tricks

Aside to the Aside: Structuring XSLT formats for your site

1. Create structured page data-definitions

Page 25: Stupid Index Block Tricks

Aside to the Aside: Structuring XSLT formats for your site

1. Create structured page data-definitions

2. Create format for the default region that includes widgetry formats

Page 26: Stupid Index Block Tricks

Aside to the Aside: Structuring XSLT formats for your site

1. Create structured page data-definitions

2. Create format for the default region that includes widgetry formats

3. In format for default region, capture your page content’s DD regions and xsl:apply-templates

Page 27: Stupid Index Block Tricks

Aside to the Aside: Structuring XSLT formats for your site

1. Create structured page data-definitions

2. Create format for the default region that includes widgetry formats

3. In format for default region, capture your page content’s DD regions and xsl:apply-templates

4. Create widget data-definitions with a ‘group’ container with unique id (e.g., contacts-by-hr-dept)

Page 28: Stupid Index Block Tricks

Aside to the Aside: Structuring XSLT formats for your site

1. Create structured page data-definitions

2. Create format for the default region that includes widgetry formats

3. In format for default region, capture your page content’s DD regions and xsl:apply-templates

4. Create widget data-definitions with a ‘group’ container with unique id (e.g., contacts-by-hr-dept)

5. In widget’s XSLT format, capture widget’s matching template• <xsl:template match=“contacts-by-hr-dept”>

Page 29: Stupid Index Block Tricks

Aside to the Aside: Structuring XSLT formats for your site

• So? Isn’t this supposed about index block tricks?

• Many of the following index block-driven widgets rely this structure:• widgetry formats are called/applied by the ‘Default’

region’s format• and the blocks are automatically transformed properly

Page 30: Stupid Index Block Tricks

Trick 3: Content aggregation – Staff profiles

• Purpose: • Display staff profiles in a consistent, structured way• Have Cascade automatically aggregate and sort staff

profiles• Give non-technical content contributors ability to CrUD

staff profiles easily

Page 31: Stupid Index Block Tricks

Trick 3: Content aggregation

• Sample:http://www.uvic.ca:8080/hr/contact/home/organization/index.php

Page 32: Stupid Index Block Tricks

Trick 3: Content aggregation

• The recipe:• Develop a data definition to capture and organize profile

data (e.g., name, dept, responsibilities, etc)• Build out Cascade folders to hold profiles• can be used as one way of sorting

• Populate data def profile blocks into folders

Page 33: Stupid Index Block Tricks

Trick 3: Content aggregation

• The recipe continued:• Create an index block to aggregate profile info

• This index block will be the data source for all three different pages

• Create a container data def block with a distinct id and block chooser (to refer back to index block)

• Depending sorting criteria, write formats to sort/organize profiles and output HTML• switch format based on namespace of container block

(<xsl:apply-templates >)

Page 34: Stupid Index Block Tricks

Trick 3: Content aggregation

By department

By service

By org

by-dept.php

by-service.php

by-org.php

Page 35: Stupid Index Block Tricks

Trick 3: Content aggregation

• The good: • One, structured source for profile data• Easy to maintain, automatically sorts• Contributors require very minimal tech skills• Models can be tweaked and re-purposed for any structured content• Some sample code delivered with Cascade (‘news’ in example.com)

• The bad:• Contributors need to be trained to update content somewhere other

than on the page where they see it• … then trained to publish pages they weren’t editing

Page 36: Stupid Index Block Tricks

Trick 3: Content aggregation

• The ugly• Managing the inclusion of formats and naming of format

files (vs. namespace of switcher blocks)• Can be very challenging to troubleshoot • “Which transformation, in which format file, from which

site, is being applied to this block?” (consider printing out comments in <xsl:template match=“…” >)

• Working within Cascade to develop your formats can be tedious and inefficient• Consider an XML tool like oXygen

Page 37: Stupid Index Block Tricks

Trick 3: Getting started

• Content aggregation:• Identify common content types that you’re ‘manually’ aggregating

• Granular content in data definitions is especially queryable (and generally easier for contributors to maintain)

• E.g., [re-]grouped lists of people, events, services, news• Develop static fully-functional model in HTML/Javascript (so you

know what your format needs to output)• Configure index block

• “Folder” (or “Content type” for pages)• Write format to query for sorted/ordered assets and transform into

markup from model

Page 38: Stupid Index Block Tricks

Trick 4: Decision tree wizard

• The purpose • Give end-users a wizard tool to sort through a deep list

of resources (without linking around a site)• Have Cascade automatically aggregate content and build

wizard HTML and JS based on native Cascade structures• Give non-technical content contributors ability to CrUD

the wizard easily(ish)

Page 39: Stupid Index Block Tricks

Trick 4: Decision tree wizard

• Sample: • http://www.uvic.ca/coopandcareer/index-wizard.php

Page 40: Stupid Index Block Tricks

Trick 4: Decision tree wizard

• The recipe:• Build out Cascade folder structure to match the decision tree

• Each folder is a ‘question’• Each child folder is a ‘response’• … and so on

• Add custom meta data fields to capture each folder’s:• ‘response’ (to its parent folder’s question), and• ‘question’ (to its child folders)

• To each applicable ‘answer’ folder, add:• ‘External link’ objects for each resource• Images for icons

Page 41: Stupid Index Block Tricks

Trick 4: Decision tree wizard

• The recipe continued:• Create an index block to aggregate tree info• Create a container data def block with a distinct id and

block chooser (to refer back to index block)• Write format to:• Output HTML, CSS and JS to create wizard interaction

Page 42: Stupid Index Block Tricks

Trick 4: Decision tree wizard

Page 43: Stupid Index Block Tricks

Trick 4: Getting started

• Decision tree wizard:• Develop a model outside of Cascade

• Construct the decision tree on paper• HTML, CSS, JS

• Build out custom metadata for the folders• Translate decision tree into to folder hierarchy with metadata

• Create index block• Based on the model, write format to query for sorted/ordered assets and

transform into • HTML• CSS• JS

Page 44: Stupid Index Block Tricks

Trick 4: Decision tree wizard

• The good:• Ability for semi-technical users to produce a very technical widget• Logical & understandable structuring of decision tree concepts• Re-usable/re-purposable/copyable

• The bad:• Many moving parts• Difficult to troubleshoot once it’s in/published from Cascade• Contributors have to be able to translate decision tree in their heads into Cascade

structures

• The Ugly• Did I mention… many moving parts

• Write XSL to write HTML, CSS & JavaScript

Page 45: Stupid Index Block Tricks

Trick 5: PHP Search & Browse

• The purpose • Allow end-users to search structured information in

your Cascade site (e.g., keyword search for academic programs)

• Have Cascade automatically aggregate and make content ‘findable’

• Give non-technical content contributors ability to CrUD content easily

Page 46: Stupid Index Block Tricks

Trick 5: PHP Search & Browse

• Sample: • http://www.uvic.ca/future-students/undergraduate/pro

grams/index.php

Page 47: Stupid Index Block Tricks

Trick 5: PHP Search & Browse

• The recipe:• Develop a data definition to capture and organize

program data (e.g., name, dept, URL, etc)• Populate data def program blocks into folders• Create an index block to aggregate program info• This index block will be the data source for all three

different pages

Page 48: Stupid Index Block Tricks

Trick 5: PHP Search & Browse

• The recipe continued:• Create a container data def block with a distinct id and block

chooser (to refer back to index block)• For this DD block, write format to:

• Output PHP code that will search index block XML• Add HTML search form to page• Call search function on server, passing index block XML as

parameter • Output HTML results from PHP function

• Add DD block to Cascade page• Publish to PHP web server for endusers

Page 49: Stupid Index Block Tricks

Trick 5: PHP Search & Browse

Page 50: Stupid Index Block Tricks

Trick 5: PHP Search & Browse

• The good:• A framework for searching organized content from Cascade • Customized search & display

• The bad:• Many moving parts• Difficult to troubleshoot once it’s in/published from Cascade

• The Ugly• Did I mention… many moving parts

• Write XSL to write PHP to write HTML, CSS & JavaScript

Page 51: Stupid Index Block Tricks

Trick 5: PHP Search & Browse

• U-G-L-Y• XSLT required to publish a PHP ‘open’ tag:

[system-view:external] <xsl:comment>#START-CODE<![CDATA[ <?php ]]>

Page 52: Stupid Index Block Tricks

Trick 5: Getting started

• Search and browse:• Cascade• Identify content type and attributes for searching• Content in data definitions is especially parse-able

(and generally easier for contributors to manage)• Configure index block• Collect the XML of the index block

Page 53: Stupid Index Block Tricks

Trick 5: Getting started

• Search and browse:• Front-end• Develop static model of tool in HTML/Javascript (so

you know what your format needs to output)

Page 54: Stupid Index Block Tricks

Trick 5: Getting started

• Search and browse:• Server-side processing• Develop framework for searching XML (regardless of

whether it is called by Cascade page or not)• Using the sample index block as your datasource,

write code to search the XML• Output markup of results• Use HTML model to test ‘manually’

Page 55: Stupid Index Block Tricks

Trick 5: Getting started

• Search and browse:• Back to Cascade• Write format to output• Client-side markup for form, results display• Server-side code to call functions to perform

search passing as a parameter, the XML from the index block• Nail down how to escape code in your XSLT

Page 56: Stupid Index Block Tricks

Conclusions

• Start to think of Cascade as a database of content• mildly relational: blocks/pages can relate to other

blocks/pages with (repeatable) data definition block/page choosers

• Index blocks are like ‘views’ on the content database• Formats can • ‘query’ index blocks • transform the results into HTML, JavaScript, server-side

code

Page 57: Stupid Index Block Tricks

Conclusions

• Getting started with index block tricks• Beg, borrow and steal:• The most difficult widget you write will be your first• Reuse and repurpose code to kick start future

widgets

Page 58: Stupid Index Block Tricks

Conclusions

• Getting started with index block tricks• Get organized

• Consider where you want to be able to insert your widgets (i.e., template regions)• How will you apply your widgetry formats to those regions?

• Consider your Data Definitions’ and Formats’ structure and names ahead of time• structure (i.e., name) your DDs uniquely – use ‘groups’ as

well-named containers that can be uniquely XPath queried• name your format files to match• in your ‘default’ format, include widget formats

Page 59: Stupid Index Block Tricks

Questions? Comments? Ideas?

Page 60: Stupid Index Block Tricks

Contact info

• Dave Shaykewich Client Account Manager, UVic Online University of Victoria

[email protected] 250-853-3233