Using the module template class

From Sohowiki
Jump to: navigation, search

Contents

Disclaimer

This page is intended for php-literate developers who are already familiar with building plugins for Soholaunch Pro Edition. Until this sentence is removed, this page is under construction and will mainly be a reference for advanced developers.

Introduction

The module template class makes it easy for you as the plugin developer to create management modules in the Soholaunch admin tool (i.e. linked to off the Main Menu) that have the same look and feel as the rest of the admin tool --- even if we (Soholaunch) make changes to that look and feel your plugin will automatically reflect the changes without you having to do anything.

Sample module file

Start by making a copy of this file to serve as the foundation for your admin module...

sohoadmin/program/modules/sample_module.php
<?php
error_reporting(E_PARSE);
if($_GET['_SESSION'] != '' || $_POST['_SESSION'] != '' || $_COOKIE['_SESSION'] != '') { exit; }

#=====================================================================================
# Soholaunch(R) Site Management Tool
#
# Author:        Mike Morrison
# Homepage:      http://www.soholaunch.com
# Release Notes: http://wiki.soholaunch.com
#
# This Script: Simple example module to illustrate how to create a new
# module and keep it's look consistent with the rest of the product
#=====================================================================================

error_reporting(E_PARSE);
session_start();

# Include core files
include_once($_SESSION['docroot_path']."/sohoadmin/program/includes/product_gui.php");
include_once($_SESSION['docroot_path']."/sohoadmin/program/includes/smt_module.class.php");

# So you can write straight HTML without having to build every line into a container var (i.e. $disHTML .= "another line of html")
ob_start();

?>


<!---Module html goes here-->
Module html goes here.


<?
# Grab module html into container var
$module_html = ob_get_contents();
ob_end_clean();

# Note: "Create Pages" used for example purposes. Replace with your own stuff.
$module = new smt_module($module_html);
$module->add_breadcrumb_link("Create New Pages", "program/modules/create_pages.php");
$module->icon_img = "skins/".$_SESSION['skin']."/icons/full_size/create_pages-enabled.gif";
$module->heading_text = "Create New Pages";
$module->description_text = "You may create up to 10 new pages at a time.";
$module->description_text .= "Please only use alpha-numerical characters and spaces.";
$module->good_to_go();
?>

REQUIRED module class directives

This should go at the bottom of the php file for your admin module.

$module = new smt_module($module_html);
$module->add_breadcrumb_link("Create New Pages", "program/modules/create_pages.php");
$module->icon_img = "skins/".$_SESSION['skin']."/icons/full_size/create_pages-enabled.gif";
$module->heading_text = "Create New Pages";
$module->description_text = "You may create up to 10 new pages at a time.";
$module->description_text .= "Please only use alpha-numerical characters and spaces.";
$module->good_to_go();

Make sure this line comes last, as it compiles all your options into the final html output and displays it.

$module->good_to_go();

OPTIONAL module class directives

These directives allow you to modify the styles of the default module template for special purposes (the lines below were taken from the "Edit Form" feature were we wanted all the space we could get to cram in all of the options and form preview area, and we wanted the module contents (i.e. the top edges of the Form/Field Properties and Form Preview panes) to butt right up against the module header. So we stretched the module template to 100% to fill the whole screen and took all the padding and margins off of the module html container area.

$module->module_table_css = "margin: 0px;width: 100%;height: 100%;border: 0;";
$module->container_css = "margin: 0;padding: 0;";
Personal tools