News:

Wondering if this will always be free?  See why free is better.

Main Menu

How Show Pagination (Page:1 2 3 4)

Started by Gonzalo Higuaín, August 06, 2015, 04:33:47 AM

Previous topic - Next topic

Gonzalo Higuaín

Hello! SMF Team. Help me please!

I use SSI Recent Topic!
<?php
require("webboard/SSI.php"); //แก้ไขพาธไฟล์เรียก SSI.php ในเว็บคุณให้ถูกต้อง

function WeloveRecentTopics($id,$limit=10)
{
  global 
$smcFunc,$scripturl;
  
  
$req $smcFunc['db_query']('','
      SELECT t.id_topic,t.num_replies,t.num_views,msg.subject,msg.poster_time,mem.id_member,mem.real_name,msg.poster_name,  b.id_board, b.name AS board_name
      FROM {db_prefix}topics AS t  
        INNER JOIN {db_prefix}messages AS msg ON(msg.id_msg = t.id_first_msg)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
        LEFT JOIN {db_prefix}members AS mem ON(mem.id_member = t.id_member_started)
      WHERE t.id_board = {int:id_board}
      ORDER BY t.id_first_msg DESC
      LIMIT {int:limit}'
,
    array(
      
'id_board' => $id,
      
'limit' => $limit
    
)
  );
  
$topics = array();
  while(
$row $smcFunc['db_fetch_assoc']($req))
  {
    
censorText($row['subject']);
    
$topic = array(
'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>'
),
      
'id' => $row['id_topic'],
      
'subject' => $row['subject'],
      
'link' => '<a href="'.$scripturl.'?topic='.$row['id_topic'].'" title="">'.$row['subject'].'</a>',
  'replies' => $row['num_replies'],
  'views' => $row['num_views'],
      
'time' => timeformat($row['poster_time']),
      
'timestamp' => forum_time(true$row['poster_time']),
      
'member' => array(
        
'id' => $row['id_member'],
        
'name' => !empty($row['id_member'])?$row['real_name']:$row['poster_name']
      )
    );
    if(empty(
$row['id_member']))
      
$topic['member']['link'] = '<span>'.$row['poster_name'].'</span>';
    else
      
$topic['member']['link'] = '<a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'" title="Profile">'.$row['real_name'].'</a>';

    
$topics[$row['id_topic']] = $topic;
  }
  return 
$topics;
}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ทำโชว์กระทู้หัวข้อล่าสุด smf 2.0.5 </title>
<meta name="description" content="เรารักประเทศไทย welovethailand.com วิธีทำโชว์กระทู้หัวข้อล่าสุด smf2.0.5 ดึงตรงจากฐานข้อมูลโดยตรง" />
<link href="Style.css" rel="stylesheet" type="text/css" />
<base target="_blank">
</head>

<body>
<h1>โชว์หัวข้อล่าสุดแบบแยกบอร์ด smf 2.0.5 (ดึงตรงจากฐานข้อมูล)</h1>
<?php 
  $recent 
WeloveRecentTopics(11,10);/* เลขตัวแรกคือชื่อบอร์ด, 10 คือจำนวนกระทู้ ถ้าไม่ใส่จะโชว์เพียง 10กระทู้ ถ้าต้องให้โชว์ทุกบอร์ด ลบ WHERE t.id_board = {int:id_board} ทิ้ง*/

echo '
<table align="center" cellpadding="5" cellspacing="0" width="100%" border="0">
         <tr>
                        <td width="40%" class="WeloveTh_header">หัวข้อ:</td>
                        <td width="20%" class="WeloveTh_header">ผู้โพสท์:</td>
<td width="5%"class="WeloveTh_header">[ อ่าน: ]</td>
<td width="5%"class="WeloveTh_header">[ ตอบ: ]</td>
<td width="20%" class="WeloveTh_header">รายชื่อบอร์ด:</td>
                        <td width="10%" class="WeloveTh_header">เดือน/วัน/ปี/เวลา:</td>
                    </tr>'
;

  foreach(
$recent as $id => $post)
  {
          echo '
                        <tr>
         <td class="Welovepost Welove_left">'
$post['link'], '</td>
         <td class="Welovepost Welove_rest">'
$post['member']['link'], '</td>
<td class="time Welovepost Welove_rest">['
$post['views'], ']</td>
<td class="time Welovepost Welove_rest">['
$post['replies'], ']</td>
<td class="time Welovepost Welove_rest">'
$post['board']['link'], '</td>
         <td class="time Welovepost Welove_rest">'
$post['time'], '</td>
       </tr>'
;
}
        
echo '
</table>
            '
;

?>

</body>
</html>





I want add Pagination (Page:1 2 3 4)
What add code function?  Help me Please!!



:) ;D :D ;) 8) :laugh:


