Advertisement:

Author Topic: SSI Functions  (Read 2280 times)

Offline njtweb

  • Sr. Member
  • ****
  • Posts: 773
SSI Functions
« on: September 04, 2018, 08:41:59 AM »
I have 2 questions.

1st. I want to limit the number of top posts by views to 5. How would that SSI function be written?
2nd. I want to show only a specific poll, not recent and not the top poll. Can you declare a specfic poll by ID?

Thank you too all in advance.

Offline vbgamer45

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 21,188
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: SSI Functions
« Reply #1 on: September 04, 2018, 11:30:48 AM »
For #2
http://www.simplemachines.org/community/ssi_examples.php

<?php ssi_showPoll($topicID); ?>
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline Mick.

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,971
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: SSI Functions
« Reply #2 on: September 04, 2018, 04:43:26 PM »
Change the 5 to whatever amount of top topic views you want.
Code: [Select]
ssi_topTopicsViews(5);

Offline njtweb

  • Sr. Member
  • ****
  • Posts: 773
Re: SSI Functions
« Reply #3 on: September 05, 2018, 10:10:00 AM »
Can't use either on my TP front page right panel. Too much data shows and it blows up the formatting. Thanks though.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,063
  • Gender: Male
    • Kindred-999 on GitHub
Re: SSI Functions
« Reply #4 on: September 05, 2018, 10:22:49 AM »
so use

Code: [Select]
$topiclist=ssi_topTopicsViews('replies',5,'array');

then you can output what you want, in the format you want....

foreach ($topiclist as $topic) {

echo

$topic['link'],
$topic['num_views'],
$topic['num_replies'];

}
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Mick.

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,971
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: SSI Functions
« Reply #5 on: September 05, 2018, 04:42:47 PM »
@kindred...
Your code throws a "Wrong value type sent to the database. Integer expected. (limit)" error. I went ahead and did it my way but maybe there's a better approach. I think the OP wants the title and number of views only.

Code: [Select]
$topiclist=ssi_topTopicsViews(5.0,'array');


foreach ($topiclist as $topic) {

echo '
<div align="left">' ,$topic['link'], '  Views = ' ,$topic['num_views'], '</div>';

}
« Last Edit: September 05, 2018, 05:40:40 PM by Mick. »

Offline njtweb

  • Sr. Member
  • ****
  • Posts: 773
Re: SSI Functions
« Reply #6 on: September 06, 2018, 07:26:14 AM »
I can't use it anyway, any of the SSI functions totally screw up my right side block. All of the blocks wind up in a scrambled mess, NBD, my basic HTML is fine, I'll just update whatever I see as the top topics by view as I see fit.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,063
  • Gender: Male
    • Kindred-999 on GitHub
Re: SSI Functions
« Reply #7 on: September 06, 2018, 07:57:33 AM »
njtweb...   If they "screw up your block", then you are not doing it right.

If you actually see the code that Mick used, it will not "screw up" anything --   but even if it does, you can reformat it however you like in the echo portion.

The whole point of the array option in the SSI functions is to output the values so that you can format them as you need...
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Mick.

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,971
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: SSI Functions
« Reply #8 on: September 06, 2018, 08:37:41 AM »
This one more of my liking. But if it breaks, it's not the code. It's prolly long titles being used. It's set to 5 topics and views only for your top topics.

Code: [Select]
$topiclist=ssi_topTopicsViews(5.0,'array');

echo '
<span style="float:right">Views</span>';

foreach ($topiclist as $topic)
{
echo '
<table border="0" width="100%">
<tr>
<td>' ,$topic['link'], ' <span style="float:right">' ,$topic['num_views'], '</span></td>
</tr>
</table>';
}

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,063
  • Gender: Male
    • Kindred-999 on GitHub
Re: SSI Functions
« Reply #9 on: September 06, 2018, 10:09:05 AM »
ugh.... don't use tables!

If you must do a tabular design, use table/cell classes in a div with css

e.g.

.rTable    { display: table; }
.rTableRow       { display: table-row; }
.rTableHeading    { display: table-header-group; }
.rTableBody    { display: table-row-group; }
.rTableFoot    { display: table-footer-group; }
.rTableCell, .rTableHead  { display: table-cell; }

and, doing that, you can always use overflow:hidden;
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Mick.

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,971
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: SSI Functions
« Reply #10 on: September 06, 2018, 10:10:24 AM »
ugh.... don't use tables!

If you must do a tabular design, use table/cell classes in a div with css

e.g.

.rTable    { display: table; }
.rTableRow       { display: table-row; }
.rTableHeading    { display: table-header-group; }
.rTableBody    { display: table-row-group; }
.rTableFoot    { display: table-footer-group; }
.rTableCell, .rTableHead  { display: table-cell; }

and, doing that, you can always use overflow:hidden;
I know what you mean, I dont like tables either. This was a quick design. ;)

Offline Mick.

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,971
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: SSI Functions
« Reply #11 on: September 06, 2018, 10:26:25 AM »
Lol....here you go..  ;D

Code: [Select]
echo '
<style type="text/css">
.divTable{
display: table;
width: 100%;
}
.divTableRow {
display: table-row;
}
.divTableCell {
display: table-cell;
padding: 3px 10px;
}
.divTableBody {
display: table-row-group;
}
</style>';




$topiclist=ssi_topTopicsViews(5.0,'array');

echo '
          <span style="float:right">Views</span>';

foreach ($topiclist as $topic)
{
echo '

          <div class="divTable">
              <div class="divTableBody">
                  <div class="divTableRow">
                      <div class="divTableCell">' ,$topic['link'], ' <span style="float: right;">' ,$topic['num_views'], '</span></div>
                  </div>
              </div>
          </div>';
}

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,063
  • Gender: Male
    • Kindred-999 on GitHub
