It appears that you're running an Ad-Blocker. This site is monetized by Advertising and by User Donations; we ask that if you find this site helpful that you whitelist us in your Ad-Blocker, or make a Donation to help aid in operating costs.

Custom Islands · Wiki

What Is Covered

Summary
Creating a Custom Island
Editing a Custom Island
Default Code
Examples
     • Example 1: Using PHP and HTML
     • Example 2: Site Links Navigation Menu
     • Example 3: Image with Embedded Link
     • Example 4: Upcoming Events (MySQL Query)
     • Example 5: Detect Login
     • Example 6: Random Image


 

Summary


Within UBB.threads exists a feature called "Custom Islands" and they're a great method of displaying content that doesn't necessarily relate to the forum software itself. You can:
• Create unlimited Islands.
• Use them in your portal page as well as your main forum as side islands.
• Use them externally on a non ubb page or add them to your header or footer.
• Use them as a custom island insert between the first and second post in a forum.
• Add php code and or html code on each one.

Some people experience difficulties in creating Custom Islands however once you understand the system it is relatively simple. For this article we will deal only with creating a custom island, not using it with the features mentioned above.


 

Creating a Custom Island


To get started in creating a Custom Island is to open the Control Panel within UBB.threads and navigate to the "Custom Islands" link in the Portal settings section. From here either select the "Edit" link (to the right of an existing Custom Island) or create one with the "Add Additional Custom Island" tab at the bottom of this page.


 

Editing a Custom Island


On this page you'll see several fields that you can edit:

Name - This appears as the header for the Custom Island's Portal Box. Your entry here will appear as the header for that island.
Cache Time - In Minutes. If zero is specified, the body of this custom box will be static, ie. never updated. This setting would be used for things like links, banner ads, etc. If you enter 1 minute then the island would be rebuilt every minute.
Always Build - With this option checked, this island will always be built even if it's not used in your portal. This would allow you to use the island elsewhere on your site, such as a page that doesn't get built through UBB.threads. You an also use it in your UBB.threads "HTML Includes" or enter the text within a template.
Body - This field contains the PHP code or HTML for the custom box. $body contains the actual content that should be printed in the custom box.

Most people experience difficulties with the creation of their Custom Islands with the Body[b] section. Below we list the defaults so you can easily restore the island to what came with the stock UBB.threads install.