I Love SMF
Thank you.

Kindred

first and foremost...   
Why did you re-state most of the entire recent topics function in your code?

second...
why would you paginate anything since you are only listing 10 mesages?

third...
why would you want to list more than 10 messages outside of the forum?
Слaва
Украинi

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

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Gonzalo Higuaín

first and foremost...   
Why did you re-state most of the entire recent topics function in your code?
- I use SimplePortal modify boardIndex.template.php


second...
why would you paginate anything since you are only listing 10 mesages?
- I use function SSI.php show picture , topic etc



third...
why would you want to list more than 10 messages outside of the forum?
- naptang.com [nofollow]



I'm sorry. I'm Not good at English. I'm Learning SMF.

Please help me.



JBlaze

There's no need to rewrite what's already in ssi_recentTopics();

First, we want to make sure we're returning the results rather than echoing them. Make sure to set $output_method to 'return'.
$result = ssi_recentTopics(10, null, null, 'return');

Second, to paginate the results from ssi_recentTopics(), treat the $num_recent variable as a string and set your LIMIT value as necessary. So, if you're wanting the second set of 10 results, you would set $num_recent to '10, 2'.
$result = ssi_recentTopics('10, 2', null, null, 'return');

Now, the null values I've set are actually the $exclude_boards and $include_boards values. You can leave those alone if you want to neither include or exclude any boards from this list. But if you do, create an array of the board id's you want to either include or exclude.

Lastly, you'll want to take a look at the constructPageIndex() function in Sources/Subs.php, and maybe look at examples of how it's used in places like the memberlist.
Jason Clemons
Former Team Member 2009 - 2012

Gonzalo Higuaín

I thank you very much but I'm confused .

I Open SSI.php search ssi_recentTopics() :'(

What  search code??

