LunpaCMS Whipping your website into shape! Introducing Lunpa, our mascot.  Her mother was a hamster and her father was Chilean M00se.  Oddly, neither smelt of elderberries.

Writing LunpaCMS Managers

One of the best features of LunpaCMS is its ease of extensibility and reuse of existing code. This documentation describes how to make the best use of code that already exists as well as tips to keep in mind when writing a new manager for LunpaCMS

Basic Steps

  1. Start with a plan of attack. This is the logic you need to figure out for how you are going to solve the problem.
  2. Have Plan of attack approved/peer reviewed to see if they agree
  3. Create the base files you think you will need, often based on standard scripts with pseudo comments
  4. Begin by writing functions inside the base files that once tested and working, are moved to a library

Detailed Steps

  1. Managers reside in the directory /htdocs/local/ usually as a pair of directories: one for the user side (i.e. “lunpamanager“) and one for the admin side (i.e. “lunpamanageradmin”). You can have a module with both admin sides and user sides (such as newsmanager), with only admin sides (such as mapmanager) or with only user sides (such as filelister). Using subdirectories of the module main dir to store perl cgi files is not currently supported because it breaks database connection handling.
  2. is the file that installs the module onto websites. This is done is by creating symlinks in the /html directory (for user side) and in the /html/admin directory (for admin side) to the manager directories, so there is only one copy of the code per server. To create this file, simply copy an existing one and edit the directories that are symlinked. Note: because of this installation process and the nature of managers in general, they should not contain anything hard coded for specific sites.
  3. Scripts in the admin directory should have a main call setting the admin parameter set to 1, ( i.e. &main(admin=>1);) to enforce admin user (though this should be caught by .htaccess in the sites’ /admin directory, not having this set to 1 can cause other problems) Also note that you will usually want admin set to 0 in non admin manager directories.
  4. Other standard files can easily be copied from other modules such as index.cgi, and the lib directory as a starting point for writing the new manager. Important: the lib directory must contain the .htaccess file (with “Deny from all” in it) to keep people from accessing it or downloading it.
  5. Most managers will have a database backend. The file that creates the database tables that are necessary for the manager is usually <manager_name>.sql which is run by the file for that manager to install the database portions of the manager. This file is also how managers set the default settings for their necessary maps in mapmanager. Note all the install scripts/SQL stuff is ALWAYS in the /admin portion of a module
  6. When adding a module, the BEGIN section at the top of GLOBAL should be modified to add: @INC /htdocs/local/<manager_name>/lib. A use statement should be added to the existing list and the admin_menu function should be modified to include: use Library_<manager_name>
  7. To enable the new manager a line like unshift @INC, "/htdocs/local/<manager_name>/lib"; must be added in local/global/lib/, otherwise the new template will not be loaded.


Website and Manager Structure Directions

  1. Current LunpaCMS prints <!DOCTYPE> ... <body> part programatically. For newer version of websites, change this to have main-begin.template and index_main-begin.template to include this part of HTML.
    1. Use :::xxx::: for page specific dynamic data replacement, such as meta-data, but no style related items. All style related definition should go into CSS file.

  2. LunpaCMS uses globalresources directory to store all supporting data components for its managers. This directory is symbolic linked from sites' document directory, so end users can only access to this directory, but they cannot add, update, or delete resources in the directory. globalresources consists of following sub directories:
    1. css: This directory contains managers.css file which defines LunpaCMS managers' default CSS rules.
    2. images: A Lunpacms manager has one designated directory to store images used by itself under this directory.
    3. js: This directory contains jsLib.js file. Commonly used JavaScript functions through LunpaCMS managers are stored in this JavaScript library file. Also, generally used JavaScript libraries, such as jQuery, can be stored in this directory.
    4. modules: Individual thrid-party supporting modules, such as FCKeditor, are stored in this directory.

  3. Use html/resources/css, html/resources/images/, html/resources/js under html directory for site design. And use html/images directory for content related items.
    1. Try to use DIV and CSS for page template HTML instead of multi level table.

  4. Each manager will have its own css rules, images, js. And each website will have its own css file(s) in html/resources/css directory. All css and javascript files will be included in in main-begin.template file.
    1. Use proper prefix in css class name. See employeemanager/css/manager.css for an example.
    2. Each manager's CSS rules can be overridden in local website css rules.

  5. On each page template.
    1. Wrap page title with <h1></h1> even for graphical titles.
    2. Use <div>, <p> properly. <div> is for piece of sentences or an area of design structure. <p> is for text paragraph. And avoid using <br> for paragraph separation.

  6. Use LOCAL_SKIP_PRINT_HTML_HEAD_AND_BODY=1 for new sites which includes HTML head part in main-begin template.

LunpaCMS Tags

LunpaCMS tags are formatted as such: These tags are parsed in get_template in Library_global and can be overwritten in local libraries. They are one of the main ways that managers are displayed and deployed on a website using LunpaCMS, and thus should be key elements to writing the managers themselves

Ex. $currentline =~ s/:::HEADLINES:(.*):FORMAT:(.*):::/&Library_newsmanager::get_news_headlines($FORM, limit=>$1, format=>$2)/eig;

This takes the :::HEADLINES:FORMAT::: tag and calls the get_news_headlines function with the given parameters.

Add Your Comment

(Only a limited set of HTML tags such as <b>, <i>, <u> are allowed. Embedded flash video from Youtube or Vimeo are also supported.)

Copyright © 2024 Peregrine Computer Consultants Corp. All rights reserved.

About Lunpa, our mascot. Her mother was a hamster and her father was an ill-tempered Chilean M00se. Oddly, neither smelt of elderberries.
The artist is Jennifer Lomax.