collapse collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 221
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Welcome to SimplePortal.net! You can download SimplePortal from the Downloads Area!

Author Topic: SP articles more functions  (Read 24916 times)

0 Members and 1 Guest are viewing this topic.

Offline ataru

  • Jr. Member
  • **
  • Posts: 63
  • Gender: Male
    • Biancocelesti.org - Sempre Forza Lazio
  • SMF Version: 2.0.10
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #20 on: September 13, 2015, 05:59:12 PM »
Thanks, any way to make it both attached/image tags??? any that comes first
Sure it can be done. But I don't know how to get attachments from db. I never used to check it. Sorry

Offline Cyberkid

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SP articles more functions
« Reply #21 on: September 13, 2015, 06:07:28 PM »
 :'(

Offline goten22

  • Semi Newbie
  • *
  • Posts: 20
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #22 on: September 14, 2015, 09:06:23 AM »
An one more question. How can I display number of comments?

Offline ataru

  • Jr. Member
  • **
  • Posts: 63
  • Gender: Male
    • Biancocelesti.org - Sempre Forza Lazio
  • SMF Version: 2.0.10
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #23 on: September 14, 2015, 11:17:13 AM »
to add number of replies you have to get them in sql query adding num_replies (and eventually num_views) values from topics tab:

Code: [Select]
<?php
$sql_qry='
SELECT
m.id_topic, m.subject, m.poster_name, m.poster_time, m.icon, c.picture, c.name, 
. (!$displaymessage '' 'm.id_msg, m.body, m.smileys_enabled,
'
) . 'mem.id_member, mem.real_name, mem.avatar,
/*adding line*/
t.num_replies, t.num_views, 
/*end of added line*/
at.id_attach, at.attachment_type, at.filename, t.num_views
FROM {db_prefix}sp_articles AS a
INNER JOIN {db_prefix}sp_categories AS c ON (c.id_category = a.id_category)
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_message)
/*adding line*/
INNER JOIN {db_prefix}topics AS t ON (t.id_first_msg = a.id_message)
/*end of added line*/
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}attachments AS at ON (at.id_member = mem.id_member)
LEFT JOIN {db_prefix}topics AS t ON (m.id_msg = t.id_first_msg)
WHERE {query_see_board}
AND a.approved = {int:approved}' 
.  
(!empty($category
'
AND a.id_category = {int:category}' 
''
) . '
ORDER BY {raw:type}
LIMIT {int:limit}'
;
?>


and put them into $articles array:

Code: [Select]
<?php
$articles[] = array(
'id' => $row['id_topic'],
'name' => $row['subject'],
/*adding lines*/
'replies' => $row['num_replies']
'views' => $row['num_views']
/*end of added lines*/
'icon' => '<img src="' $settings[$icon_sources[$row['icon']]] . '/post/' $row['icon'] . '.gif" align="middle" alt="' $row['icon'] . '" border="0" />',
'msg' => ( !$displaymessage NULL
array(
'id' => $row['id_msg'],
'body' => $row['body'],
'nviews' => $row['num_views'],
'smileys_enabled' => $row['smileys_enabled'
)
),
'href' => $scripturl '?topic=' $row['id_topic'] . '.0',
'link' => '<a href="' $scripturl '?topic=' $row['id_topic'] . '.0">' $row['subject'] . '</a>',
'poster' => array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl '?action=profile;u=' $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' $scripturl '?action=profile;u=' $row['id_member'] . '">' $row['real_name'] . '</a>',
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true$row['poster_time']),
'timeyear' => timeformat($row['poster_time'], '%d %b %y'),
'timeday' => timeformat($row['poster_time'], '%H:%M:%S'),
),
'image' => array(
'href' => $row['picture'],
'image' => '<img src="' $row['picture'] . '" alt="' $row['name'] . '" />',
),
'avatar' => array(
'name' => $row['avatar'],
'image' => $row['avatar'] == '' ? ($row['id_attach'] > '<img 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 src="' $row['avatar'] . '" alt="" class="avatar" border="0" />' '<img src="' $modSettings['avatar_url'] . '/' htmlspecialchars($row['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $row['avatar'] == '' ? ($row['id_attach'] > ? (empty($row['attachment_type']) ? $scripturl '?action=dlattach;attach=' $row['id_attach'] . ';type=avatar' $modSettings['custom_avatar_url'] . '/' $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' $row['avatar']),
'url' => $row['avatar'] == '' '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' $row['avatar']),
),
);
?>


and then you will find number of views and replies using variables:
Code: [Select]
$article['replies']
$article['views']

double check everything, I didn't test it, and remove '/*adding line*/' and '/*end of added line*/' from code
« Last Edit: September 14, 2015, 11:31:39 AM by ataru »

Offline ataru

  • Jr. Member
  • **
  • Posts: 63
  • Gender: Male
    • Biancocelesti.org - Sempre Forza Lazio
  • SMF Version: 2.0.10
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #24 on: September 14, 2015, 11:36:47 AM »
:'(

you should take advantage from that mod:

http://custom.simplemachines.org/mods/index.php?mod=1151

using:

Code: [Select]
, IFNULL(big.id_attach, 0) AS big_id, big.filename AS big_filename, big.width AS big_width, big.height AS big_height,
IFNULL(thn.id_attach, 0) AS thn_id, thn.filename AS thn_filename, thn.width AS thn_width, thn.height AS thn_height

Code: [Select]
LEFT JOIN {db_prefix}attachments AS big ON (big.id_msg = mf.id_msg AND big.attachment_type = 0)
LEFT JOIN {db_prefix}attachments AS thn ON (thn.id_attach = big.id_thumb)

on sql query to get images and thumbnails from database

and then cycle them to get first attachment image.

Offline Cyberkid

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SP articles more functions
« Reply #25 on: September 14, 2015, 01:17:59 PM »
Am loving this site

Offline goten22

  • Semi Newbie
  • *
  • Posts: 20
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: SP articles more functions
« Reply #26 on: September 15, 2015, 06:06:06 AM »
I've got error "Not unique table/alias: 't'"

EDIT: Got it. Sad that I still don't know much how to deal with this sql, array etc.

Code: [Select]
SELECT
m.id_topic, m.subject, m.poster_name, m.poster_time, ///add t.num_replies///, m.icon, c.picture, c.name,

Code: [Select]
$articles[] = array(
'id' => $row['id_topic'],
'name' => $row['subject'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
///add 'replies' => $row['num_replies'],////
'msg' => ( !$displaymessage ? NULL:

and then just $article['replies']
« Last Edit: September 15, 2015, 10:06:59 PM by goten22 »

Offline Cyberkid

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SP articles more functions
« Reply #27 on: September 21, 2015, 10:12:46 AM »
:'(
you should take advantage from that mod:
http://custom.simplemachines.org/mods/index.php?mod=1151
using:
Code: [Select]
, IFNULL(big.id_attach, 0) AS big_id, big.filename AS big_filename, big.width AS big_width, big.height AS big_height,
IFNULL(thn.id_attach, 0) AS thn_id, thn.filename AS thn_filename, thn.width AS thn_width, thn.height AS thn_height
Code: [Select]
LEFT JOIN {db_prefix}attachments AS big ON (big.id_msg = mf.id_msg AND big.attachment_type = 0)
LEFT JOIN {db_prefix}attachments AS thn ON (thn.id_attach = big.id_thumb)
on sql query to get images and thumbnails from database
and then cycle them to get first attachment image.
Can this your code be done for recent post?? I mean detecting thumbnail via  [IMG] tag

Offline Cyberkid

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SP articles more functions
« Reply #28 on: December 04, 2016, 05:48:55 PM »
Thanks, any way to make it both attached/image tags??? any that comes first
Sure it can be done. But I don't know how to get attachments from db. I never used to check it. Sorry
hi bro, i had to look for my way down here again, was still thinking if this can be done, using this mod Post and PM Inline Attachments link here http://custom.simplemachines.org/mods/index.php?mod=3770 since it uses custom bbc tags, don't know if the url of the attachment can be extracted and echo out as img tag, please help out

Offline emanuele

  • Developer
  • *
  • Posts: 293
Re: SP articles more functions
« Reply #29 on: December 05, 2016, 03:03:15 PM »
Thanks, any way to make it both attached/image tags??? any that comes first
Attachments never come "first", they are always at the end of the message.
What if there is more than one attachment? Just pick the first?
I guess you'd want the attachment only if it is an image, and the thumbnail should served (not the full size image).

Work with attachments is a bit tricky TBH, I may try to put something together, but I do not assure you anything.

Offline Cyberkid

  • Semi Newbie
  • *
  • Posts: 15
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: SP articles more functions
« Reply #30 on: December 05, 2016, 06:10:51 PM »
Thanks, any way to make it both attached/image tags??? any that comes first
Attachments never come "first", they are always at the end of the message.
What if there is more than one attachment? Just pick the first?
I guess you'd want the attachment only if it is an image, and the thumbnail should served (not the full size image).

Work with attachments is a bit tricky TBH, I may try to put something together, but I do not assure you anything.
okay thanks bro

Offline emanuele

  • Developer
  • *
  • Posts: 293
Re: SP articles more functions
« Reply #31 on: December 08, 2016, 08:45:23 AM »
And the answers to my questions are...? ;)