:-\ :'( :'(


Help me ... Please

Kindred

you don't have to search any code and you don't have to edit ssi.php at all... as a matter of fact. DON'T...

after the include of SSI, CALL the SSI function, as described.
Слaва
Украинi

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

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

JBlaze

@Kindred, relax dude. You're coming off as *extremely* hostile, and it's not cool.

@Developing, what you are after involves a lot of extra overhead. Do you absolutely need the pagination, or can you live with just displaying 'x' number of recent topics? My suggestion would be to take a look at one of the portal mods out there, and see how they do their blocks. Also, with our language barrier, I don't really think either one of us can convey what needs to be explained. Do you have access to a Thai -> English translator?
Jason Clemons
Former Team Member 2009 - 2012

onepiece

This should give you an idea:

<?php

require("webboard/SSI.php"); //แก้ไขพาธไฟล์เรียก SSI.php ในเว็บคุณให้ถูกต้อง

// Change the following two variables
$total_number_of_posts_to_show 50;
$number_of_posts_to_show_per_page 10;

function 
WeloveRecentTopics($id$limit 10$start 0)
{
global $smcFunc$scripturl;

$request $smcFunc['db_query']('''
SELECT
t.id_topic, t.num_replies, t.num_views, msg.subject,
msg.poster_time, mem.id_member, mem.real_name,
msg.poster_name, b.id_board, b.name AS board_name
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS msg ON (msg.id_msg = t.id_first_msg)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = t.id_member_started)
WHERE t.id_board = {int:id_board}
ORDER BY t.id_first_msg DESC
LIMIT {int:start}, {int:limit}'
,
array(
'id_board' => $id,
'start' => $start,
'limit' => $limit,
)
);
$topics = array();
while($row $smcFunc['db_fetch_assoc']($request))
{
censorText($row['subject']);

$topic = array(
'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>'
),
'id' => $row['id_topic'],
'subject' => $row['subject'],
'link' => '<a href="' $scripturl '?topic=' $row['id_topic'] . '" title="">' $row['subject'] . '</a>',
'replies' => $row['num_replies'],
'views' => $row['num_views'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true$row['poster_time']),
'member' => array(
'id' => $row['id_member'],
'name' => !empty($row['id_member']) ? $row['real_name'] : $row['poster_name'],
),
);

if (empty($row['id_member']))
$topic['member']['link'] = '<span>' $row['poster_name'] . '</span>';
else
$topic['member']['link'] = '<a href="' $scripturl '?action=profile;u=' $row['id_member'] . '" title="Profile">' $row['real_name'] . '</a>';

$topics[$row['id_topic']] = $topic;
}

return $topics;
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ทำโชว์กระทู้หัวข้อล่าสุด smf 2.0.5</title>
<meta name="description" content="เรารักประเทศไทย welovethailand.com วิธีทำโชว์กระทู้หัวข้อล่าสุด smf2.0.5 ดึงตรงจากฐานข้อมูลโดยตรง" />
<link href="Style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>โชว์หัวข้อล่าสุดแบบแยกบอร์ด smf 2.0.5 (ดึงตรงจากฐานข้อมูล)</h1>
<?php 

$start 
= !empty($_REQUEST['page']) ? (int) $_REQUEST['page'] : 0;
$page_index constructPageIndex('?page=%1$d'$start$total_number_of_posts_to_show$number_of_posts_to_show_per_pagetrue);

$recent WeloveRecentTopics(11$number_of_posts_to_show_per_page$start);/* เลขตัวแรกคือชื่อบอร์ด, 10 คือจำนวนกระทู้ ถ้าไม่ใส่จะโชว์เพียง 10กระทู้ ถ้าต้องให้โชว์ทุกบอร์ด ลบ WHERE t.id_board = {int:id_board} ทิ้ง*/

echo '
<table align="center" cellpadding="5" cellspacing="0" width="100%" border="0">
<tr>
<td width="40%" class="WeloveTh_header">หัวข้อ:</td>
<td width="20%" class="WeloveTh_header">ผู้โพสท์:</td>
<td width="5%"class="WeloveTh_header">[ อ่าน: ]</td>
<td width="5%"class="WeloveTh_header">[ ตอบ: ]</td>
<td width="20%" class="WeloveTh_header">รายชื่อบอร์ด:</td>
<td width="10%" class="WeloveTh_header">เดือน/วัน/ปี/เวลา:</td>
</tr>'
;

foreach (
$recent as $id => $post)
{
echo '
<tr>
<td class="Welovepost Welove_left">'
$post['link'], '</td>
<td class="Welovepost Welove_rest">'
$post['member']['link'], '</td>
<td class="time Welovepost Welove_rest">['
$post['views'], ']</td>
<td class="time Welovepost Welove_rest">['
$post['replies'], ']</td>
<td class="time Welovepost Welove_rest">'
$post['board']['link'], '</td>
<td class="time Welovepost Welove_rest">'
$post['time'], '</td>
</tr>'
;
}

echo 
'
</table>
<div style="text-align: center;">Pages:'
$page_index'</div>';

?>

</body>
</html>

Kindred

Ummmm.... Onepiece...  No

That was specifically what we said not to do.

Do not try to rebuild the entire function. The function alreayd exists in ssi and there is no need to do that. As I said above, use the function call, like zilladotexe said...

Zilla...   I am not hostile. Due to the obvious language barrier, plain, no frills, statements have to be made... And, apparently, the folks reading this thread are still not reading what has actually been said.
Слaва
Украинi

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

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Gonzalo Higuaín

#10
Quote from: onepiece on August 08, 2015, 05:44:34 PM
This should give you an idea:

<?php

require("webboard/SSI.php"); //แก้ไขพาธไฟล์เรียก SSI.php ในเว็บคุณให้ถูกต้อง

// Change the following two variables
$total_number_of_posts_to_show 50;
$number_of_posts_to_show_per_page 10;

function 
WeloveRecentTopics($id$limit 10$start 0)
{
global $smcFunc$scripturl;

$request $smcFunc['db_query']('''
SELECT
t.id_topic, t.num_replies, t.num_views, msg.subject,
msg.poster_time, mem.id_member, mem.real_name,
msg.poster_name, b.id_board, b.name AS board_name
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS msg ON (msg.id_msg = t.id_first_msg)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = t.id_member_started)
WHERE t.id_board = {int:id_board}
ORDER BY t.id_first_msg DESC
LIMIT {int:start}, {int:limit}'
,
array(
'id_board' => $id,
'start' => $start,
'limit' => $limit,
)
);
$topics = array();
while($row $smcFunc['db_fetch_assoc']($request))
{
censorText($row['subject']);

$topic = array(
'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>'
),
'id' => $row['id_topic'],
'subject' => $row['subject'],
'link' => '<a href="' $scripturl '?topic=' $row['id_topic'] . '" title="">' $row['subject'] . '</a>',
'replies' => $row['num_replies'],
'views' => $row['num_views'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true$row['poster_time']),
'member' => array(
'id' => $row['id_member'],
'name' => !empty($row['id_member']) ? $row['real_name'] : $row['poster_name'],
),
);

if (empty($row['id_member']))
$topic['member']['link'] = '<span>' $row['poster_name'] . '</span>';
else
$topic['member']['link'] = '<a href="' $scripturl '?action=profile;u=' $row['id_member'] . '" title="Profile">' $row['real_name'] . '</a>';

$topics[$row['id_topic']] = $topic;
}

