Google translator »

(Opens in a new window - öffnet in einem neuen Fenster)

# Short Documentation Addon "TemplateFuncs"

### About TemplateFuncs

TemplateFuncs is an Addon for CMSimple Templates. TemplateFuncs provides several useful functions for CMSimple templates.

## 1. System Requirements

TemplateFuncs requires a working installation of CMSimple_XH 1.2 utf-8 or higher.

Recommended is CMSimple 4.0 or higher.

## 2. Installation

1. Download the zip-file and unzip it with a suitable program.
2. Upload the folder "templatefuncs" to the folder of the template.

Now the file "templatefuncs.php" has to be included in the template.htm (on top, above the Doctype Declaration):

<?php include_once($pth['folder']['template'] . 'templatefuncs/templatefuncs.php');?>
<!DOCTYPE html>
...

## 3. The functions

### 3.1. The function "changing Newsboxes"

The newsbox function shows consecutively numbered CMSimple pages in a newsbox. The variantly shown CMSimple pages should begin with the name (normally "News"); followed by consecutive numbering. Example:

- News1001
- News1002
- News1003

You can create consecutively numbered newsbox-pages as many you want. Later in this document I refer to News1001 - News1003. The large numbers are chosen, to avoid conflicts with existing newsboxes on the page.

The change of NewsBoxes will happen with every page view, regardless of whether a new page is called or by reload the current page.

#### Usage in template.htm

News boxes usually are called in the template (template.htm); inserted where the news box shall appear.

##### Ordered change

The following function-call shows the pages News1001 - News1003 successive:

<?php echo tf_newsboxes('News',1001,1003); ?>

#### Random change

The following function-call shows the pages News1001 - News1003, changing in random order:

<?php echo tf_newsboxes('News',1001,1003,'random'); ?>

### 3.2. The function "changing images"

This function allows changing images or background images via inline CSS in the template.htm. The image change will happen with every page view, regardless of whether a new page is called, or the current page is reloaded.

The images are located in a subfolder of the folder "templatefuncs", for example "templatefuncs/bgheader/" for changing background images in the header.

Simply upload your image files into the folder "templatefuncs/bgheader/", and they will be included in the image change. If you want to remove an image, just delete it. The function "changing images" automatically recognizes the images in the folder.

The folder where the image files are located, must be specified in the function call:

<?php echo tf_images('bgheader'); ?>

Example for changing background images in the header:

<div id="header" style="background: #fff url(<?php echo tf_images('bgheader');?>) no-repeat;">
...
</div>

#### Random change

For random change, add the optional parameter "random" to the function call:

<?php echo tf_images('bgheader','random'); ?>

### 3.3. The functions for "special Links with Icons"

With these functions, you can show special CMSimple-links with small images (icons).

<?php echo tf_homelink('homelink.gif'); ?>
<?php echo tf_printlink('printlink.gif'); ?>
<?php echo tf_mailformlink('mailformlink.gif'); ?>
<?php echo tf_sitemaplink('sitemaplink.gif'); ?>
<?php echo tf_previouspage('prev.gif'); ?>
<?php echo tf_nextpage('next.gif'); ?>
<?php echo tf_top('top.gif'); ?>

The icons are located in the folder "templatefuncs/icons/". The file name and the filetype you have to specify in the function call (filenname.gif, filenname.png ...)

The icons you can style with the following CSS classes in the stylesheet.css of the template (e.g. spaces between the icons):

img.tf_homelink_icon {margin-right: 16px;}
img.tf_printlink_icon {margin-right: 16px;}
img.tf_mailformlink_icon {margin-right: 16px;}
img.tf_sitemaplink_icon {margin-right: 16px;}
img.tf_prev_icon {margin: 0 16px;}
img.tf_next_icon {margin: 0 16px;}
img.tf_top_icon {margin: 0 16px;}

### 3.4. The function openMenu()

With this function, you can create an opened menu. You optionally can specify two parameters, for menulevel "min, max":

<?php echo openMenu(1,2); ?>

Normally a simple function call is enough, menulevels as specified in the Configuration:

<?php echo openMenu(); ?>

### 3.5. The function tf_locator()

With this function you can create an alternative locator (breadcrumb navigation) with definable delimiter.

This function call uses the special character » as separator:

<?php echo tf_locator('&raquo;'); ?>

You also can refer an image. These function calls use the file locator.png in the directory .../templatefuncs/icons/ (in the template folder) as separator:

<?php echo tf_locator('<img src="' . $pth['folder']['template'] . 'templatefuncs/icons/locator.png" alt="">'); ?>

### 3.6. The function tf_contentPlus()

This function is similar to the Newsbox function, but instead of a specific page a subpage of the current page is displayed. The default page name of the displayed subpage is "tfContentPlus".

Standard plugin call in template.htm:

<?php echo tf_contentPlus(); ?>

The function can be called with 2 optional parameters:

<?php echo tf_contentPlus('pagename', 'CSS_class'); ?>

pagenname: The name of the dieplayed page, default: tfContentPlus
CSS_class: The CSS class of the surrounding divs, default: tf_cplus

The output is surrounded by 2 divs, the inner div gets the class with an appended "In", by default tf_cplus and tf_cplusIn.