SimplePortal
Customization => Blocks and Modifications => Block Requests => Topic started by: Sim on February 27, 2011, 08:47:04 PM
-
Display latest 5 blocks from ADK Blog
global $smcFunc, $scripturl;
echo'Recent Links:<br />';
$dbresult = $smcFunc['db_query']('', '
SELECT id_comment , id_member, subject
FROM {db_prefix}blog_comments
ORDER BY id_comment DESC
LIMIT 5');
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
echo'<a href="'.$scripturl.'index.php?blog='.$row['id_member'].';sa=topic;id='.$row['id_comment'].'">'.$row['subject'].'</a><br />';
}
$smcFunc['db_free_result']($dbresult);
-
URL Fix
global $smcFunc, $scripturl;
$dbresult = $smcFunc['db_query']('', '
SELECT id_comment , id_member, subject
FROM {db_prefix}blog_comments
ORDER BY id_comment DESC
LIMIT 5');
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
{
echo'<a href="'.$scripturl.'?blog='.$row['id_member'].';sa=topic;id='.$row['id_comment'].'">'.$row['subject'].'</a><br />';
}
$smcFunc['db_free_result']($dbresult);
-
Sim
Hope ya still around somewhere.
What would I have to add so the owner and date of the blog show?
-
:nervous-happy:
<?php
global $smcFunc, $context, $scripturl, $modSettings, $txt, $settings;
$limit = 10;
$sql = $smcFunc['db_query']('','
SELECT co.id_initial, co.subject, co.body, co.time, co.id_cat, co.icon, co.id_member, ca.id_cat, ca.title,
mem.avatar, mem.real_name, mem.id_member,
IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type
FROM {db_prefix}blog_comments AS co, {db_prefix}blog_categories AS ca, {db_prefix}members AS mem
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE co.is_started = {int:s} AND co.id_cat = ca.id_cat AND mem.id_member = co.id_member
ORDER BY co.id_initial DESC
LIMIT {int:limit}',
array(
'limit' => $limit,
's' => 1,
)
);
$context['info'] = array();
$width = 50;
$height = 65;
while($row = $smcFunc['db_fetch_assoc']($sql))
{
$image = '<img src="'.$settings['images_url'].'/post/'.$row['icon'].'.gif" alt="" /> ';
$context['info'][] = array(
'id' => $row['id_initial'],
'id_member' => $row['id_member'],
'member' => '<a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'">'.$row['real_name'].'</a>',
'avatar' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img width="'.$width.'" height="'.$height.'" src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img width="'.$width.'" height="'.$height.'"src="' . $row['avatar'] . '" alt="" class="avatar" border="0" />' : '<img width="'.$width.'" height="'.$height.'"src="' . $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'subject' => $row['subject'],
'time' => timeformat($row['time']),
'id_cat' => $row['id_cat'],
'title' => $row['title'],
'icon' => !empty($row['icon']) ? $image : '',
'cat' => '<a href="'.$scripturl.'?blog='.$context['blog']['id_user'].';sa=cat;id='.$row['id_cat'].'">'.$row['title'].'</a>',
);
}
echo'
<table style="width: 100%;">';
foreach($context['info'] AS $post)
{
echo'
<tr>
<td style="width: 60px;">
'.$post['avatar'].'
</td>
<td>
<div class="smalltext">
'.$post['icon'].'<a href="'.$scripturl.'?blog='.$post['id_member'].';sa=topic;id='.$post['id'].'" style="font-weight: bold;">'.$post['subject'].'</a> '.$txt['by'].' '.$post['member'].' '.$txt['on'].' '.$post['time'].'
</div>
</td>
</tr>';
}
echo'
</table>';
?>
-
Can you make so the avatars have their width and height proportions ?
Because right now is square.
Thank you very very much.
-
Like this?
<?php
global $smcFunc, $context, $scripturl, $modSettings, $txt, $settings;
$limit = 10;
$sql = $smcFunc['db_query']('','
SELECT co.id_initial, co.subject, co.body, co.time, co.id_cat, co.icon, co.id_member, ca.id_cat, ca.title,
mem.avatar, mem.real_name, mem.id_member,
IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type
FROM {db_prefix}blog_comments AS co, {db_prefix}blog_categories AS ca, {db_prefix}members AS mem
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE co.is_started = {int:s} AND co.id_cat = ca.id_cat AND mem.id_member = co.id_member
ORDER BY co.id_initial DESC
LIMIT {int:limit}',
array(
'limit' => $limit,
's' => 1,
)
);
$context['info'] = array();
$width = 50;
while($row = $smcFunc['db_fetch_assoc']($sql))
{
$image = '<img src="'.$settings['images_url'].'/post/'.$row['icon'].'.gif" alt="" /> ';
$context['info'][] = array(
'id' => $row['id_initial'],
'id_member' => $row['id_member'],
'member' => '<a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'">'.$row['real_name'].'</a>',
'avatar' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img width="'.$width.'" src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img width="'.$width.'" src="' . $row['avatar'] . '" alt="" class="avatar" border="0" />' : '<img width="'.$width.'" src="' . $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'subject' => $row['subject'],
'time' => timeformat($row['time']),
'id_cat' => $row['id_cat'],
'title' => $row['title'],
'icon' => !empty($row['icon']) ? $image : '',
'cat' => '<a href="'.$scripturl.'?blog='.$context['blog']['id_user'].';sa=cat;id='.$row['id_cat'].'">'.$row['title'].'</a>',
);
}
echo'
<table style="width: 100%;">';
foreach($context['info'] AS $post)
{
echo'
<tr>
<td style="width: 60px;">
'.$post['avatar'].'
</td>
<td>
<div class="smalltext">
'.$post['icon'].'<a href="'.$scripturl.'?blog='.$post['id_member'].';sa=topic;id='.$post['id'].'" style="font-weight: bold;">'.$post['subject'].'</a> '.$txt['by'].' '.$post['member'].' '.$txt['on'].' '.$post['time'].'
</div>
</td>
</tr>';
}
echo'
</table>';
?>
-
Yes :)
This is great.
Thank you very very much for your help.
-
Ehmmmm
I am getting this error now in my error log...
8: Undefined index: blog
File: /home/vinilio/public_html/Themes/default/languages/Stats.greek-utf8.php (portal_above sub template - eval?)
Line: 40
-
Try this:
<?php
error_reporting(E_ALL ^ E_NOTICE);
global $smcFunc, $context, $scripturl, $modSettings, $txt, $settings;
$limit = 10;
$sql = $smcFunc['db_query']('','
SELECT co.id_initial, co.subject, co.body, co.time, co.id_cat, co.icon, co.id_member, ca.id_cat, ca.title,
mem.avatar, mem.real_name, mem.id_member,
IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type
FROM {db_prefix}blog_comments AS co, {db_prefix}blog_categories AS ca, {db_prefix}members AS mem
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE co.is_started = {int:s} AND co.id_cat = ca.id_cat AND mem.id_member = co.id_member
ORDER BY co.id_initial DESC
LIMIT {int:limit}',
array(
'limit' => $limit,
's' => 1,
)
);
$context['info'] = array();
$width = 50;
while($row = $smcFunc['db_fetch_assoc']($sql))
{
$image = '<img src="'.$settings['images_url'].'/post/'.$row['icon'].'.gif" alt="" /> ';
$context['info'][] = array(
'id' => $row['id_initial'],
'id_member' => $row['id_member'],
'member' => '<a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'">'.$row['real_name'].'</a>',
'avatar' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img width="'.$width.'" src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img width="'.$width.'" src="' . $row['avatar'] . '" alt="" class="avatar" border="0" />' : '<img width="'.$width.'" src="' . $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'subject' => $row['subject'],
'time' => timeformat($row['time']),
'id_cat' => $row['id_cat'],
'title' => $row['title'],
'icon' => !empty($row['icon']) ? $image : '',
'cat' => '<a href="'.$scripturl.'?blog='.$context['blog']['id_user'].';sa=cat;id='.$row['id_cat'].'">'.$row['title'].'</a>',
);
}
echo'
<table style="width: 100%;">';
foreach($context['info'] AS $post)
{
echo'
<tr>
<td style="width: 60px;">
'.$post['avatar'].'
</td>
<td>
<div class="smalltext">
'.$post['icon'].'<a href="'.$scripturl.'?blog='.$post['id_member'].';sa=topic;id='.$post['id'].'" style="font-weight: bold;">'.$post['subject'].'</a> '.$txt['by'].' '.$post['member'].' '.$txt['on'].' '.$post['time'].'
</div>
</td>
</tr>';
}
echo'
</table>';
?>
-
8: Undefined index: blog
File: /home/vinilio/public_html/Themes/default/languages/SearchFocus.greek-utf8.php (portal_above sub template - eval?)
Line: 41
:(
-
It works on mine :(
Those are notice errors. No big deal but I understand that you want them removed. I added a code to remove notice errors like the ones you are having and it works fine in my test forum. Are you sure the errors are from this block?
Let's try this, then... Last hope:
<?php
error_reporting(0);
global $smcFunc, $context, $scripturl, $modSettings, $txt, $settings;
$limit = 10;
$sql = $smcFunc['db_query']('','
SELECT co.id_initial, co.subject, co.body, co.time, co.id_cat, co.icon, co.id_member, ca.id_cat, ca.title,
mem.avatar, mem.real_name, mem.id_member,
IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type
FROM {db_prefix}blog_comments AS co, {db_prefix}blog_categories AS ca, {db_prefix}members AS mem
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE co.is_started = {int:s} AND co.id_cat = ca.id_cat AND mem.id_member = co.id_member
ORDER BY co.id_initial DESC
LIMIT {int:limit}',
array(
'limit' => $limit,
's' => 1,
)
);
$context['info'] = array();
$width = 50;
while($row = $smcFunc['db_fetch_assoc']($sql))
{
$image = '<img src="'.$settings['images_url'].'/post/'.$row['icon'].'.gif" alt="" /> ';
$context['info'][] = array(
'id' => $row['id_initial'],
'id_member' => $row['id_member'],
'member' => '<a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'">'.$row['real_name'].'</a>',
'avatar' => $row['avatar'] == '' ? ($row['id_attach'] > 0 ? '<img width="'.$width.'" src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img width="'.$width.'" src="' . $row['avatar'] . '" alt="" class="avatar" border="0" />' : '<img width="'.$width.'" src="' . $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'subject' => $row['subject'],
'time' => timeformat($row['time']),
'id_cat' => $row['id_cat'],
'title' => $row['title'],
'icon' => !empty($row['icon']) ? $image : '',
'cat' => '<a href="'.$scripturl.'?blog='.$context['blog']['id_user'].';sa=cat;id='.$row['id_cat'].'">'.$row['title'].'</a>',
);
}
echo'
<table style="width: 100%;">';
foreach($context['info'] AS $post)
{
echo'
<tr>
<td style="width: 60px;">
'.$post['avatar'].'
</td>
<td>
<div class="smalltext">
'.$post['icon'].'<a href="'.$scripturl.'?blog='.$post['id_member'].';sa=topic;id='.$post['id'].'" style="font-weight: bold;">'.$post['subject'].'</a> '.$txt['by'].' '.$post['member'].' '.$txt['on'].' '.$post['time'].'
</div>
</td>
</tr>';
}
echo'
</table>';
?>
-
I think is ok now...
I dont get any blog related errors.
Thank you very very much :)
-
Blue
My portal block also had errors.
As a challenge hows about a scrolling block?
>:-D
-
My portal block also had errors.
If they are only Notice Errors you can add this line to the top of your block code:
error_reporting(E_ALL ^ E_NOTICE);
If the error continue to show you can disable all error reporting with this code:
error_reporting(0);
As a challenge hows about a scrolling block?
Oh my god! I hate javascript and all latest requests want to use it! Arrrrrgggg :P ;D
One challenge a time, first I need to finish Advance Who's Online Block :P
After that, who knows ;)
-
Hailsa,
How would one go about getting this to show less than 5..like 1 or 2..??
Thanks,
-Lyfing
-
So,
I've new with coding.
This code works for me except it does not connect to the DB. I know i've to change something but I don't know what. Could you guys help me? =)
-
So,
I've new with coding.
This code works for me except it does not connect to the DB. I know i've to change something but I don't know what. Could you guys help me? =)
PHP validation off/on/off and it worked. go figure :P
-
Where can this blog mod be downloaded?
-
You can try using the codes provided in the following posts with a Custom PHP block:
http://simpleportal.net/index.php?topic=7950.msg48749#msg48749
http://simpleportal.net/index.php?topic=7950.msg43876#msg43876
-
These links links to blocks??? Where can I download the blog?
-
Yeah, those are only block codes for SimplePortal. I guess you can download the mod itself at simplemachines.org Mod Site or maybe those guys have their own site where they serve their mods.
-
Ok, thanks!