Below is the code to paste into where you want the list to show up. Firstly you'll need to configure one line according to where your script is located relative to Interspire Website Publisher. If it sin the same directory, the default will work:
include_once('init.php');
If Interspire Website Publisher is in a subfolder, e.g. /websitepublisher/ then use this:
include_once('websitepublisher/init.php');
Configure that in the code below:
<?php
include_once('init.php'); // this connects us to the database
$NumArticles = 5;
$query = sprintf("select *, unix_timestamp(StartDate) as SD from %sarticles as art
inner join %susers as u on art.AuthorID = u.UserID
left join %scategoryassociations as ca on art.ArticleID = ca.ArticleID
inner join %scategories as c on ca.CategoryID = c.CategoryID
where art.Featured=0 and art.Visible=1 and art.Status=1 and
unix_timestamp(art.StartDate) <= %s and
art.IsFinished=1 and
(unix_timestamp(art.ExpiryDate) >= %s or art.EnableExpiry=0)
group by art.ArticleID
order by art.StartDate DESC, art.ArticleID DESC
limit %d
", $GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"],$GLOBALS["AL_CFG"]["tablePrefix"], $GLOBALS["AL_CFG"]["tablePrefix"], time(), time(),$NumArticles);
$articleResult = mysql_query($query);
while($articleRow = mysql_fetch_array($articleResult))
{
$articleurl = AL_HELPER::ArticleLink($articleRow['ArticleID'],$articleRow['Title']);
$articledate = AL_HELPER::GetRelativeDate($articleRow["SD"]);
echo <<< ENDHTML
<a href="{$articleurl}">{$articleRow['Title']}</a> - by {$articleRow['FirstName']} {$articleRow['LastName']}<br/>
ENDHTML;
}
?>This outputs a basic list. You can change the html if you want. Just change the code between
echo <<< ENDHTML
and
ENDHTML;
Make sure that no spaces are in front of the ENDHTML; on the same line. It could cause issues. You'll notice in the HTML are variables you can use like:
{$articleRow['LastName']}The curly braces won't show up, they just show where the variable starts and ends.
Here is a quick list of the ones you can use:
{$articleRow['Summary']} - Article summary
{$articleRow['StartDate']} - Date of the article in format YYYY-MM-YY
{$articleRow['Title']} - This is the Article Title
{$articleRow['FirstName']} - Author first name
{$articleRow['LastName']} - Author last name
{$articleRow['Name']} - First category nameThere is code there so you can also use these:
{$articleurl} - The Link URL to the article
{$articledate} - Date of the article formatted to MM/DD/YYYYThere is also this line near the top to control the maximum number of articles to display:
$NumArticles = 5;
Please note thought, we don't perform customizations. This code was provided as it essentially already exists in Interspire Website Publisher, it just had to be copied out and trimmed down a bit.
