MAXdev
MDLite developers documents
TiMax

Here you can found some usefull documents about developement with MDLite

 



Convert old modules to MDLite

Some tips to convert old modules to new MDLite structure

Some old MDPro/Postnuke modules need several modifications to make them MDLite compatible, other modules need just minimal hacks, you can read bellow some tips maybe can be usefull to convert some modules, please let us know if you will working to convert some modules, so all community can know about

with just these simple action several old modules can work with MDLite and please share your work

then if you want to use Tinymax editor in your module, you can follow these istructions 

we can use hooks to activate Tinymax editor in our modules, so for example

you can just add something like that

pnModCallHooks('item','transform','',array('textarea name1','textarea name2'));

in your module, then you can activate Tynimax editor manually from Admin/modules click in Name module or you need to add something like that in your db

INSERT INTO md_hooks VALUES ('', 'item', 'transform', 'Name module', NULL , 'API', 'Tinymax', 'user', 'transform');

sure you can write pninit to do it automatically with installation procedure

 




Autorender documentation

 

Autorender Documentation

 

Content

 

•1.Introduction

•2.Directories structure

•3.Processing algorithms

•4.Plugins

•5.Example module

•6.Templating details

•7.NOTES

 

 

1. Introduction

Autorender module is a templating engine  based on teo popular templating engines:

AutoTheme engine from Shawn ()

and Smarty engine from smarty.php.net

Autorender was made to join the power of AutoTheme and power of Smarty. It supports AutoTheme templates almost without signifficant changes,  and supports almost all  the features of AutoTheme and Smarty together.

Smarty support also allows to use or port pnRender-based modules form postNuke with easy.

 

 

2. Directories structure

 

The Autorender has the following directory structure:

Root MD Pro Catalog

|--libs

     |--render_smarty                Contains basic Smarty code without changes 

            |--plugins                     contains Smarty plugins for the whole site

                |--smarty_core         contains basic smarty plugins from smarty developer

                |--api                       contains api-depenedent plugins from postNuke and MDPro

|--modules

    |--Autorender                     Contains code of AutoTheme modified to support Smarty.

    |--Your custom module

            |--templates                 Contains Autorender templates for your custom module

                |--plugins                 Contains plugins for Autorender for your custom module

|--cache

    |--_arcompile                      Contains compiled templates for autorender, must be 777

    |--_cache                             Contains cached pages from smarty, must be 777

 

 

3. Processing algorithms.

Basically, the Autorender could work in two modes:

 

Mode No.1 - get the template, parse it with a smarty, treat this as a AutoTheme template and parse by AutoTheme parser, then return to user. This mode supports both template constants and algorithms - smarty ones and AutoTheme ones,  but works slower than only smarty or only AutoTheme

 

Mode No.2 - get the template, parse it with a smarty, then return to user. This mode supports only smarty tags, but works faster than Mode No.1. Recommended to use in speed critical modules or blocks, that does not requires AutoTheme tags.

 

4. Plugins.

Plugins allows you to write a custom command or modifier to use it within template.

Basically, plugins are divided into smarty ones, api ones, and module ones.

Smarty ones are placed inot libs/render_smarty/plugins/smarty_core directory and necessary to support basic smarty functionality:

 

a) Commands

            plugin file names:

            function.YourFunctionName.php

            template usage:

            <% YourFunctionName

                        parameter1Name=parameter1value

                        parameter2name=parameter2value

            %>

 

b) Modifiers

            plugin file names:

            modifiers.YourModifierName.php

            template usage:

            <% $value|YourModifierName %>

 

 

           

            Some useful smarty syntax provided by commands

 

<% section loop=$myarray name="myvar" %> 

            <% $myarray[myvar].array_element %> <br>

<%sectionelse%>

            No data found

<%/section%>

            Making a loop over array items.

            http://smarty.php.net/manual/en/language.function.section.php

 

<%if $condition ne "" %>

            <% $condition %> is not null

<%else%>

            <% $condition %> is null

<%/if%>

            Checks if the condition true or false

            Supports basic operations (eq,ne,gt,lt,le,ge,not and theirs mathematical analogues)

http://smarty.php.net/manual/en/language.function.if.php

 

<% include file="yourfile.tpl" %>

            Includes another template into current one

            http://smarty.php.net/manual/en/language.function.include.php

 

<%php%>

 echo "php code works";

<%/php%>

            Includes php code into templates. Not recommended to use ;)

http://smarty.php.net/manual/en/language.function.php.php

 

 

            Some useful supported smarty core functions (defined as plugins) are:

<% config_load file='dfsf' section='dsfsd'

     scope='fsd' global=true %>

 is used for loading config variables from a configuration file into the template file.

 

<% counter name='dfsf' start=1 skip=2

          direction=up print=false assing=varname %>

      Remembers the count on each iteration and is used to print it.

      http://smarty.php.net/manual/en/language.function.counter.php

 

