Saturday, September 7, 2013

Add an internal page to Koha

Koha is one of the most commonly used open source fully automated library management system used by libraries today. Even though koha an opac interface, many librarians and user espicially would like to have a portal where all library resources and information can easily be accessed. In an attempt to offer this feature to the koha's opac many opt for attaching external link sometime referring to the library website or a standalone web page.  Leaving koha to another different page or website is odd and not effective, as it really disturbs a smooth user navigation.
   Many librarians or IT professional setting up koha find it difficult  or have either forgotten that koha offer indeed an option create internal page. With a good skills of css and html only, the OPAC can easily be converted to a web portal. Through out this post and other that will follow, I will try to share the little I know on this issue.

 1- login as the root user:
  --$ su
  Password:
 2- create the first page to be served as templates called page.pl:
  --# cp  /usr/share/koha/opac/cgi-bin/opac/opac-main.pl  /usr/share/koha/opac/cgi-bin/opac/pages.pl

 3-  Edit the newly created page.pl from your preferred text editor like gedit (debian) or leafpad (ubuntu)
  --# gedit /usr/share/koha/opac/cgi-bin/opac/pages.pl

 4- At around line 30 just before my ( $template, $borrowernumber, $cookie ) = get_template_and_user( add the following statement:
  : my $cgi = new CGI;






 5- Make this change to the code at around line 33:

    template_name   => "opac-main.tt", change to  template_name   => "pages.tt",




 6- Approximately at 56 add this code:

 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)
          );



 7- Save page.pl and exit.

 8- Create a second page called page.tt
 --# cp /usr/share/koha/opac/htdocs/opac-tmpl/prog/en/modules/opac-main.tt  /usr/share/koha/opac/htdocs/opac-tmpl/prog/en/modules/pages.tt

 9- At approximately  line 40 make this change:
        
        Change
      [% IF ( OpacMainUserBlock ) %]<div id="opacmainuserblock" class="container">[% OpacMainUserBlock %]</div>[% END %]

       to

      [% IF ( local_page ) %]<div id="opacmainuserblock" class="container">[% local_page %]</div>[% END %]



   10- Save page.tt and exit.

   11- In system preferences in the staff client, click the button for "New Preference" under "Local Use"
  
   12-

  Fill it out as follow:

      Explanation: demo page for an internal koha page
 
      Variable: page_demo

      Value: What is up , this is my demo page.

      Click the TextArea link (or enter "TextArea" into the input field below it)
 
      variable options (last field): 100|80

  13- In a browser go to http://youraddress/cgi-bin/koha/pages.pl?p=demo
      youraddress can be localhost or 127.0.0.1

 14- 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.

 15- Hope it works. For any issue drop me a comment.

1 comment: