B2 Extra Options
// $Id: b2extraoptions.html,v 1.2 2002/11/28 23:31:33 zed1 Exp $
//
// B2 Extra Options
// Copyright (C) 2002 Mike Little -- mike@zed1.com
//
// This is an add-on to b2 weblog / news publishing tool
// b2 is copyright (c)2001, 2002 by Michel Valdrighi - m@tidakada.com
//
// **********************************************************************
// Copyright (C) 2002 Mike Little
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// Mike Little (mike@zed1.com)
// *****************************************************************
B2 Extra Options is an add-on to b2 weblogging software.
- It plugs in to the admin screens.
- It adds to menu commands: Extra Options
- It allows you to define arbitrary extra options for use in your templates.
- Each option can has a name, type, value, description, and admin level.
- You can control who is allowed to modify the value of these options.
- You can control who is allowed to create and edit the details of these options.
You can download it from http://zed1.com/b2extraoptions/b2options-0.2.zip
Also available as a tar ball: http://zed1.com/b2extraoptions/b2options-0.2.tar.gz
Files:
- b2extraoptions.readme.txt
- this file
- b2extraoptions.sql
- sql to create the necessary database tables
- b2extraoptionsmanager.php
- admin plugin to manage links
- b2extraoptions.php
- template functions
- b2extraoptions.install.php
- alternate installation method
- license.txt
- GNU General Public License Version 2
Installation:
- Execute the SQL from the file b2extraoptions.sql. This will create the two tables
and add two extra options. Alternatively, upload the file b2extraoptions.install.php
to your B2 installation directory and load it into your browser.
***Note***:
There is a bug in the file b2extraoptions.install.php: You need to insert
$connexion = mysql_connect($server,$loginsql,$passsql) or die("Can't connect to the database<br>".mysql_error());
$dbconnexion = mysql_select_db($base, $connexion);
before the line $got_options = false;
You can fins an updated version here
- Edit the b2-include/b2menutop.txt file to add in the new command.
5 b2extraoptionsmanager.php Extra Options
Note: there should be a tab character after the 5 and after the filename.
- Add the files b2extraoptions.php and b2extraoptionsmanager.php into your b2 install directory.
- Login and click on the Extra Options command to edit options.
- You will be presented with a list of existing extra options.
- If your admin level is high enough you will have a 'Change' button next to each option you are allowed to change. This will allow you to change the VALUE of an option.
- If your admin level is even higher you will also have an 'Edit' button next to each option. You will also have a 'New Option' Button.
- If you are editing or creating a new option, the fields mean the following:
- name This is the name of the option. This is also the name you pass to the functions documented below.
- Type This is the type of the option value. Currently only boolean does anything different.
When you wish to change the VALUE of an option of type boolean, you are presented with a true/false selector.
All other types just give you an edit field. More type specific support will be added in later versions.
- Value This is the initial value of the option.
- Description The description of the option.
- Admin level This is the level a user has to be in order to change the value of the option you are defining.
- In your template include_once("b2extraoptions.php")
- You can then use <?php echo get_extraoption('option_name'); ?> in order to
in this case, output the value of the option.
- Or you may want to test the value of an option:
include_once("./b2extraoptions.php");
if (get_extraoption('blog_closed') == 'true') {
die("The blog is closed, sorry.");
}
- The use you make of the extra option is entirely up to you.
- There is also a function: get_extraoption_level() which retrieves the admin level required to change the option.
- See the comments above each function for full details.
- There is a special, reserved extra option: 'add_options_min_level'. This is
used to set the admin level at which a user can edit the details of an
option, or create new options.
To Do:
- Support, integer, string, and date types properly.
- Allow deletion of an option.
- Think of some more/better examples!
Changes
- 0.1 - initial release
- 0.2 - Fixed JavaScript error in Internet Explorer.
Added PHP database installation script.
Thats about it really. This is beta software, and has not been extensively tested. Use with caution.
--
Mike Little
mike@zed1.com