Re: SSI Functions
« Reply #12 on: September 06, 2018, 11:06:29 AM »
yay!   
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Mick.

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,971
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: SSI Functions
« Reply #13 on: September 06, 2018, 01:33:20 PM »

Offline njtweb

  • Sr. Member
  • ****
  • Posts: 773
Re: SSI Functions
« Reply #14 on: March 09, 2019, 08:18:38 AM »
I do have a question. It's currently coded to show most viewed topics. Is there a way to make it show all most recent topics with views over 1000? I only want the most viewed topics from one board "board=85.0"

This is the current code.

Code: [Select]
$array = ssi_topTopicsViews(15,'array');

foreach ($array as $topic) {

echo

$topic['link'];

echo '
<div align="center"><a href="', $topic['href'], '">', $news['subject'], '</a><hr></div>';


}

Offline Virginiaz

  • Semi-Newbie
  • *
  • Posts: 57
Re: SSI Functions
« Reply #15 on: March 09, 2019, 11:03:06 AM »
I do have a question. It's currently coded to show most viewed topics. Is there a way to make it show all most recent topics with views over 1000? I only want the most viewed topics from one board "board=85.0"

This is the current code.

-snip-


I think this should work. I didn't test it though.

In /SSI.php

Replace:
Code: [Select]
function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo')
With:

Code: [Select]
function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo', $min_views = 0)

Replace:

Code: [Select]
    // Find all the posts in distinct topics.  Newer ones will have higher IDs.
    $request = $smcFunc['db_query']('substring', '
        SELECT
            m.poster_time, ms.subject, m.id_topic, m.id_member, m.id_msg, b.id_board, b.name AS board_name, t.num_replies, t.num_views,
            IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
            IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
            IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', SUBSTRING(m.body, 1, 384) AS body, m.smileys_enabled, m.icon
        FROM {db_prefix}topics AS t
            INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg)
            INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
            INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)
            LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
            LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
            LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})' : '') . '
        WHERE t.id_last_msg >= {int:min_message_id}
            ' . (empty($exclude_boards) ? '' : '
            AND b.id_board NOT IN ({array_int:exclude_boards})') . '
            ' . (empty($include_boards) ? '' : '
            AND b.id_board IN ({array_int:include_boards})') . '
            AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
            AND t.approved = {int:is_approved}
            AND m.approved = {int:is_approved}' : '') . '
        ORDER BY t.id_last_msg DESC
        LIMIT ' . $num_recent,
        array(
            'current_member' => $user_info['id'],
            'include_boards' => empty($include_boards) ? '' : $include_boards,
            'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
            'min_message_id' => $modSettings['maxMsgID'] - 35 * min($num_recent, 5),
            'is_approved' => 1,
        )
    );

With:

Code: [Select]
    // Find all the posts in distinct topics.  Newer ones will have higher IDs.
    $request = $smcFunc['db_query']('substring', '
        SELECT
            m.poster_time, ms.subject, m.id_topic, m.id_member, m.id_msg, b.id_board, b.name AS board_name, t.num_replies, t.num_views,
            IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
            IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
            IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', SUBSTRING(m.body, 1, 384) AS body, m.smileys_enabled, m.icon
        FROM {db_prefix}topics AS t
            INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg)
            INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
            INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)
            LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
            LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
            LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})' : '') . '
        WHERE t.id_last_msg >= {int:min_message_id}
            ' . (empty($exclude_boards) ? '' : '
            AND b.id_board NOT IN ({array_int:exclude_boards})') . '
            ' . (empty($include_boards) ? '' : '
            AND b.id_board IN ({array_int:include_boards})') . '
            AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
            AND t.approved = {int:is_approved}
            AND m.approved = {int:is_approved}' : '') . '
            AND t.num_views >= {int:min_views}
        ORDER BY t.id_last_msg DESC
        LIMIT ' . $num_recent,
        array(
            'current_member' => $user_info['id'],
            'include_boards' => empty($include_boards) ? '' : $include_boards,
            'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
            'min_message_id' => $modSettings['maxMsgID'] - 35 * min($num_recent, 5),
            'is_approved' => 1,
            'min_views' => (int)$min_views,
        )
    );

In the code you posted, replace:

Code: [Select]
$array = ssi_topTopicsViews(15,'array');

With:

Code: [Select]
// 3rd parameter is what boards to include in search, last parameter is minimum views (use 0 if you want to include new topics)
$array = ssi_topTopicsViews(15, null, array(85), 'array', 1000);

Offline njtweb

  • Sr. Member
  • ****
  • Posts: 773
Re: SSI Functions
« Reply #16 on: March 09, 2019, 11:27:16 AM »
Hi @Virginiaz

I don't actually want to change any physical files. I'm using Tinyportal front page. There are .php blocks where you can drop code into and save and it'll show the results on the tinyportal front page. That code example that I posted is exactly what is currently in there.

Thank you

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,963
    • StoryBB/StoryBB on GitHub
Re: SSI Functions
« Reply #17 on: March 09, 2019, 11:28:20 AM »
Since the SSI function doesn't do what you want it to do, the only choice really is to modify it, or copy paste the modified version into the HTML block.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 50,584
Re: SSI Functions
« Reply #18 on: March 09, 2019, 12:02:45 PM »
or copy paste the modified version into the HTML block.

dont you mean PHP block?

Offline njtweb

  • Sr. Member
  • ****
  • Posts: 773
Re: SSI Functions
« Reply #19 on: March 09, 2019, 12:15:18 PM »
or copy paste the modified version into the HTML block.

dont you mean PHP block?

Yes, that's what he means. That didn't work. The block just looks like there's nothing in it on the front page when it's saved.