Skip to content
You are here:
Template Commands | Print |

The description on this site is always for use with the newest SOBI2 version. Most of the functions will work also in older versions. Some older commands (not longer mentioned here) are deprecated.

General Styling Options
Advanced Template Styling
Advanced Template Styling Part II
Inserting Plugin Code

General Styling Options

Description of the basic statements for the Details View and V-Card Template. Insert the statements you need. By default (standard template) all basic statements are included in the template file.

HTML skills are necessary!

Wherever the $mySobi object is used, you should know that this object exists by default only in the Details View Template. In the V-Card Template this object has to be created first using the following statement. The $mySobi object should be created only once for the whole V-Card Template.

<?php $mySobi = new sobi2( $id ); ?>

Style of the Details View (Details View only)  | link | 

That is the background image and border as defined in the SOBI2 back-end configuration. If you remove this statement, the configuration settings are no longer effective.

<?php echo $style; ?>

Style of the V-Card (V-Card only)  | link | 

The style as defined in the SOBI2 back-end configuration. That is the background image and border. If you remove this statement, the configuration settings are not longer effective. Also you will loose the "width" setting if using multiple columns for V-Cards.Don't remove the table column statement!

<td <?php echo $style; ?> >

Title of the entry  | link | 

Normally, this is the company name if you use SOBI2 as a business directory.

<?php echo $mySobi->title ?>

Title of the entry with link to Details View (V-Card only)  | link | 

<?php echo $title; ?>

Icon and image  | link | 

<?php echo $ico; ?>
<?php echo $img; ?>

All other fields  | link | 

This statement inserts all other fields as defined by the fields manager, including your self defined custom fields.

<?php HTML_SOBI::customFieldsData($fieldsFormatted); ?>

Integrated Google Map (Details View only)  | link | 

This statements works only if Google Maps is set up in the back-end correctly.

<?php HTML_SOBI::showGoogleMaps($mySobi, $config); ?>

Way search link  | link | 

<?php HTML_SOBI::waySearchUrl($waySearchLink); ?>
If using this command in the V-Card, you need to create the waysearch link first. To do this, just uncomment (by removing the two slashes) the two lines already given in the default V-Card.
$mySobi = new sobi2($id);
$waySearchLink = HTML_SOBI::createWaySearchUrl($id);

Date and time  | link | 

These statements insert date and time or date only when the entry was added to the directory.

<?php echo HTML_SOBI::addedDate($config, $mySobi); ?>
<?php echo HTML_SOBI::addedDateOnly($config, $mySobi); ?>

Number of hits  | link | 

This statement inserts the number of hits for the entry.

<?php echo HTML_SOBI::showHits($config, $mySobi);?>

Edit and delete buttons  | link | 

These buttons are only shown for the registered owner of the entry and for administrators.

<?php echo HTML_SOBI::editButtons($config, $mySobi); ?>

Separate edit and delete buttons (V-Card only)  | link | 

<?php echo $editButton; ?>
<?php echo $deleteButton; ?>

Link to the "Renew" function  | link | 

This statement inserts a link to the "renew entry" function when the entry expires soon and the renew functionality is enabled in the administration panel.

<?php HTML_SOBI::renewal($config, $mySobi); ?>

Selected categories  | link | 

This statement inserts the selected categories for the entry in the form category | category | category .

<?php echo HTML_SOBI::getMyCategories($mySobi, true);?>

Instead of the returned string you can get an arry with the categories. You have to execute a foreach loop to get all categories for the entry. This is only an example on how to get the info. You have to do your own programming to show the info in the way you want.

<?php foreach (HTML_SOBI::getMyCategories($mySobi) as $category) {
   echo $category['href'];
   echo $category['introtext'];
   echo $category['name'];
   echo $category['icon'];
}
?>

Hot label  | link | 

This statement inserts the "hot" label for the entry. By default an entry is "hot" if it has 500 hits. You can also define how much hits are needed to make an entry "hot". The second statement shows an example for 1000 hits.

<?php echo HTML_SOBI::hotLabel($mySobi);?>
<?php echo HTML_SOBI::hotLabel($mySobi, 1000);?>

