About Features Downloads Getting Started Documentation Events Support GitHub

Love VuFind®? Consider becoming a financial supporter. Your support helps build a better VuFind®!

Site Tools


Warning: This page has not been updated in over over a year and may be outdated or deprecated.
videos:managing_static_content

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
videos:managing_static_content [2021/11/10 15:34] – [Transcript] demiankatzvideos:managing_static_content [2023/03/28 16:02] (current) crhallberg
Line 14: Line 14:
 // This is a machine-generated transcript and will be corrected as time permits. // // This is a machine-generated transcript and will be corrected as time permits. //
  
- hello and welcome to this month's +Hello, and welcome to this month'VuFind tutorial videowhich is about managing static content. 
-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 VuFind instanceor to embed that type of information within some of VuFind's existing displays. VuFind isof coursenot meant to be a content management systemand so certainly wouldn't recommend using it to build your entire web presencebut sometimes it's useful to be able to place a page of custom content into the context of VuFind, and so we provide some tools to enable you to do thisand to also take advantage of VuFind's internationalization support along the way. 
-when i say static content i'm just + 
-referring to the ability to create +When you get VuFind out of the boxit ships with a couple of examples of static contentwhich are really just meant to be overwritten as you customize the system. These include the Ask 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. It's just a matter of putting templates in a particular directory within your themeand then VuFind does the rest. 
-custom html pages to present information + 
-within your viewfind instance +Let me quickly show you where this lives in the default themeand then we'll move forward to creating some content of our own. So if go into VuFind'themes directory and look under bootstrap3 in the templates/contentdirectoryyou'll see that we have an FAQ.phtml and ask library.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, if you find we'll display that template to youproviding a really easy way to render custom content. VuFind also supports Markdown, so if you want to create your content using the Markdown language instead of PHP HTML templatesthat's available as wellwhich may be more convenient if you're working with the content development team that's less comfortable with coding because the Markdown standard is widely used. 
-or to embed that type of information + 
-within some of viewfind's existing +So with that background out of the waylet me do some quick demosand I'll start by showing you how to create a Markdown-based content page in your VuFind instance. Right now we're looking at VuFind's core bootprint3 themeso let's switch to our custom tutorial templateso we're in a better position to customize some things. I'm just going to switch to my local config viewfind config.ini fileand I'm going to comment out the bootprint3 setting to activate my tutorial setting. Now if go back to my browser and refreshwe get to see the custom tutorial theme that we've been using in some of these videos. 
-displays + 
-viewfinder is of course not meant to be +Now that we're on our custom themecreating a new content page is as simple as going into our theme folderso under themes/tutorial/templates/, we need to create a new folder called contentsince this is the first content page we're creatingand in this content folderwe can just create a new file. So as said earlierthe file name will correspond with the URL where the content will be displayedso I'm going to call this Markdown-demobut the extension of the file will tell if you find how to render the content. So if were to end this in .php, it would render as a standard PHP templatebut of course want to demonstrate Markdown, so I'm going to name the file .md instead. So now have an empty fileand I'm going to put some Markdown in it. I'm not going to go into any depth on the Markdown standard during this videobecause there are lots of tutorials and sheet sheets out therebut it's widely usedyou've probably run across it somewhereand even if you haven'tit's pretty easy to learn. In any case, I'm going to start with "# 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 "\*Markdown demo\*", to show some formattingand I'm going to say here is a \[link\](), and I'm going to link this to the VuFind home page just for funand that's it. 
-a content management system and so + 
-certainly wouldn't recommend using it to +So I'm saving this file of Markdown. Now if return to my browserand go to /content/Markdown-demoas part of my VuFind URL, there is my Markdown, rendered in VuFind. 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 were to click this linkit would take me to the VuFind home page. So it's that simple. You can create Markdown to your heart's contentand serve it up through VuFind, so you can create institution specific pagescustom help screenswhatever you like
-build your entire web presence but + 
-sometimes it's useful to be able to +also mentioned earlier that the content display system supports internationalization. So if you're if you find instance supports multiple languagesyou can create multiple versions of your static contentand VuFind will display the appropriate one based on the language that's currently active. The way you do this is simply 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_en.phtml. So this is going to create a content page called i18nthe common abbreviation for internationalization. And this is going to be the English language version of thatand I'm indicating that with the \_en at the end of the file name. 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 can say in here, "this is in English". And since this wouldn't be a very exciting demoif didn't have another language as well, I'm going to create another file called i18n_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. 
-place a page of custom content into the + 
-context of viewfind and so we provide +So nowif go back to my browser, I need to go to the right browser. If I go back to my browserand edit my URL so that it is /content/i18n after the page VuFind URL, I see mythis is an English messagethen if switch my language to French: "This is not in French, but we can pretend". It's that simple. 
-some tools to enable you to do this and + 
-to also take advantage of ufind's +should also make a quick note on how the default behavior works for these templates. If you have a number of languagesbut you don't have templates for all of them. So for exampleif switch this to German, it actually says this is in English. The reason for that is that in config.iniyou're able to set a default language for your site. And if you find is unable to find a template for the requested languageit 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 if you find decides to display the English template. If there were no English templateit would next look to see if there were simply an i18n.phtml template with no language code at all. It would use that next. And only if all of those options failedwould it give up and throw an error about content being unavailable. 
-internationalization support along the + 
-way +In any casethat shows you all the capabilities for creating static pages in Markdown or PHP and with or without internationalization support. One thing that you might want to do though is give one of your content pages a custom URL. As you noticeby defaultall of the content pages have URLs with slash content slash something in them. But through the magic of the Laminas router systemit's not very difficult at all to give these any URL you like. So I'll show you that really quickly. 
-uh when you get viewfind out of the box + 
-it ships with a couple of examples of +First of alllet's go into the core VuFind module. So I'm going to my VuFind home module VuFind and I'm looking at the configuration here. So in my VuFind 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 definitionswhich we've talked about in the past. But one of these routes is called content page. And it is this routewhich does all the magic 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 patternit 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 few finds code map that to an appropriate template to display. But if you want to give a different URL to a content pageyou can simply copy this route into your local module and make a few small changes and get the effect you want. So I'm going to do exactly that
-static content which are really just + 
-meant to be overridden +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 herewe 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. And the formatting is a little ugly herebut I'm not going to worry about that right nowjust bear with me. So first of allwe 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 didn't change thisthis content page route would override the core version. So instead, I'm just going to call this content demo. And then I'm going to go to my options and I'm going to replace this content slash page thing with the URL that 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 because there's no page placeholder anymore. I can remove that constraint. And instead, I can go into the defaults and can just hardcode 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 demowhich is exactly the same as using the other route to go to slash content slash Markdown demo. 
-as you customize the system uh these + 
-include the ask librarian and faqs +So let me show you. If I now go here and just put Markdown demo on the end of my VuFind URL, I get to see my Markdown page. So in this wayyou can seamlessly incorporate static content into your URL structureas long as you're careful not to collide with existing URLs or route needs. So that covers all of the standalone page content
-pages + 
-which show in the footer and just +But what about incorporating this type of content into an existing page? If you find has something called content blockswhich are currently used on the various search home pages to drop in interesting information. So for exampleif just go to my search home screen, on I'm going to set this back to English for a momentyou will see that we have this facet information here. And this is actually being dropped in as a content block. 
-contain placeholder information + 
-if you click through to them +This is a configurable setting that you can find in searches.iniand all of you find search back ends have a content block configuration so that you can put different content on each of their home pages. Let me show you in practice here. So if go to you find main config, you find directory. And I look at the searches.ini filewhich 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 defaulttwo content blocks are set up. One is called ILS status monitor. This normally does not display anythingbut it will check to see if your ILS is offline. And if it isit will display a warning message that some functionality may be unavailable. If you're not using an ILS, or you don't want this featureyou might consider commenting this out. Following thatthere's a facet list content blockwhich is what creates that facet list was showing you. And againif you don't like thatyou 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 hereor you can build your own. But for todaywhat want to show you is a content block called template basedwhich 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 just showed you. 
-so + 
-creating these static content pages is +So I am going to demonstrate that for you right now. So first of allbecause this demo instance doesn't have a custom searches.ini yet, I am going to copy the core searches.ini file into my local settings directory. So I have a place to do some custom configuration. So I'm copying from if you find home config, if you find searches.ini into local config, you find searches.ini. And then I'm going to scroll down here so can customize my content. So to turn this on, I simply need to add another content block setting. 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 can say equals template basedwhich 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 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 and a capital B. And under that, the folder called template base. So I can now just take my to i18n templatescopy thempaste them into here. And make sure that 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 pass it list and below any ILS related messages. But I could move this line around if wish to do things differently. And now 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 change my language to French, it says "This is not in French, but we can pretend". 
-pretty easy uh it's just a matter of + 
-putting templates in a particular +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. And as of the recording of this videowe haven't actually implemented such a thingbut it would be pretty straightforward to do so. So if anyone has a need for thisby all means feel free to open a Jira ticket and we can get that feature incorporated into a future release. 
-directory within your theme + 
-and then vufine does the rest +In any casethanks for your time and for listening to this. I hope this makes it easier for you to share information through your VuFind instance and we'll have more for you next month.
-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 +
-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 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 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 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 were to end this in dot p html it +
-would render as a standard php template +
-but of course want to demonstrate +
-markdown +
-so i'm going to +
-name the file dot md instead +
-so now 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 return to my browser +
-and 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 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 +
-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 +
-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 could just as +
-easily use markdown here it makes no +
-difference +
-i'm just showing both versions for +
-demo purposes +
-so then can say in here this is in +
-english +
-and since this wouldn't be a very +
-exciting demo if 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 +
-will save that +
-so now if go back to my browser +
-need to go to the right browser +
-uh if i go back to my browser +
-and 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 switch my language to french +
-this is not in french but we can pretend +
-it's that simple +
-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 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 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 want to use so let's +
-say we want to show that markdown demo +
-at a url +
-called +
-markdown demo +
-can just put that in +
-uh +
-because there's no page placeholder +
-anymore can remove that constraint +
-and instead can go into the defaults +
-and 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 +
-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 just put mark down demo on +
-the end of my viewfinder url +
-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 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 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 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 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 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 +
-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 can +
-customize my content +
-so to turn this on 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 created for the earlier full page +
-example +
-the only difference is what directory +
-the files go in within my theme +
-so for +
-page content use the content directory +
-for content block content +
-just need to create a different +
-directory to put my files into +
-and that directory is +
-content block with a capital and a +
-capital +
-and under that +
-folder called +
-template based +
-so i can now just take my two +
-i18n +
-templates +
-copy them +
-paste them into here +
-and make sure that 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 wish to +
-do things differently +
-and now +
-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 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 hope this makes it easier for +
-you to share information through your +
-viewfind instance +
-and we'll have more for you next month +
 ---- struct data ---- ---- struct data ----
 +properties.Page Owner : 
 ---- ----
  
videos/managing_static_content.1636558455.txt.gz · Last modified: 2021/11/10 15:34 by demiankatz