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
- Start with a plan of attack. This is the logic you need to figure out for how you are going to solve the problem.
- Have Plan of attack approved/peer reviewed to see if they agree
- Create the base files you think you will need, often based on standard scripts with pseudo comments
- Begin by writing functions inside the base files that once tested and working, are moved to a library
- 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.
- install.pl 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.
- 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.
- 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.
- 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 install.pl 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
- 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:
- To enable the new manager a line like
unshift @INC, "/htdocs/local/<manager_name>/lib"; must be added in local/global/lib/Library_global.pm, otherwise the new template will not be loaded.
- It is a very good idea to look at other modules when writing a new one as well as Library_global since there is a lot of code that is very useful contained within them that may be used, copied and modified rather than starting from scratch.
- Old modules did not assume that map manager, global, library_global::dbh, etc. were available. You will see this reflected. You can now assume that as of v0.3, codebase, mapmanager, colormanager, templatemanager,usermanager, newsmanager and photomanager are available and will not change names.
Website and Manager Structure Directions
- 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.
- 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.
- 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:
- css: This directory contains managers.css file which defines LunpaCMS managers' default CSS rules.
- images: A Lunpacms manager has one designated directory to store images used by itself under this directory.
- modules: Individual thrid-party supporting modules, such as FCKeditor, are stored in this directory.
- 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.
- Try to use DIV and CSS for page template HTML instead of multi level table.
- Use proper prefix in css class name. See employeemanager/css/manager.css for an example.
- Each manager's CSS rules can be overridden in local website css rules.
- On each page template.
- Wrap page title with <h1></h1> even for graphical titles.
- 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.
- Use LOCAL_SKIP_PRINT_HTML_HEAD_AND_BODY=1 for new sites which includes HTML head part in main-begin template.
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
$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.
Copyright © 2019 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