Main Menu
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.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

User Info

Welcome Guest.
Please log in.

Who's Online

  • Dot Guests: 1157
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

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!

Create a block message

Started by fdr77, December 27, 2010, 12:20:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fdr77

I wanted to create a block that takes a given message with certain characteristics.
For example, the board, the topic, the author, the number of views and answers .....
I did this but it does not work.
The message has id 4325
global $context, $settings, $scripturl, $txt;
global $user_info, $modSettings, $smcFunc, $posts;
$msgID = 4325;
$request = $smcFun['db_query']('', 'SELECT msg.id_board, b.name as boar_name, msg.id_topic, IFNULL(m.real_name, msg.poster_name) as poster_name, msg.poster_time, msg.subject, t.num_replies, t.num_views
FROM {db_prefix}messages as msg
LEFT JOIN {db_prefix}boards as b ON (msg.id_board = b.id_board)
LEFT JOIN {db_prefix}topics as t ON (msg.id_topic = t.id_topic)
LEFT JOIN {db_prefix}members as m ON (msg.id_member = m.id_member)
WHERE msg.id_msg = {int:message}',
array('message' => $msgID;
)
);
$row = $smcFunc['db_fetch_assoc']($request);
echo '<a href="' . $boardurl . '/?board=' . $row['board_id'] . '.0">' $row['board_name'] . '</a>'|<a href="' . $boardurl . '/?topic=' . $row['id_topic'] . '.0">'  $row['subject'] . '</a><br/>';
echo' Inserito da', $row['poster_name'], ' in ', $row['board_name'], ' |il ', $row['poster_time'],';

echo '(Visto: ', $row['num_views'], ' | Commenti: ', $row['num_replies'], ')<br/>';


echo' descrizione del messaggio che metto io';
echo'<div align="right">';
echo '<br/><a href="' . $boardurl . '/?action=post;topic=' . $row['id_topic'] . '"><b>Commenta..</b></a>|<a href="' . $boardurl . '/?topic=' . $row['id_topic'] . '.0"><b>Leggi tutto...</b></a></div><hr />';

a little help to make it work in a block php Simple portal?
In this mode go in sintax error
E' meglio bruciarsi in fretta che spegnersi lentamente                                               Kurt D. Cobain

130860

so, do you want to fetch a single message?  have you tried the  ssi_fetchPosts  function inSSI.php?

$post = ssi_fetchPosts(1, NULL, NULL);
echo $post[0]['body'], '<br />';


where 1 is the id o the topic you want to fetch and   $post[0]   0  is the message from that particular topic, in this case 0 is the first message, you ned to find out the number of the particular mesage you want to show.

you can do a print($post);  to see all the options avaliable, for example, ['body']  will show just the body

fdr77

#2
I wish it were so.
I don't speak english very well ...Let me explain with a picture
As a board news but get the topic instead the board
Over the ['body'] options ....What are the  possible option

here something like
http://simpleportal.net/index.php?topic=6165.msg35953#msg35953
E' meglio bruciarsi in fretta che spegnersi lentamente                                               Kurt D. Cobain

130860

and the code on that example didn't work?  thats pretty much the same I already told you, to use ssi fetchPost  function to get the topic you would like to display,   you just need the topic ID

fdr77

#4
 this is the result of the code.
I tried this but it is not as the attachment above
$msgID=4325;
ssi_fetchPosts($msgID, false, 'echo');

E' meglio bruciarsi in fretta che spegnersi lentamente                                               Kurt D. Cobain

130860

so, you want the block exactly as the image you attached?

you want the body of that particularly msg?

can you post the whole code your using?

fdr77

I would like as the block in the picture but taking the news(body, date, poster,wievs,replies...)of a selected message.
What code do you want me to publish?
E' meglio bruciarsi in fretta che spegnersi lentamente                                               Kurt D. Cobain

130860

I don't understand, if you take away the news. date, poster views and replies  then all you got is the link to that topic   do you only want to show the link to that topic?

fdr77

I wish it were so ..... but choosing a topic and not a board
E' meglio bruciarsi in fretta che spegnersi lentamente                                               Kurt D. Cobain

130860

ok, it seems what you want is the body of an specific message,   if that so, the  first code I give you does that:

Quote from: 130860 on December 27, 2010, 01:44:01 PM
so, do you want to fetch a single message?  have you tried the  ssi_fetchPosts  function inSSI.php?

$post = ssi_fetchPosts(1, NULL, NULL);
echo $post[0]['body'], '<br />';


where 1 is the id o the topic you want to fetch and   $post[0]   0  is the message from that particular topic, in this case 0 is the first message, you ned to find out the number of the particular mesage you want to show.

you can do a print($post);  to see all the options avaliable, for example, ['body']  will show just the body


you just need to change the 1  for the ID of the topic you want to display.

fdr77

#10
yes but your code  shows only the body  .
I would like to add date,Number of views,Number of replies,and autor. is possible?
E' meglio bruciarsi in fretta che spegnersi lentamente                                               Kurt D. Cobain

130860

sure its possible,   this is the array with all the info you can use:



// Build the array.
$posts[] = array(
'id' => $row['id_msg'],
'board' => array(
'id' => $row['id_board'],
'name' => $row['board_name'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'
),
'topic' => $row['id_topic'],
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => empty($row['id_member']) ? '' : $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['poster_name'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $smcFunc['strlen']($preview) > 128 ? $smcFunc['substr']($preview, 0, 128) . '...' : $preview,
'body' => $row['body'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '" rel="nofollow">' . $row['subject'] . '</a>',
'new' => !empty($row['is_read']),
'is_new' => empty($row['is_read']),
'new_from' => $row['new_from'],



for example, is you want to show the date, you used it like this:


$post = ssi_fetchPosts(1, NULL, NULL);
echo $post[0]['body'], '<br />';
echo $post[0]['timestamp'];  or $post[0]['time']

author:  you can use $post[0]['name']  or  $post[0]['link']

I believe this functions does not have any parameter for   Number of views and Number of replies.