2 Template Site Template With Dynamic Global Header
2 -Template Site Template With Dynamic, Global Header and Footer Mark Nokes, University of Central Oklahoma
Musician to Web-nician
University of Central Oklahoma More than 16, 000 students More than 450 full-time and 500 adjunct faculty 117 undergraduate and 74 graduate majors ~400 web content management system users
UCO’s Challenge 1. 2. Websites must contain dynamic, global elements, including headers, footers, sidebars The elements must be: Independently Dynamically Have publishable included in all pages that use the same site template, and a preview inside Cascade
UCO’s Solution
Header/Footer As Independent Elements Header and footer use their own data definition that allows users to choose links, images, buttons, etc. Every page will use the header and footer automatically. Updates to the header and footer will be reflected in all pages using theme.
How’d He Do It?
Common Site Contains • subfolder for each theme Common files, includes, base assets, formats, and templates for one theme. Include directory contains global elements that are included server-side, as well as within Cascade CMS. The template directory contains two templates. One for pages, and one for plain text.
Constants Contains theme variables that remain constant regardless of the site. $inc. Path -side. is used for included files within Cascade and server
“Include file” Architecture
UCO Page Template All pages use one template! The page template contains only 5 regions
Template-level Region Format An “include” macro is called with one or more arguments • Argument one is the file name (without the extension) • Argument two is the path to an optional format to import.
“Include” Macro Logic External view is a PHP include Internal view contains a small piece of logic • If the $import variable is set, do an import, otherwise, use the locator tool to get the include file, and display the text value.
Global Element Region Format The include file itself needs a format to present a view inside Cascade CMS. Markup is shared by the page region and the default region of the include file.
Shared Markup Logic The global element will need CSS and Javascript for an internal view
Page Default Region
The Resulting Server-side Code
Sidebars Automatically included into pages that require sidebars regardless of folder structure. They will be included based upon the following hierarchy: Current page parent folder • Current page ancestor folder, recursively • Ability to choose a custom sidebar if default sidebar is not desired
Sidebars: Internal Preview
Sidebars: The Asset Format
Sidebars: In-page Macro
Sidebars: Server-side Code
Bonus: Macro Type Macro In The Wild Alphabet “chunk” design requires many iterations Velocity is too slow Must do processing serverside, but include in page inside Cascade A-Z Site Index
Macro Section Type – Page Default Region As long as there’s a format in the macro folder that contains a macro of the same name used here, it will be evaluated and formatted in the page.
Results 1. UCO’s University Communications department can manage global site elements without publishing user’s content. 2. User’s can edit/publish sidebars without the need to publish pages. 3. The addition of new site elements in the default region does not require additional templates, configurations, or content types!
Questions…. Find me on Github: https: //github. com/marknokes Email me: mnokes@uco. edu Call me: On second thought, don’t.
- Slides: 29