return $topics;
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ทำโชว์กระทู้หัวข้อล่าสุด smf 2.0.5</title>
<meta name="description" content="เรารักประเทศไทย welovethailand.com วิธีทำโชว์กระทู้หัวข้อล่าสุด smf2.0.5 ดึงตรงจากฐานข้อมูลโดยตรง" />
<link href="Style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>โชว์หัวข้อล่าสุดแบบแยกบอร์ด smf 2.0.5 (ดึงตรงจากฐานข้อมูล)</h1>
<?php 

$start 
= !empty($_REQUEST['page']) ? (int) $_REQUEST['page'] : 0;
$page_index constructPageIndex('?page=%1$d'$start$total_number_of_posts_to_show$number_of_posts_to_show_per_pagetrue);

$recent WeloveRecentTopics(11$number_of_posts_to_show_per_page$start);/* เลขตัวแรกคือชื่อบอร์ด, 10 คือจำนวนกระทู้ ถ้าไม่ใส่จะโชว์เพียง 10กระทู้ ถ้าต้องให้โชว์ทุกบอร์ด ลบ WHERE t.id_board = {int:id_board} ทิ้ง*/

echo '
<table align="center" cellpadding="5" cellspacing="0" width="100%" border="0">
<tr>
<td width="40%" class="WeloveTh_header">หัวข้อ:</td>
<td width="20%" class="WeloveTh_header">ผู้โพสท์:</td>
<td width="5%"class="WeloveTh_header">[ อ่าน: ]</td>
<td width="5%"class="WeloveTh_header">[ ตอบ: ]</td>
<td width="20%" class="WeloveTh_header">รายชื่อบอร์ด:</td>
<td width="10%" class="WeloveTh_header">เดือน/วัน/ปี/เวลา:</td>
</tr>'
;

