If I add a font size to the block then the php code fails - is there a way to do this?
Cant help you unless we see the code.
Here's the code, which displays a list of recent articles. It currently displays too large.
global $db_prefix, $scripturl, $user_info;
$query = db_query(
"SELECT subject, id, date, shortname
FROM {$db_prefix}tp_articles
WHERE approved = 1
ORDER BY date DESC
LIMIT 10", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($query))
{
if(empty($row['shortname'])) $row['shortname'] = $row['id'];
echo '<a href="' . $scripturl . '?page=' . $row['shortname'] . '">' . $row['subject'] . '</a> ' . timeformat($row['date'], $user_info['time_format']) . '<br />';
}
I don't see anything wrong with that code. How were you changing the font?
echo '<font size="12pt"><a href="' . $scripturl . '?page=' . $row['shortname'] . '">' . $row['subject'] . '</a></font> ' . timeformat($row['date'], $user_info['time_format']) . '<br />';
This should work for changing the title to a font sizee of 12pt.
Slight variation to IchBin's suggestion- just to use the CSS in the theme...
global $db_prefix, $scripturl, $user_info;
$query = db_query(
"SELECT subject, id, date, shortname
FROM {$db_prefix}tp_articles
WHERE approved = 1
ORDER BY date DESC
LIMIT 10", __FILE__, __LINE__);
echo '<div class="smalltext">';
while ($row = mysql_fetch_assoc($query))
{
if(empty($row['shortname'])) $row['shortname'] = $row['id'];
echo '<a href="' . $scripturl . '?page=' . $row['shortname'] . '">' . $row['subject'] . '</a> ' . timeformat($row['date'], $user_info['time_format']) . '<br />';
}
echo '</div>';
Thanks guys - what I'm trying to do is match the font (which appears to be bold) with the standard block font and size. Ideally I'd also like the date for each to follow on the line beneath the title.
OK, I'm figuring this out for myself now - is there any way to abbreviate the month to the first three letters?
Also, the time format could do with losing the last three digits (:00)
And the numerical day of the month first if possible ;)
The date is returned as a Unix timestamp, so you use that to extrapolate a variety of chronological info.
Look at the date function (http://www.php.net/manual/en/function.date.php) and format it through that function:
echo '<a href="' . $scripturl . '?page=' . $row['shortname'] . '">' . $row['subject'] . '</a> (' . date("M n, Y - g:ia", $row['date']) . ')<br />';
Fabulous, many thanks ;)
Solved then :up:
Indeed, looking good.