There are two sections within [b]Body
, an area for PHP and a separate area for HTML. You will need to keep these sections separate, and you must enter your HTML between the EOF lines (otherwise you'll be presented with an error versus working code). If you're attempting to insert 3rd party code, it may have to be separated to work with the Custom Island formatting.

Note
Do not delete any of the default code when editing the Island.



 

Default Code


Code
/* PHP CODE HERE, IF NECESSARY */

/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF
EOF;
/* DO NOT CHANGE THE LINE ABOVE */



 

Examples


We have prepared several examples of what you can do with the Custom Islands system within UBB.threads.

 

Example 1: Using PHP and HTML


For this example it will display "My 2 + 2 math equals 4" in the Island. Even though it is a simple math statement, it shows how to break up your php script to display the results in the html section of the island.

Code
/* PHP CODE HERE, IF NECESSARY */
$mymath = 2 + 2;

/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF

My 2 + 2 math equals $mymath

EOF;
/* DO NOT CHANGE THE LINE ABOVE */



 

Example 2: Site Links Navigation Menu


For this example we will use the Site Links menu at UBBCentral.

Code
/* PHP CODE HERE, IF NECESSARY */

/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF

<a href="https://ubbcentral.com">Home</a><br />
<a href="https://ubbcentral.com/features.php">Features</a><br />
<a href="https://ubbcentral.com/docs.php">Documentation</a><br />
<a href="https://ubbcentral.com/purchase.php">Pricing & Order</a><br />
<a href="http://www.infopop.com/members/members.php">Members Area</a>

EOF;
/* DO NOT CHANGE THE LINE ABOVE */



 

Example 3: Image with Embedded Link


For this example we will use Mindraven's static ad.

Note
aff=015 is the affiliate number so change accordingly to your number. Unless you want to give me credit on all the clicks from your site.


Code
/* PHP CODE HERE, IF NECESSARY */

/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF

<a href="http://www.mindraven.com/hosting/aff.php?aff=015">
<img src="http://www.mindraven.com/banners/mindraven_125_125.gif" width="200" height="125" border="5" />
</a>

EOF;
/* DO NOT CHANGE THE LINE ABOVE */



 

Example 4: Upcoming Events (MySQL Query)


This example will show how to use a MySQL query extracting data from the calendar and display the results in the Island. Sirdude created this and a special thank you to him for its creation. To view the complete article visit Upcoming events Custom Island.

Code
/* PHP CODE HERE, IF NECESSARY */
# Change the next parameter to the maximum future events you want
$maxEvents = 10;
# Change to whichever column this Custom Island will be shown (for CSS)
$portalCol = 'left';

# -- Nothing changes below, unless you are non-n00bers ;)
$intTime = time();
$dateParts = getdate($intTime);
$dtYr = $dateParts['year'];

$q = "
SELECT ce.CALENDAR_EVENT_SUBJECT, ce.TOPIC_ID, t.POST_ID,
ce.CALENDAR_EVENT_DAY, ce.CALENDAR_EVENT_MONTH,
ce.CALENDAR_EVENT_YEAR, ce.CALENDAR_EVENT_BODY
FROM {$config['TABLE_PREFIX']}CALENDAR_EVENTS ce, {$config['TABLE_PREFIX']}TOPICS t
WHERE ce.CALENDAR_EVENT_TYPE='public'
AND ce.CALENDAR_EVENT_RECURRING = 'never'
AND ce.CALENDAR_EVENT_YEAR >= $dtYr
AND ce.TOPIC_ID=t.TOPIC_ID
";
$r = $dbh->do_query($q);
$ceList = array();
while (list($ceSubject, $topicID, $postID, $ceDay, $ceMon, $ceYr) = $dbh->fetch_array($r)) {
$ceTime = mktime(0,0,0,$ceMon,$ceDay,$ceYr);
if ($ceTime >= $intTime) {
$ceList[$ceTime]['Subject'] = $ceSubject;
$ceList[$ceTime]['postID'] = $postID;
}
}

# Create the list
$i=0;
sort($ceList);
foreach ($ceList as $ce) {
$cssExt = ($i++&1) ? '2' : '1';
$cssClass = 'class="' . $portalCol . 'alt-' . $cssExt .'"';
if ($i [h2] 1) {
$htmlList .= "<a href="{$config['FULL_URL']}/ubbthreads.php?ubb=showflat&Number={$ce['postID']}">{$ce['Subject']}</a>";
} else {
$htmlList .= "</td></tr><tr><td $cssClass>";
$htmlList .= "<a href="{$config['FULL_URL']}/ubbthreads.php?ubb=showflat&Number={$ce['postID']}">{$ce['Subject']}</a>";
}
}

/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF

$htmlList

EOF;
/* DO NOT CHANGE THE LINE ABOVE */



 

Example 5: Detect Login


This example will show how to make an island display something different after a person has logged in. In the example below, it tells the person that they have successfully logged in. Prior to that, it contained a link on how to get their Password sent to them.

Code
/* PHP CODE HERE, IF NECESSARY */

/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF

<?php
if ($user['USER_DISPLAY_NAME']) {
echo <<<STUFF
You ARE logged in.
STUFF;
} else {
echo <<<STUFF
Please login to post or reply.
STUFF;
echo '* * *<br/><a target="_blank" href="http://www.example.com/forum/ubbthreads.php?ubb=login&lostpw=1">
<font color="#FF0000">Send My Password</font></a>';

}?>

EOF;
/* DO NOT CHANGE THE LINE ABOVE */



 

Example 6: Random Image


Here's a quick little "random image" custom island that can be used/modified. Just displays a single random image that links to the the actual gallery post: Created by Rick Baker.

Code
/* PHP CODE HERE */
$query = "
select POST_ID,FILE_DIR,FILE_NAME
from ubbt_FILES
where FILE_DIR <> ''
order by rand() limit 1
";
$sth = $dbh->do_query($query,__LINE__,__FILE__);
list($postId,$fDir,$fName) = $dbh->fetch_array($sth);
/* BODY HERE */
$body = <<<EOF
<div style='text-align: center'>
<a href="{$config['BASE_URL']}/ubbthreads.php?ubb=showgallery&Number=$postId">
<img border="0" src="{$config['BASE_URL']}/gallery/$fDir/thumbs/$fName" />
</a>
</div>
EOF;

Posted By Gremelin Posted on October 4th, 2014 · Updated on October 6th, 2015
▼ Sponsored Links ▼
▲ Sponsored Links ▲

Comments

( Posted)