foreach (
$recent as $id => $post)
{
echo '
<tr>
<td class="Welovepost Welove_left">'
$post['link'], '</td>
<td class="Welovepost Welove_rest">'
$post['member']['link'], '</td>
<td class="time Welovepost Welove_rest">['
$post['views'], ']</td>
<td class="time Welovepost Welove_rest">['
$post['replies'], ']</td>
<td class="time Welovepost Welove_rest">'
$post['board']['link'], '</td>
<td class="time Welovepost Welove_rest">'
$post['time'], '</td>
</tr>'
;
}

echo 
'
</table>
<div style="text-align: center;">Pages:'
$page_index'</div>';

?>

</body>
</html>


Yes!!! I very Happy

Thank you "onepiece" and SMF Team



Hello! I use mod smart_pagination
I want show total-page auto add css smart_pagination < >

example

Back | 1 , ... , p , p , page , p , p , ... , 100 | Next

onepiece

Quote from: Kindred on August 08, 2015, 09:49:24 PM
Ummmm.... Onepiece...  No

That was specifically what we said not to do.

Do not try to rebuild the entire function. The function alreayd exists in ssi and there is no need to do that. As I said above, use the function call, like zilladotexe said...

Zilla...   I am not hostile. Due to the obvious language barrier, plain, no frills, statements have to be made... And, apparently, the folks reading this thread are still not reading what has actually been said.

There is no call in SSI.php, by default, that would give you anything close to what the custom function in the first post gives. (see the WHERE and ORDER BY clauses in the query and note that it queries FROM topics table) The request was very simple: to add pagination to the custom recent topics function. There is no need to overcomplicate things and try to enforce what you think should be done.

onepiece

Quote from: Developing on August 09, 2015, 05:09:21 AM
Hello! I use mod smart_pagination
I want show total-page auto add css smart_pagination < >

example

Back | 1 , ... , p , p , page , p , p , ... , 100 | Next

For that, you'll have to include the stylesheet that comes with the mod and generate previous and next links for your pagination. It'd look something like this:

<?php

require("webboard/SSI.php"); //แก้ไขพาธไฟล์เรียก SSI.php ในเว็บคุณให้ถูกต้อง

$total_number_of_posts_to_show 50;
$number_of_posts_to_show_per_page 10;

function 
WeloveRecentTopics($id$limit 10$start 0)
{
global $smcFunc$scripturl;

$request $smcFunc['db_query']('''
SELECT
t.id_topic, t.num_replies, t.num_views, msg.subject,
msg.poster_time, mem.id_member, mem.real_name,
msg.poster_name, b.id_board, b.name AS board_name
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS msg ON (msg.id_msg = t.id_first_msg)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = t.id_member_started)
WHERE t.id_board = {int:id_board}
ORDER BY t.id_first_msg DESC
LIMIT {int:start}, {int:limit}'
,
array(
'id_board' => $id,
'start' => $start,
'limit' => $limit,
)
);
$topics = array();
while($row $smcFunc['db_fetch_assoc']($request))
{
censorText($row['subject']);

$topic = array(
'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>'
),
'id' => $row['id_topic'],
'subject' => $row['subject'],
'link' => '<a href="' $scripturl '?topic=' $row['id_topic'] . '" title="">' $row['subject'] . '</a>',
'replies' => $row['num_replies'],
'views' => $row['num_views'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true$row['poster_time']),
'member' => array(
'id' => $row['id_member'],
'name' => !empty($row['id_member']) ? $row['real_name'] : $row['poster_name'],
),
);

if (empty($row['id_member']))
$topic['member']['link'] = '<span>' $row['poster_name'] . '</span>';
else
$topic['member']['link'] = '<a href="' $scripturl '?action=profile;u=' $row['id_member'] . '" title="Profile">' $row['real_name'] . '</a>';

$topics[$row['id_topic']] = $topic;
}

return $topics;
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ทำโชว์กระทู้หัวข้อล่าสุด smf 2.0.5</title>
<meta name="description" content="เรารักประเทศไทย welovethailand.com วิธีทำโชว์กระทู้หัวข้อล่าสุด smf2.0.5 ดึงตรงจากฐานข้อมูลโดยตรง" />
<link href="Style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="<?php echo $settings['default_theme_url']; ?>/css/pagination.css" />
</head>
<body>
<h1>โชว์หัวข้อล่าสุดแบบแยกบอร์ด smf 2.0.5 (ดึงตรงจากฐานข้อมูล)</h1>
<?php 

$start 
= !empty($_REQUEST['page']) ? (int) $_REQUEST['page'] : 0;
$total_pages ceil($total_number_of_posts_to_show $number_of_posts_to_show_per_page);
$current_page ceil($start $number_of_posts_to_show_per_page);
$page_index constructPageIndex('?page=%1$d'$start$total_number_of_posts_to_show$number_of_posts_to_show_per_pagetrue);
$previous_link $next_link '';
if (
$current_page 0)
$previous_link '<a class="navPages" href="?page=' . (($current_page 1) * $number_of_posts_to_show_per_page) .'">&laquo;</a> ';
if (
$current_page $total_pages 1)
$next_link '<a class="navPages" href="?page=' . (($current_page 1) * $number_of_posts_to_show_per_page) . '">&raquo;</a>';

$recent WeloveRecentTopics(11$number_of_posts_to_show_per_page$start);/* เลขตัวแรกคือชื่อบอร์ด, 10 คือจำนวนกระทู้ ถ้าไม่ใส่จะโชว์เพียง 10กระทู้ ถ้าต้องให้โชว์ทุกบอร์ด ลบ WHERE t.id_board = {int:id_board} ทิ้ง*/

echo '
<table align="center" cellpadding="5" cellspacing="0" width="100%" border="0">
<tr>
<td width="40%" class="WeloveTh_header">หัวข้อ:</td>
<td width="20%" class="WeloveTh_header">ผู้โพสท์:</td>
<td width="5%"class="WeloveTh_header">[ อ่าน: ]</td>
<td width="5%"class="WeloveTh_header">[ ตอบ: ]</td>
<td width="20%" class="WeloveTh_header">รายชื่อบอร์ด:</td>
<td width="10%" class="WeloveTh_header">เดือน/วัน/ปี/เวลา:</td>
</tr>'
;

foreach (
$recent as $id => $post)
{
echo '
<tr>
<td class="Welovepost Welove_left">'
$post['link'], '</td>
<td class="Welovepost Welove_rest">'
$post['member']['link'], '</td>
<td class="time Welovepost Welove_rest">['
$post['views'], ']</td>
<td class="time Welovepost Welove_rest">['
$post['replies'], ']</td>
<td class="time Welovepost Welove_rest">'
$post['board']['link'], '</td>
<td class="time Welovepost Welove_rest">'
$post['time'], '</td>
</tr>'
;
}

echo 
'
</table>
<div class="pagesection" style="text-align: center;">Pages: '
$previous_link$page_index$next_link'</div>';

?>

</body>
</html>

Gonzalo Higuaín

Quote from: onepiece on August 09, 2015, 05:48:41 AM
Quote from: Kindred on August 08, 2015, 09:49:24 PM
Ummmm.... Onepiece...  No

That was specifically what we said not to do.

Do not try to rebuild the entire function. The function alreayd exists in ssi and there is no need to do that. As I said above, use the function call, like zilladotexe said...

Zilla...   I am not hostile. Due to the obvious language barrier, plain, no frills, statements have to be made... And, apparently, the folks reading this thread are still not reading what has actually been said.

There is no call in SSI.php, by default, that would give you anything close to what the custom function in the first post gives. (see the WHERE and ORDER BY clauses in the query and note that it queries FROM topics table) The request was very simple: to add pagination to the custom recent topics function. There is no need to overcomplicate things and try to enforce what you think should be done.


Yessss!!


Thank you very much!!!!

Gonzalo Higuaín

Help me Please again!!!


I want show pagination , body , title
<?php require("./Settings.php"); //เรียกไฟล์ Settings.php จากบอร์ด ใส่ path ไฟล์ให้ถูกต้องด้วย

?>

<div style="border:1px solid #b7b7b7; background-color:#f7f5f5; padding-left:0px; padding-right:0px; padding-top:10px;">
<table width='100%' border='0' cellpadding='0' cellspacing='0' >
<?php


$number 
"16"// จำนวนหัวข้อ
$board "12"// นัมเบอร์บอร์ดที่ต้องการให้แสดง โชว์หลายๆบอร์ดผสมกันใช้คอมม่าคั่น 1,2,3 

function findIMG($text){
if (preg_match_all('/\[img\].*?\[\/img\]/i',$text,$page)){
foreach($page as $value)
$src substr($value[0],5);
$src substr($src,0,-6);
return($src);}
if (preg_match_all('/\[img width=\d{3} height=\d{3}\].*?\[\/img\]/i',$text,$page)){
foreach($page as $value)
$src substr($value[0],26);
$src substr($src,0,-6);
return($src);}

}

$prefix1 $db_prefix."topics"
$prefix2 $db_prefix."messages";
$prefix3 $db_prefix."members";
$prefix4 $db_prefix"attachments";
@
mysql_connect($db_server,$db_user,$db_passwd) or die("sorry! now it can't connect the smf database"); 
$charset ="SET NAMES utf8";mysql_query($charset//set language utf8 or tis620 
or die('Invalid query: ' mysql_error()); 

$sql "select t.id_topic,t.id_board,t.id_last_msg,t.num_replies,t.num_views,m.body,m.id_topic,m.id_board,m.id_msg,m.subject,m.id_member,m.poster_time,s.id_member,IFNULL(s.real_name, m.poster_name) AS poster_name,IFNULL(a.id_attach,0) AS id_thumb,a.id_msg 
from 
$prefix1 AS t 
LEFT JOIN 
$prefix2 AS m ON (t.id_topic=m.id_topic)
LEFT JOIN 
$prefix3 AS s ON (m.id_member=s.id_member)
LEFT JOIN 
$prefix4 AS a ON (m.id_msg=a.id_msg AND id_thumb = 0) 
where t.id_board IN(
$board)  GROUP BY t.id_topic order by t.id_topic DESC limit 0,$number"

$result mysql_db_query($db_name,$sql); 
$row mysql_num_rows($result); 
$i 0;

while (
$num mysql_fetch_array($result)) { 

$idtopic $num["id_topic"]; 
$id_msg $num["id_msg"];
$title =  $num["subject"]; 
$id_last_msg =  $num["id_last_msg"];
$numViews =$num["num_views"];
$reply $num["num_replies"]; 
$id_thumb =$num["id_thumb"];
$id_poster =$num["id_member"];
$poster =$num["poster_name"];
$datepost =$num["poster_time"];
$srcPic findIMG($num['body']);

//ถ้าไม่มีรูปภาพ จะขึ้นรูป NO_IMAGE.png แทน *มีรูปแต่รูปหรือลิงค์เสียภาพNO_IMAGEไม่ขึ้นครับ
if(empty($srcPic))
$srcPic 'http://www.welovethailand.com/NO_IMAGE.png';



// Attachments img แสดงภาพจากไฟล์แนบ หากใช้ใส่ตัวแปล ".$attach_img." ตามตำแหน่งที่ต้องการ 
if(!empty($num['id_msg'])){
$attach_img="<img src=\"".$boardurl."/index.php?action=dlattach;topic=".$idtopic.";attach=".$id_thumb.";image\" width='55'  height='55' border='0'>";
}else {
$attach_img="<img src='http://www.welovethailand.com/NO_IMAGE.png' width='55' height='55' alt=''/>";

}

$today date("d M Y"); 
$date =date("d",$num["poster_time"]);
$month date ("m",$num["poster_time"]);
$year=date("Y",$num["poster_time"]) +543;
$datepost =date("d M Y",$num["poster_time"]);
$stime =date("H:i:s",$num["poster_time"]);


//วันที่โพสท์
if ($today==$datepost

$time date("<font color='#FF0000'><b>วันนี้, $stime</font></b>"); 
} else { 
$time date ("เมื่อวันที่ : $date $month $year$stime");


//new.gif ภาพกระทู้ใหม่ล่าสุด แสดงเฉพาะของวันนี้ today เท่านั้น (เปลี่ยนใส่พาธไฟล์ให้ถูกต้อง)
if($datepost==$today){
$img_new="<img src=\"webboard/Themes/default/images/thai-utf8/new.gif\">"//path picture new
}else {
$img_new="";
}
?>


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Highlight</title>
<link href="http://www.naptang.com/Themes/default/css/index.css" rel="stylesheet" type="text/css" />
</head>
<body topmargin="0" leftmargin="0">
<?php
//show the content 4 คือจำนวนคอลัมน์
 
if ($i == 0) echo("<tr>");
echo (
"<td>
<table border='0' cellpadding='0' cellspacing='0' width='100%'>
<tr>
<td>

<div style='width:168px; height:138px; padding:0px; margin:0px 20px 0px 20px; float:left;'>
<table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td>
<div style='background-color:#f3f2f2; border:black 4px solid; margin-left:auto; margin-right:auto; width:160px; height:93px; margin-top:0px;'><a href='"
.$boardurl."/index.php?topic=".$idtopic.".msg".$id_msg.";topicseen#new'' target='_blank' >
<img src='"
.$srcPic." ' width='160' height='93'></a><br/></div>
<div style='text-align:center; padding-top:2px; padding-bottom:5px;'><a style='text-decoration:none; color:blue; font-size:11px;' href='"
.$boardurl."/index.php?topic=".$idtopic.".msg".$id_msg.";topicseen#new'' target='_blank' >"$title."</a></div>
</td>
</tr>
</table>
</div>

</td>
</tr>
</table>
</td>"
);
if (
$i 4== 4) echo("</tr>");
$i++;


}  
?>


</table>
</div>
</body>
</html>




Thank You  !!!  SMFTeam

JBlaze

1. Don't call Settings.php directly. Include SSI.php
2. Don't use mysql functions directly. SMF has built-in functions to help with database queries. You will need to learn to use $smcFunc.
3. Please be a little more specific as to what you're trying to do.
Jason Clemons
Former Team Member 2009 - 2012

Pipke

"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Gonzalo Higuaín

I testing
Mod Name: Recent Forum Topics on Boardindex


Thank you

Biology Forums

I've done this for one of my pages:

http://biology-forums.com/index.php?action=unanswered

The code is based on an SSI function though. I will upload that code if this is what you're looking for.


alex-ergeev

Quote from: Shuban on August 20, 2015, 01:12:00 PM
I've done this for one of my pages:
The code is based on an SSI function though. I will upload that code if this is what you're looking for.
Please upload it out if you do not difficult.

Advertisement: