Video 15: Managing Static Content
The fifteenth VuFind® instructional video demonstrates how you can incorporate static content (informational screens and local messages) into your VuFind instance. This provides a simple way to customize your displays to meet the needs of your local audience, using only basic HTML or Markdown, and including support for internationalization.
This is a machine-generated transcript and will be corrected as time permits.
hello and welcome to this month's viewfind tutorial video which is about managing static content when i say static content i'm just referring to the ability to create custom html pages to present information within your viewfind instance or to embed that type of information within some of viewfind's existing displays viewfinder is of course not meant to be a content management system and so i certainly wouldn't recommend using it to build your entire web presence but sometimes it's useful to be able to place a page of custom content into the context of viewfind and so we provide some tools to enable you to do this and to also take advantage of ufind's internationalization support along the way uh when you get viewfind out of the box it ships with a couple of examples of static content which are really just meant to be overridden as you customize the system uh these include the ask a librarian and faqs pages which show in the footer and just contain placeholder information if you click through to them so creating these static content pages is pretty easy uh it's just a matter of putting templates in a particular directory within your theme and then vufine does the rest let me quickly show you uh where this lives in the default theme and then we'll move forward to creating some content of our own so if i go into viewfinds themes directory and look under bootstrap 3 in the templates content directory you'll see that we have an faq.phtml an asklibrary.phtml and a couple of other utility templates that are actually used by the content display code but the important thing to take away here is that if you see a file that starts with faq and you go to your browser and add content slash faq after the base url uh viewfinder will display that template to you providing a really easy way to render custom content if you also supports markdown so if you want to create your content using uh the markdown language instead of php html templates uh that's available as well which may be more convenient if you're working with a content development team that's less comfortable with coding because the markdown standard is widely used so with that background out of the way let me do some quick demos and i'll start by showing you how to create a markdown based content page in your viewfind instance right now we're looking at viewfind's core boot print three theme so let's switch to our custom tutorial template so we're in a better position to customize some things i'm just going to switch to my local config viewfind config.ini file and i'm going to comment out the bootprint 3 setting to activate my tutorial setting now if i go back to my browser and refresh we get to see the custom tutorial theme that we've been using in some of these videos now that we're on our custom theme creating a new uh content page is as simple as going into our theme folder so under themes tutorial templates uh we need to create a new folder called content since this is the first content page we're creating uh and in this content folder uh we can just create a new file so as i said earlier the file name will correspond with the url where the content will be displayed so i'm going to call this markdown demo but the extension of the file will tell if you find how to render the content so if i were to end this in dot p html it would render as a standard php template but of course i want to demonstrate markdown so i'm going to name the file dot md instead so now i have an empty file and i'm going to put some markdown in it i'm not going to go into any depth on the markdown standard during this video because there are lots of tutorials and cheat sheets out there but it's widely used you probably run across it somewhere and even if you haven't it's pretty easy to learn uh in any case i'm going to start with pound my title because prefixing text with the pound is how you create a heading in markdown and then i'm just going to put a line of content i'm going to say this is the star markdown demo star to show some formatting and i'm going to say here is a bracket link parenthesis and i'm going to link this to the view find home page just for fun and that's it so i'm saving this file of markdown now if i return to my browser and i go to content markdown demo as part of my viewfinder url there is my markdown rendered in view viewfind also you might notice that the tab in my browser actually shows my title the markdown parser is smart enough to take top level headings and use those as the page title for you and if i were to click this link it would take me to the viewfind home page so it's that simple you can create mark down to your heart's content and serve it up through viewfind so you can create institution specific pages custom help screens whatever you like i also mentioned earlier that the content display system supports internationalization so if your viewfinder instance supports multiple languages you can create multiple versions of your static content and viewfind will display the appropriate one based on the language that's currently active uh the the way you do this is simply uh to put an underscore and a language code on the end of your file names so i'll do a quick demo of this as well i will create a new file called i18n underscore en.phtml so this is going to create a content page called i18n you know the common abbreviation for internationalization uh and this is going to be the english language version of that and i'm indicating that with the underscore en at the end of the file name uh and this demo i'm just going to do standard phtml templates i could just as easily use markdown here it makes no difference i'm just showing both versions for demo purposes so then i can say in here this is in english and since this wouldn't be a very exciting demo if i didn't have another language as well i'm going to create another file called i18n underscore fr.phtml for french and i'm going to write in here this is not in french but we can pretend i will save that so now if i go back to my browser i need to go to the right browser uh if i go back to my browser and i edit my url so that it is content slash i18n after the base viewfind url i see my this is an english message then if i switch my language to french this is not in french but we can pretend it's that simple i should also uh make a quick note on how the default behavior works for these templates uh if you have a number of languages but you don't have templates for all of them so for example if i switch this to german it actually says this is in english the reason for that is that in config.ini you're able to set a default language for your site and if viewfind is unable to find a template for the requested language it will next search for a template in the default language as a fallback so in this example german is not available english is the default language configured in config.ini so viewfinder decides to display the english template if there were no english template it would next look to see if there were simply an i18n.php template with no language code at all it would use that next and only if all of those options failed would it give up and throw an error about content being unavailable in any case that shows you all the capabilities for creating static pages in markdown or php and with or without internationalization support one thing that uh you might want to do though is give one of your content pages a custom url uh as you notice by default all of the content pages have urls with slash content slash something in them but through the magic of the laminas router system it's not very difficult at all to give these any url you like so i'll show you that really quickly first of all let's go into the core viewfinder module so i'm going to my view find home module viewfinder and i'm looking at the configuration here so in my viewfind module i'm going to the configuration directory and opening module.config.php and at the top of this file are all of the route definitions which we've talked about in the past but one of these routes is called content page and it is this route which does all the magic of resolving content for you so it's a segment based route and it looks for slash content slash something when it encounters a match for that pattern it calls the content action of the content controller and passes through part of the url as a parameter called page so this is how you're able to type in a content url and have viewfinds code map that to an appropriate template to display but if you want to give a different url to a content page you can simply copy this route into your local module make a few small changes and get the effect you want so i'm going to do exactly that i'm going to copy this whole route and then i'm going to go into my local tutorial module and into the configuration and the module config so in here we have a custom route that we set up in a past video and i'm just going to paste in that content route right above it uh and the formatting is a little ugly here but i'm not going to worry about that right now just bear with me so first of all we want to give every route a unique name because we don't want to override the existing content page route we want all of our content to keep working and if i didn't change this this content page route would override the core version so instead i'm just going to call this content demo uh and then i'm going to go to my options and i'm going to replace this content page thing with the url that i want to use so let's say we want to show that markdown demo at a url called markdown demo i can just put that in uh because there's no page placeholder anymore i can remove that constraint and instead i can go into the defaults and i can just hard code a page value here and this is going to be markdown demo it's that simple i've created a route named content demo it's going to look for a url that just says markdown demo and when it encounters that url it's going to call the content action of the content controller and it's going to pass it a page parameter of markdown demo which is exactly the same as using the other route to go to slash content slash markdown demo so let me show you if i now go here and i just put mark down demo on the end of my viewfinder url i get to see my markdown page so in this way you can seamlessly incorporate static content into your url structure as long as you're careful not to collide with existing urls or route names so uh that covers all of the standalone page content but what about incorporating this type of content into an existing page viewfinder has something called content blocks which are currently used on the various search home pages to drop in interesting information so for example if i just go to my search home screen and i'm going to set this back to english for a moment uh you will see that we have this facet information here and this is actually being dropped in as a content block this is a configurable setting that you can find in searches.ini and all of you finds search backends have a content block configuration so that you can put different content on each of their home pages let me show you uh in practice here so if i go to view finds main config viewfind directory and i look at the searches.ini file which controls the behavior of the main default solar-based search near the bottom of this file there's a setting called content and this is where we configure the content blocks for the home page by default two content blocks are set up one is called ils status monitor this normally does not display anything but it will check to see if your ils is offline and if it is it will display a warning message that some functionality may be unavailable if you're not using an ils or you don't want this feature you might consider commenting this out following that there's a facet list content block which is what creates that facet list i was showing you and again if you don't like that you can simply turn off this setting to get rid of it and you can also choose from some of the other content blocks that are listed in the comments up here or you can build your own but for today what i want to show you is a content block called template based which allows you to drop static content onto your home page in much the same way as you are able to create the static content pages i just showed you so i am going to demonstrate that for you right now so first of all because this demo instance doesn't have a custom searches.ini yet i am going to copy the coresearches.ini file into my local settings directory so i have a place to do some custom configuration so i'm copying from viewfind home config viewfind searches.ini into local config viewfind searches.ini and then i'm going to scroll down here so i can customize my content so to turn this on i simply need to add another content block settings so i can say content bracket bracket and the brackets are important because this is a repeating setting and we want to be sure that we don't override the setting rather than adding to it and i could say equals template based which is the name of the content block colon i18n we just need to give a template base name for the content block to use in this case i'm choosing i18n because that allows me to be really lazy and simply copy and paste the templates that i created for the earlier full page example the only difference is what directory the files go in within my theme so for page content i use the content directory for content block content i just need to create a different directory to put my files into and that directory is content block with a capital c and a capital b and under that a folder called template based so i can now just take my two i18n templates copy them paste them into here and make sure that i saved my configuration properly it's also worth noting that the order of the content settings affects the order of the display so i've set this up so that the template will appear above the facet list and below any ils related messages but i could move this line around if i wish to do things differently and now i come back here and refresh the page the message this is in english has appeared above my list of facets so it is working and if i change my language to french it says this is not in french but we can pretend so the template-based content block follows all of the same rules and conventions as the full page templates so you can use the language suffixes on the file names or not as you prefer you can use php templates or markdown as you prefer it's just a nice way to be able to quickly and easily embed messages wherever you need them the next step that might be useful would be to have similar functionality in a recommendation module so that we could put messages into search results uh and as of the recording of this video uh we haven't actually implemented such a thing but it would be pretty straightforward to do so so if anyone has a need for this by all means feel free to open a jira ticket and we can get that feature incorporated into a future release in any case thanks for your time and for listening to this i hope this makes it easier for you to share information through your viewfind instance and we'll have more for you next month