SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: Sim on February 27, 2011, 08:47:04 PM

Title: ADK Blog Block
Post by: Sim on February 27, 2011, 08:47:04 PM
Display latest 5 blocks from ADK Blog

Code: [Select]
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);
Title: Re: ADK Blog Block
Post by: Sim on February 27, 2011, 09:00:19 PM
URL Fix

Code: [Select]
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);
Title: Re: ADK Blog Block
Post by: Old Fossil on May 31, 2011, 11:05:53 AM
Sim

Hope ya still around somewhere.

What would I have to add so the owner and date of the blog show?
Title: Re: ADK Blog Block
Post by: NaYmCo on July 16, 2011, 03:30:16 PM
 :nervous-happy:

Code: [Select]
<?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="" />&nbsp;';

$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'] > '<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>'
;

?>
Title: Re: ADK Blog Block
Post by: Yngwiedis on July 20, 2011, 09:15:14 AM
Can you make so the avatars have their width and height proportions ?
Because right now is square.

Thank you very very much.
Title: Re: ADK Blog Block
Post by: Blue on July 20, 2011, 10:15:45 AM
Like this?

Code: [Select]
<?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="" />&nbsp;';

$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'] > '<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>'
;

?>
Title: Re: ADK Blog Block
Post by: Yngwiedis on July 20, 2011, 10:28:43 AM
Yes :)

This is great.

Thank you very very much for your help.
Title: Re: ADK Blog Block
Post by: Yngwiedis on July 20, 2011, 10:35:48 AM
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
Title: Re: ADK Blog Block
Post by: Blue on July 20, 2011, 03:11:17 PM
Try this:

Code: [Select]
<?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="" />&nbsp;';

$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'] > '<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>'
;

?>
Title: Re: ADK Blog Block
Post by: Yngwiedis on July 21, 2011, 10:40:19 AM
8: Undefined index: blog
File: /home/vinilio/public_html/Themes/default/languages/SearchFocus.greek-utf8.php (portal_above sub template - eval?)
Line: 41


:(
Title: Re: ADK Blog Block
Post by: Blue on July 21, 2011, 11:56:44 AM
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:
Code: [Select]
<?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="" />&nbsp;';

$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'] > '<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>'
;

?>
Title: Re: ADK Blog Block
Post by: Yngwiedis on July 21, 2011, 12:09:51 PM
I think is ok now...
I dont get any blog related errors.

Thank you very very much :)
Title: Re: ADK Blog Block
Post by: Old Fossil on July 21, 2011, 02:15:37 PM
Blue

My portal block also had errors.

As a challenge hows about a scrolling block?

 >:-D
Title: Re: ADK Blog Block
Post by: Blue on July 21, 2011, 02:43:36 PM

My portal block also had errors.

If they are only Notice Errors you can add this line to the top of your block code:
Code: [Select]
error_reporting(E_ALL ^ E_NOTICE);
If the error continue to show you can disable all error reporting with this code:
Code: [Select]
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 ;)
Title: Re: ADK Blog Block
Post by: Lyfing on January 11, 2012, 07:46:46 AM
Hailsa,

How would one go about getting this to show less than 5..like 1 or 2..??

Thanks,
-Lyfing
Title: Re: ADK Blog Block
Post by: bakayarou on February 20, 2013, 06:20:12 AM
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? =)
Title: Re: ADK Blog Block
Post by: bakayarou on February 20, 2013, 06:45:54 AM
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
Title: Re: ADK Blog Block
Post by: Dylert on January 03, 2014, 09:01:28 AM
Where can this blog mod be downloaded?
Title: Re: ADK Blog Block
Post by: [SiNaN] on January 03, 2014, 10:06:13 AM
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
Title: Re: ADK Blog Block
Post by: Dylert on January 03, 2014, 11:34:43 AM
These links links to blocks??? Where can I download the blog?
Title: Re: ADK Blog Block
Post by: [SiNaN] on January 03, 2014, 12:08:18 PM
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.
Title: Re: ADK Blog Block
Post by: Dylert on January 03, 2014, 12:10:16 PM
Ok, thanks!
SimplePortal 2.3.8 © 2008-2024, SimplePortal