In the Information Center you will find everything you need to know about SobiPro and its applications!
It is also the place to download SobiPro, its applications and language packages.
Enhance your directories!
Get additional functionality for SobiPro with our applications.
Design your directories!
Check out the different SobiPro templates we have created for you.
Let your directories speak your language!
SobiPro is translated into more than 30 languages.
As an active customer download the full version of SobiPro from the description page or download the trial version of SobiPro free of charge.
Although a lot can be done with XSL there are some limitations, especially as we can use only XSLT 1.0 and not XSLT 2.0 as there is no PHP support available for XSLT 2.0, means your server has only XSLT 1.0 installed. To overcome these limitations, it is necessary to call PHP for some functions. Therefore SobiPro provides not only built-in PHP functions, but also allows to add your own PHP code.
For security reasons it is not possible to call every PHP function directly from a template file. Every PHP function which should be available in the template has to be registered for its usage.
To allow the usage of your own defined PHP function, they need to fulfil the following:
tplDefault3
). If you have duplicated a template in the
global template manager of SobiPro, the name of the abstract class depends on the name of your template. SobiPro will correct the abstract class name
for you while duplicating the template.
To make things easier, the SobiPro templates already include by default the PHP file template.php in the root of the template folder. This PHP file already contains the needed structure (including an abstract class) inside of it and it's already defined in the global configuration file. You only need to care about adding your own functions to this file and call them from your templates.
Example of a PHP file containing your own PHP functions:
<?php defined( 'SOBIPRO' ) || exit( 'Restricted access' ); abstract class tplDefault4 { public static function MyFirstFunction($para1, $para2) { ... return myResult; } public static function MySecondFunction($para1, $para2) { ... return myResult; } } ?>
Every PHP function defined within the abstract class in the PHP file is available in your template files. Of course you can use your own PHP file, with your own abstract class, but frankly, there is no reason to do so.
The following PHP functions are registered by default:
To register another PHP function, create an override file of the file template_functions.ini located in the /components/com_sobipro/etc
folder. The name of your override file will be template_functions_override.ini. To register a PHP function, extend the section
[functions]
by a new line. The key will be the name of the PHP function and the value is true
.
To call a PHP function in one of your template files, you have to extend the definition of the template document to include the PHP namespace (xmlns:php="https://secure.php.net/xsl"
)
in the stylesheet tag. Normally this is already added to all template files, but in case you have an older file or a file from a 3rd party developer who
doesn't included this tag, you need to add it in order to use a PHP function in the template file.
To call a PHP function, defined in your PHP file, use the following structure:
<xsl:value-of select="php:function ('tplDefault3::MyFirstFunction', 'para1', 'para2')"/>
Where tplDefault4
is the name of the abstract class defined in your PHP functions file. If using the default SobiPro template, this will be
'tplDefault4'. This may be different for older or 3rd party templates.
MyFirstFunction
is the name of the function itself, and para1
and para2
are strings passed to the function as
arguments.
A function which is used in an XSL template can return either a simple string or in case you need a more advanced structure, a DOMDocument element (it may also return nothing). Depending on what it returns, it can be used alone, or will require additional code to handle the data returned.
Functions defined in each template's template.php file, are "limited" to that specific template, meaning you won't be able to use them in other templates or in SobiPro modules, unless you double them.
It is possible to define a global PHP functions file to use in all section templates and the module's template files.
To define global PHP functions, you need to create a global PHP file containing all functions you want to use globally within SobiPro. The structure of that
file will be the same as for the SobiPro template's template.php files. The global PHP file has to be located in the
front folder of SobiPro template's area, accessible via the global template manager. It is wise, to use a different name for its
abstract class name, for example abstract class GlobalFunctions
, to distinguish it from the local PHP functions.
All your global PHP functions need to be registered in order to use them. For that create an override file of the file template_functions.ini
located in the /components/com_sobipro/etc folder. The name of your override file will be template_functions_override.ini.
To register your own global PHP function, create a section in the file with the name and path of your global PHP file in the
front folder. Replace the slashes with dots and leave the file extension.
If you named your global PHP file my-global-functions.php the section will be
[usr.templates.front.my-global-functions]
. Now add a line for each PHP function in your global file, where the key is the name of the PHP
function and the value is true
.
If you have for example two PHP functions "IsNew()" and "IsUpdated()", your section will look like:
[usr.templates.front.my-global-functions] IsNew = true IsUpdated = true
There are several predefined SobiPro PHP functions available to use in the template files.
The predefined PHP functions don't need to be mentioned in the local or global PHP files. The abstract class for these predefined PHP functions is always
SobiPro
.
The function SobiPro::Cfg
returns a SobiPro configuration setting...
public static function Cfg($key, $def = null, $section = 'general')
...and has the following parameters:
Example usage: returns the live URL address of the site
<xsl:value-of select="php:function( 'SobiPro::Cfg', 'live_site' )"/>
The function SobiPro::My
returns the selected property of the current user...
public static function My($property)
...and has the following parameters:
Example usage: welcomes a registered user
Welcome <xsl:value-of select="php:function('SobiPro::My', 'name')"/>
The function SobiPro::User
returns a selected property of an user identified by the given id...
public static function User($id, $property)
...and has the following parameters:
Example usage: returns the real name of the author of the currently displayed entry
<xsl:variable name="author"> <xsl:value-of select="entry/author"/> </xsl:variable> Author: <xsl:value-of select="php:function('SobiPro::User', $author, 'name')"/>
The function SobiPro::Tooltip
creates a tooltip with given text and title...
public static function Tooltip($tooltip, $title = null)
...and has the following parameters:
Example usage:
<xsl:variable name="desc"> <xsl:value-of select="description"/> </xsl:variable> <xsl:variable name="label"> <xsl:value-of select="label"/> </xsl:variable> <xsl:value-of select="php:function( 'SobiPro::Tooltip', $desc, $label )" disable-output-escaping="yes"/>
Default SobiPro translation method. The function SobiPro::Txt
returns a translated string depending on the currently active language...
public static function Txt($txt)
...and has the following parameters:
You will see the usage of this function in all default SobiPro template files.
Example usage:
<xsl:value-of select="php:function('SobiPro::Txt', 'Text to show')"/>
The function SobiPro::Url
creates an internal URL to SobiPro functions/listings...
public static function Url($var = null, $js = false)
...and has the following parameters:
If SEF is enabled and available for SobiPro, the URL will be search engine friendly.
Example usage: creates the link /index.php?option=com_sobipro&sid=600&task=entry.edit&Itemid=99
<xsl:variable name="Url"> {"sid":"600","task":"entry.edit"} </xsl:variable> <xsl:value-of select="php:function('SobiPro::Url', $Url)"/>
The function SobiPro::Request
retrieves a parameter from the request (POST/GET)...
public static function Request($key, $def = null)
...and has the following parameters:
The function SobiPro::AlternateLink
allows to add an alternate link to the HTML header of the displayed document...
public static function AlternateLink($url, $type, $title = null)
...and has the following parameters:
application/atom+xml
or application/rss+xml
Refer to Links and search engines on W3C for more information about alternate links.
Example usage: in the template file section/view.xsl, to create an alternate link for RSS feeds
<xsl:variable name="rssUrl"> {"sid":"<xsl:value-of select="id"/>", "sptpl":"feeds.rss","out":"raw"} </xsl:variable> <xsl:variable name="sectionName"> <xsl:value-of select="name"/> </xsl:variable> <xsl:value-of select="php:function( 'SobiPro::AlternateLink', $rssUrl, 'application/atom+xml', $sectionName )"/>
The example above generates the following alternate link:
<link href="/component/sobipro/600/view,rss?Itemid=23" rel="alternate"
type="application/atom+xml" title="Section Name"/>
The function SobiPro::Can
checks the permission for an action...
public static function Can($subject, $action = 'access', $section = null, $ownership = 'valid')
...and has the following parameters:
Example usage: checks if entry owner may see unpublished entries
<xsl:value-of select="php:function('SobiPro::Can','entry','see_unpublished','own')"/>
To shorten this, it can also be used also in a short form (section is always the current section):
<xsl:value-of select="php:function('SobiPro::Can', 'subject.action.ownership')"/>
public static function Currency($value)
Formats a given value using currency options as set in Global Configuration - Payment Options (currency -€, $...-, currency symbol position, decimal point, thousands separator).
It and has the following parameters:
Example usage:
<xsl:variable name="price"> <xsl:value-of select="fields/field_price/data"/> </xsl:variable> <xsl:value-of select="php:function( 'SobiPro::Currency', $price )"/>
Copyright (C) 2006-2024 Sigsiu.NET GmbH (https://www.sigsiu.net). All rights reserved.
This documentation and all images therein are copyrighted and protected by law. You may not publish, distribute or sell them or parts of it without explicit written permission of Sigsiu.NET GmbH.