Updated label  | link | 

This statement inserts the "updated" label for the entry. By default an entry has an "updated" label if it has been updated within the last three days. You can also define the number of days. The second statement shows an example for 10 days.

<?php echo HTML_SOBI::updatedLabel($mySobi);?>
<?php echo HTML_SOBI::updatedLabel($mySobi, 10);?>

New label  | link | 

This statement inserts the "new" label for the entry. By default an entry is "new" if it has been added within the last three days. You can also define the number of days. The second statement shows an example for 10 days.

<?php echo HTML_SOBI::newLabel($mySobi);?>
<?php echo HTML_SOBI::newLabel($mySobi, 10);?>

Link to all entries of the author  | link | 

This statement inserts a link to a list of all entries of the author. By default the label of this link is the real name of the author. You can also specify that this should be the login name.

<?php echo HTML_SOBI::userHref($mySobi);?>
<?php echo HTML_SOBI::userHref($mySobi, "login");?>

Tags/Meta Keys  | link | 

This statement inserts the selected tags for this entry. Tags in SOBI2 are created from the meta keys which the user has entered in add/edit entry form. By default this statement shows the first five selected tags. You can overwrite the default number of this function.

<?php echo HTML_SOBI::showTags($mySobi); ?>
<?php echo HTML_SOBI::showTags($mySobi, 20); ?>

Advanced Template Styling | link | 


Another method to insert the fields is to do it individually for each field instead of using the statement for inserting all fields defined in the fields manager at once. Don't forget to add your self defined custom fields!

The statements below already contain the formatting information like the CSS id or newlines as adjusted in the SOBI2 fields manager and the label of the field. Therefore you need no extra styling for them.

HTML skills are necessary!

Inserts the field street

<?php echo $fieldsFormatted['field_street']; ?>

Inserts the field postcode

<?php echo $fieldsFormatted['field_postcode']; ?>

Inserts the field city

<?php echo $fieldsFormatted['field_city']; ?>

Inserts the field county

<?php echo $fieldsFormatted['field_county']; ?>

Inserts the field federal state

<?php echo $fieldsFormatted['field_federal_state']; ?>

Inserts the field country

<?php echo $fieldsFormatted['field_country']; ?>

Inserts the field email

<?php echo $fieldsFormatted['field_email']; ?>

Inserts the field website

<?php echo $fieldsFormatted['field_website']; ?>

Inserts the field contact person

<?php echo $fieldsFormatted['field_contact_person']; ?>

Inserts the field phone

<?php echo $fieldsFormatted['field_phone']; ?>

Inserts the field fax

<?php echo $fieldsFormatted['field_fax']; ?>

Inserts the field hotline

<?php echo $fieldsFormatted['field_hotline']; ?>

Inserts the field description

<?php echo $fieldsFormatted['field_description']; ?>

Advanced Template Styling Part II | link | 


To do some further programming or add some custom PHP code you need probably the raw field values without any formatting information like the CSS id. To get these raw data directly use the statements below.
To show the raw data of a field you need to add an echo statement.

HTML and PHP skills are necessary!

The raw value of the field street

<?php $fieldsObjects['field_street']->data; ?>

The raw value of the field postcode

<?php $fieldsObjects['field_postcode']->data; ?>

The raw value of the field city

<?php $fieldsObjects['field_city']->data; ?>

The raw value of the field county

<?php $fieldsObjects['field_county']->data; ?>

The raw value of the field federal state

<?php $fieldsObjects['field_federal_state']->data; ?>

The raw value of the field country

<?php $fieldsObjects['field_country']->data; ?>

The raw value of the field email

<?php $fieldsObjects['field_email']->data; ?>

The raw value of the field website

<?php $fieldsObjects['field_website']->data; ?>

The raw value of the field contact person

<?php $fieldsObjects['field_contact_person']->data; ?>

The raw value of the field phone

<?php $fieldsObjects['field_phone']->data; ?>

The raw value of the field fax

<?php $fieldsObjects['field_fax']->data; ?>

The raw value of the field hotline

<?php $fieldsObjects['field_hotline']->data; ?>

The raw value of the field description

<?php $fieldsObjects['field_description']->data; ?>

