Second example:
<?php
$query1 = "SELECT id, name, module FROM $table_pages WHERE section='$section' AND invisible != 'yes' ORDER BY sort";
$result1 = mysql_query($query1);
while ($sectionmenu = mysql_fetch_array($result1))
{
if(substr($sectionmenu[2],0,5) == "http:")
{
print "<tr>
<td width=\"162\" background=\"starnet/themes/standard/menu-button.gif\" height=\"21\"
onMouseOver=\"this.background='starnet/themes/standard/menu-button1.gif';\" onMouseOut=\"this.background='starnet/themes/standard/menu-button.gif';\">
<a href=$sectionmenu[2] style=\"text-decoration:none; font-family:verdana; font-size:10pt; color:white\">$sectionmenu[1]</a>
</td></tr><tr><td height=\"6\"></td></tr>";
}
else
{
print "<tr>
<td width=\"162\" background=\"starnet/themes/standard/menu-button.gif\" height=\"21\"
onMouseOver=\"this.background='starnet/themes/standard/menu-button1.gif';\"
onMouseOut=\"this.background='starnet/themes/standard/menu-button.gif';\">
<a href=index.php?page=$sectionmenu[0]§ion=$section style=\"text-decoration:none; font-family:verdana; font-size:10pt; color:white\">$sectionmenu[1]</a>
</td></tr><tr><td height=\"6\"></td></tr>";
}
}
?>
|
This second example makes it possible to create a menu item with a link inside or outside the CMS.
For this purpose we use the module field when creating a page:
![[ ]](pics/template_outside_link.png)
template_outside_link.png
Instead of specifying a module name we give a valid http address. The PHP code in the template checks for http: (lowercase) and if it finds it, it will create a menu link with this http address.
The target="_blank" is used to open the requested link in a new browser window.
This creates the menu items for the pages of a section:
![[ ]](pics/template_pages.png)
template_pages.png
<?php
$query1 = "SELECT id, name FROM $table_pages WHERE section='$section' AND invisible != 'yes' ORDER BY sort";
$result1 = mysql_query($query1);
while ($sectionmenu = mysql_fetch_array($result1))
{
if($sectionmenu[0] == $page)
{
print "<tr height=\"25\"><td width=\"20%\" align=\"right\"><img border=\"0\" src=\"starnet/themes/standard/nblt.gif\" width=\"6\" height=\"12\"></td>";
print "<td width=\"80%\" background=\"starnet/themes/standard/menu-bg2.gif\"><font size=\"2\">";
print "$sectionmenu[1]</font></td></tr>";
}
else
{
print "<tr height=\"25\"><td width=\"20%\" align=\"right\"><img border=\"0\" src=\"starnet/themes/standard/nblt.gif\" width=\"6\" height=\"12\"></td>";
print "<td width=\"80%\" onMouseOver=\"this.background='starnet/themes/starnet/menu-bg2.gif'\" onMouseOut=\"this.background=''\"><font size=\"2\">";
print "<a href=index.php?page=$sectionmenu[0]§ion=$section>$sectionmenu[1]</a></font></td></tr>";
}
}
?>
|
This example assumes that the menu bar is part of a table, the other HTML is left out to keep the example simple.
The nblt.gif(little arrow) is a small gif, which is located in the standard theme directory.
This will create the important part, the real contents of a page:
![[ ]](pics/template_content.png)
template_content.png
<?php
$query = "SELECT module FROM $table_pages WHERE id='$page'";
$result = mysql_query($query);
$module = mysql_result($result,0);
unset($query);
unset($result);
if($module != '')
{
print "<table border=\"0\" cellpadding=\"10\" cellspacing=\"0\" width=\"100%\"><tr><td width=\"100%\">";
include("starnet/modules/$module");
print "</td></tr></table>";
}
else
{
$query = "SELECT content FROM $table_pages WHERE id='$page'";
$result = mysql_query($query);
$content = mysql_result($result,0);
unset($query);
unset($result);
$content = str_replace("../","",$content);
print "<font class=\"text\" size=\"2\">$content</font>";
}
?>
|
The first part checks to see if an installed module is called (e.g. guestbook or mail page).
If this is not the case a normal HTML content is read FROM the MySQL table.
This example creates a logoff link.
<?php
if(IsSet($_SESSION['userid']))
{
print "<a href=index.php?section=$section&page=$page&logout=yes>logoff</a>";
}
?>
|
This example creates a public site link which can be used to return to the public site
from the protected site, without being logged off.
(only possible with S@S 2.4!)
<?php
if($_SESSION['site'] == "protected")
{
print "<a href=\"index.php?section=$_SESSION[section_came_from]&page=$_SESSION[page_came_from]&site=public\">".$sas_lang['public_area']." /</a>";
}
?>
|
This example takes the title of the last created news item and shows a link:

template_last_news.png
<?php
$newstable = $dbprefix."m_news_articles" ;
if($_SESSION['site'] == "protected")
{
$query = "SELECT title,date FROM $newstable WHERE public = 1 AND archive = 0 ORDER BY id DESC LIMIT 1";
}
else
{
$query = "SELECT title,date FROM $newstable WHERE public = 0 AND archive = 0 ORDER BY id DESC LIMIT 1";
}
$result = mysql_query($query) or die_script($query,mysql_error());
if(mysql_num_rows($result) > 0)
{
$newstitle = mysql_result($result,0);
print "<a class=\"mainmenu\" href=\"index.php?section=xx&page=yy\">Latest news: <b>$newstitle<b>$newstitle</b></a>" ;
}
?>
|
Where 'xx' is the page number and 'yy' is the page number where your news page is on the site.
When a page is added or changed, S@S will store the date of this action into the database.
Use the following to show it on the bottom of the page, e.g.:
<?php
$query = "SELECT config_value FROM $table_configuration WHERE config_key='last_update_date'";
$result = mysql_query($query);
$date1 = mysql_result($result,0);
unset($query);
unset($result);
print "site last updated on : $date1" ;
?>
|
Site@School also stores the last update date per page, you can use the code below to display a "page last changes on yyyy-mm-dd" text.
<?php
$query = "SELECT unix_timestamp(lastupdate) FROM $table_pages WHERE id='$page'";
$result = mysql_query($query);
$date = mysql_result($result,0);
unset($query);
unset($result);
$query = "SELECT config_value FROM $table_configuration WHERE config_key='dateformat'";
$result = mysql_query($query);
$date_format = mysql_result($result,0);
unset($query);
unset($result);
$date = strftime($date_format,$date);
print "© $sitename , page last changed on $date ";
?>
this will give : "© sitename , page last changed on 01-09-2003"
|
The category template uses the category field to create an extra menu level in the pop-up menu on the left side of the screen.
When you fill in the category field it is possible to create the a pop-up menu like this:
![[ ]](pics/template_popupmenu.png)
template_popupmenu.png
(top)
Author: Dirk Schouten <schoutdi (at) knoware (dot) nl>
Last updated: 2006-04-21