<% cycle name="gfdg" values="blue,green,red" print="false"               delimiter="," assign="varname" reset="true" %>

     

      is used to cycle though a set of values (looks like php foreach).

      http://smarty.php.net/manual/en/language.function.cycle.php

     

 

<% debug output="Your string here" %>

       dumps the debug console to the page.

      http://smarty.php.net/manual/en/language.function.debug.php

 

<% eval var="$x+1" assign="varname"%>

  used to evaluate a variable as a smarty template.

      http://smarty.php.net/manual/en/language.function.eval.php

 

<% fetch file="http://somewhere.there/file" assign="varname" %>

 Used to download files from the local file system, http or ftp and display or assign theirs contents.

      http://smarty.php.net/manual/en/language.function.fetch.php

 

 

<% html_checkboxes name="outputname"

          options=$associated_array_values

          selected=$string_or_array_of_values %>

       is a custom function that creates checkbox group with data provided by creator.

 http://smarty.php.net/manual/en/language.function.html.checkboxes.php

 

<% html_options

     name="outputname"

     values=$array_of_values

     selected=$string_or_array %>

      Same as html_checkboxes, but for select list

      http://smarty.php.net/manual/en/language.function.html.options.php

 

<% html_radios name="outputname"

     values=$array_of_values

     selected=$string_or_array %>

 

      Same as html_checkboxes, but for radio buttons

http://smarty.php.net/manual/en/language.function.html.radios.php

 

<% html_select_date prefix="mydate_"

     time="2005-12-31"

     start_year="1970"

     end_year="2020" %>

      Creates dropdown select boxes to select a date.

 http://smarty.php.net/manual/en/language.function.html.select.date.php

 

<% html_select_time

          prefix="mytime_"

          time=$unixtimestamp

          %>

      Creates dropdown select boxes to select a date.

http://smarty.php.net/manual/en/language.function.html.select.time.php

 

<% html_table loop=$array_of_data cols=10 rows=20 %>

 Dumps an array into an HTML table.

http://smarty.php.net/manual/en/language.function.html.table.php

 

<% html_image file="image_path" height=10 width=20

          alt="Alt name" href="http://link.here/" %>

      Create image tag from given data.

      I am not sure whether this is useful or not.      http://smarty.php.net/manual/en/language.function.html.image.php

 

<% mailto address="me@maxdev.com" text="Contact me"

          subj="Mail from site" %>

      Creates a mailto tag for given data

http://smarty.php.net/manual/en/language.function.mailto.php

 

<% math equation="x*y" x=2 y=3 format="%d" %>

      Calculates a math equation.

http://smarty.php.net/manual/en/language.function.math.php

 

 

All the detailed information about these function is available at smarty site:

http://s/

 

Some useful core modifiers:

 

truncate:20:"...":true

Limits printed value by 20 chars, sets '...' at the end.

http://smarty.php.net/manual/en/language.modifier.truncate.php

 

nl2br

Converts line feeds to the <br> tags

http://smarty.php.net/manual/en/language.modifier.nl2br.php

 

date_format:"%B %e, %Y %H:%M:%S"

Outputs unixtimestamp as string date.

http://smarty.php.net/manual/en/language.modifier.date.format.php

 

strip_tags

Removes html tags

http://smarty.php.net/manual/en/language.modifier.strip.tags.php

 

All the detailed modifiers information available at

http://smarty.php.net/manual/en/

 

 

postNuke/MDPro API functions/modifiers

 

There is a number of special modifiers and functions to support api-dependent functionality. Under postNuke they are used by pnRender.

 

<% opentable %>

<% closetable %>

<% opentable2 %>

<% closetable2 %>

Tags for opening and closing two standard table types

 

<% const name=_YOUR_CONSTANT_NAME%>

Show constant (might be language dependent)

 

<% pager %>

Show pager with given parameters (description should be extended)

 

<% pnblock id=45 %>

Output contents of a block with given id (added to a system using admin->Blocks)

 

<% pnconfiggetvar name="param_name" %>

 

Print config value for a given parameter name

 

<% pnmodapifunc modname="YouModuleName" type="user"

                                   func="your_func_name" param1="val1"

                                   param2="val2" %>

Call api function for givven module,type and parameters values

 

<% pnmodgetvar module="YouModuleName" name="ParamName" %>

 

Get module config variable

 

<% pnvarcleanfrominput name="ParamName" %>

 

Get input (post/get) parameters

 

<% pnusergetvar uid="2" name="ParamName" %>

 

Get user-dependent paramters

 

<% pnsecgenauthkey module="YourModuleName" assign=$variable_name %>

 

Generate AuthKey (required for some edit/delete/update operations )

 

Modifiers:

 

pnvarprepforstore

Prepare variable for storing

pnvarprepfordisplay

Prepare variable for displaying

 

pnvarprephtmldisplay

Prepare variable for displaying as html code

 

 

AutoRender_docs.pdf AutoRender_docs.pdf (451.71 KB 31.05.2006 05:48)