Raw data for checkbox group  | link | 

Raw data for checkbox groups are within an array.
To address a specific checkbox use a similar statement as below. Replace 'field_checkbox_opt_1' with the option name you used in the Fields Manager. The example below shows the option value as entered in the Fields Manager if the checkbox is checked and it shows "not selected" if the checkbox isn't checked.

<?php
if (isset($fieldsObjects['field_mylist']->data['field_checkbox_opt_1']))
  echo $fieldsObjects['field_mylist']->data['field_checkbox_opt_1'];
else
  echo "not selected";
?>

To get all checked items of a checkbox group, use statements like these:

<?php
foreach ($fieldsObjects['field_mylist']->data as $name => $value) {
  echo $value;
  echo "<br/>";
}
?>

Another method to output all checked items of a checkbox group separated by a sign (e.g. a comma).

<?php
$separator = ", ";
echo (isset($fieldsObjects['field_mylist']->data) &&
  is_array($fieldsObjects['field_mylist']->data)) ?
  implode($separator, $fieldsObjects['field_mylist']->data) : null
?>

Field labels  | link | 

The label of the fields can be accessed separately by using a statements like the one below. To show the label add an echo.

<?php $fieldsObjects['field_street']->label; ?>
<?php echo $fieldsObjects['field_street']->label; ?>

Example of using raw data  | link | 

This example shows how the real URL of a website will be shown instead of the label "Website". Don't forget to insert the CSS class information.
This example is for the V-Card template. For the Details View template use span id="sobi2Details_field_website".

<span class="sobi2Listing_field_website">
<a href="<?php echo $fieldsObjects['field_website']->data; ?>" target="_blank">
<?php echo $fieldsObjects['field_website']->data; ?>
</a>
</span>
<br />

Linking to Details View (V-Card only)  | link | 

If you want to insert a (second) link to the corresponding details view of the entry, make a link as stated below.

<?php
$catid = (int) sobi2Config::request($_REQUEST, 'catid', 0);
$config =& sobi2Config::getInstance();
$link = sobi2Config::sef("index.php?option=com_sobi2&sobi2Task=sobi2Details&
    catid={$catid}&sobi2Id={$id}&Itemid={$config->sobi2Itemid}");
?>
<a href="<?php echo $link ?>">read more...</a>

Quick edit for raw values (Details View only)  | link | 

By default the Quick Edit function works only for formatted fields. If you need to use the Quick Edit function for raw values you have to use a statement like the one below.

<?php echo HTML_SOBI::toQuickEdit($fieldsObjects['field_street'], $mySobi); ?>

Notice:

  • this function should be called for every field only once.
  • this function works only in details view template
  • the returned value of this function contains not longer only raw data. The raw data is then within a span tag

Other entry related raw data  | link | 

The $mySobi object has the following attributes

$title - Title of the entry (company name)
$hits - Number of hits of the entry
$publish_up - Date of publishing
$publish_down - Date of expiration
$owner - ID of the owner of the entry
$image - File name of the image file
$icon - File name of the icon file
$ip - IP of the user who made the entry
$lastUpdate - Date of last update
$updatingUser - ID of the user who updated the entry the last time
$updatingIp - IP of the user who updated the entry the last time
$myCategories - two dimensional array with all selected categories for this entry
         (catid => catname)
$metakey - Meta keys
$metadesc - Meta description
$background - File name of the background image

Use these data in the following ways:

To show the data:

<?php echo $mySobi->hits; ?>

To use the data:

<?php
if ($mySobi->hits > 1000)
   echo "a lot of hits";
else
   echo "only a few hits";
?>

Inserting Plugin Code | link | 


To insert a plugin code in the Details View or V-Card use a statement like the below one. Replace reviews with the name of the plugin you use.
In the V-Card, normally this will insert a counter for the plugin (Reviews, Gallery and Media plugin). In the Details View, normally the complete functionality of the plugin will be inserted.

HTML skills are necessary!

<?php echo $plugins['reviews']; ?>

Digg!Del.icio.us!Google!Facebook!Slashdot!Netscape!Technorati!Yahoo!Ma.gnolia!