Koha as a CMS

These are instructions for taking a default install of Koha 3.0 and allowing it to function as a little content management system. This will allow a library to publish an arbitrary number of pages based on a template. This example uses the template for the main opac page, but you could just as well use any template you wish with a bit more editing. This may be appropriate if you have a small library, want to allow librarians to easily add pages, and do not want to support a complete CMS.

  • Copy /usr/share/koha/opac/cgi-bin/opac/opac-main.pl to /usr/share/koha/opac/cgi-bin/opac/pages.pl (in the same directory)
  • Edit pages.pl in an editor
  • At approximately line 32 add
  my $cgi = new CGI;
  • At approximately line 36 change this code:
      template_name   => "opac-main.tmpl",

To this code:

       template_name   => "pages.tmpl",
  • At approximately line 54 change this code:
  $template->param(
      koha_news       => $all_koha_news,
      koha_news_count => $koha_news_count
  );
  

To this:

  
  my $page = "page_" . $cgi->param("p");
  $template->param(
      koha_news       => $all_koha_news,
      koha_news_count => $koha_news_count,
      local_page           => "" . C4::Context->preference($page)
  );
  
  • Copy /usr/share/koha/opac/htdocs/opac-tmpl/prog/en/modules/opac-main.tmpl to /usr/share/koha/opac/htdocs/opac-tmpl/prog/en/modules/pages.tmpl
  • At approximately line 38, change this:
  <!-- TMPL_IF NAME="OpacMainUserBlock" --><div id="opacmainuserblock" class="container"><!-- TMPL_VAR NAME="OpacMainUserBlock" --></div><!-- /TMPL_IF -->

To this code:

 
  <!-- TMPL_IF NAME="local_page" --><div id="opacmainuserblock" class="container"><!-- TMPL_VAR NAME="local_page" --></div><!-- /TMPL_IF -->
  • In system preferences in the intranet, click the button for “New Preference”
  • Fill it out as so
    • Explanation: test page for pages tiny cms
    • Variable: page_test
    • value: Lorem ipsum
    • click the TextArea link (or enter “TextArea” into the input field below it)
    • variable options (last field): 80|50
  • In a browser go to http://youraddress/cgi-bin/koha/pages.pl?p=test The page should come up with the words “Lorem ipsum” in the main content area of the page. (replace “youraddress” with localhost, 127.0.0.1, or your domain name depending on how you have Apache set up.)
  • To add more pages simply create a system preference where the title begins with “page_” followed by any arbitrary letters. You can add any markup you want as the value of the field. Reference the new page by changing the value of the “p” parameter in the URL.

Troubleshooting

If you have problems check file permissions on pages.pl and pages.tmpl. They should have the same user and group as other Koha files like opac-main.pl.

Bonus Points

Instead of using the address http://youraddress/cgi-bin/koha/pages.pl?p=test you can shorten it to http://youraddress/pages.pl?p=test Just open up /etc/koha/koha-httpd.conf and add the follow at about line 13:

     
     ScriptAlias /pages.pl "/usr/share/koha/opac/cgi-bin/opac/pages.pl"
     

Then restart Apache.

 
en/documentation/tutorials/kohaascms.txt · Last modified: 2009/10/12 11:16 by nengard
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki