News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Como aumentar o número de páginas do "action,recent"

Started by FragaCampos, July 26, 2009, 08:54:40 PM

Previous topic - Next topic

FragaCampos

Saudações a todos.

Como já muitos de vocês já deverão ter reparado, a página que mostra as últimas mensagens (action,recent) só tem 10 páginas.

Será que não dá para aumentar o número de páginas que aí aparecem?

Obrigado desde já.

margarett

Essa realmente é uma pequena incógnita...

A função que trata disse está no Sources/Recent.php

function getLastPosts($showlatestcount)
{
global $scripturl, $txt, $db_prefix, $user_info, $modSettings, $func;

// Find all the posts.  Newer ones will have higher IDs.  (assuming the last 20 * number are accessable...)
// !!!SLOW This query is now slow, NEEDS to be fixed.  Maybe break into two?
$request = db_query("
SELECT
m.posterTime, m.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG,
IFNULL(mem.realName, m.posterName) AS posterName, t.ID_BOARD, b.name AS bName,
LEFT(m.body, 384) AS body, m.smileysEnabled
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE m.ID_MSG >= " . max(0, $modSettings['maxMsgID'] - 20 * $showlatestcount) . "
AND t.ID_TOPIC = m.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? "
AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND $user_info[query_see_board]
ORDER BY m.ID_MSG DESC
LIMIT $showlatestcount", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
.............................


Não encontro em lado nenhum onde é que aquela variável "showlatestcount" é inicializada... Mas em lado nenhum mesmo... De qualquer forma, experimenta mudar aquele "LIMIT $showlatestcount" usando um número em vez da variável, só para ver se isso resulta...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

FragaCampos

Obrigado, mas não dá.

Escolhi o número 15 e devolveu-me o seguinte erro.
QuoteYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '15' at line 12
Ficheiro: /home/docspt/public_html/Sources/Recent.php
Linha: 122

margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

FragaCampos

Substitui o $showlatestcount por um inteiro, mas como eu percebo tanto isto como de um lagar de azeite... :P

margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

FragaCampos

Não estou a perceber lá muito bem  :P
O código que experimentei foi o que tu me deste, mas substitui apenas onde aparece $showlatestcount por 15...

margarett

Vamos experimentar de outra maneira:


function getLastPosts($showlatestcount)
{
   global $scripturl, $txt, $db_prefix, $user_info, $modSettings, $func;

   // Find all the posts.  Newer ones will have higher IDs.  (assuming the last 20 * number are accessable...)
   // !!!SLOW This query is now slow, NEEDS to be fixed.  Maybe break into two?
   $request = db_query("
      SELECT
         m.posterTime, m.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG,
         IFNULL(mem.realName, m.posterName) AS posterName, t.ID_BOARD, b.name AS bName,
         LEFT(m.body, 384) AS body, m.smileysEnabled
      FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
         LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
      WHERE m.ID_MSG >= " . max(0, $modSettings['maxMsgID'] - 20 * $showlatestcount) . "
         AND t.ID_TOPIC = m.ID_TOPIC
         AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? "
         AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
         AND $user_info[query_see_board]
      ORDER BY m.ID_MSG DESC
      LIMIT $showlatestcount", __FILE__, __LINE__);
   $posts = array();
   while ($row = mysql_fetch_assoc($request))
.............................


Passa a:


function getLastPosts($showlatestcount)
{
   global $scripturl, $txt, $db_prefix, $user_info, $modSettings, $func;
   $LimiteDoBruno = 15;

   // Find all the posts.  Newer ones will have higher IDs.  (assuming the last 20 * number are accessable...)
   // !!!SLOW This query is now slow, NEEDS to be fixed.  Maybe break into two?
   $request = db_query("
      SELECT
         m.posterTime, m.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG,
         IFNULL(mem.realName, m.posterName) AS posterName, t.ID_BOARD, b.name AS bName,
         LEFT(m.body, 384) AS body, m.smileysEnabled
      FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
         LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
      WHERE m.ID_MSG >= " . max(0, $modSettings['maxMsgID'] - 20 * $showlatestcount) . "
         AND t.ID_TOPIC = m.ID_TOPIC
         AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? "
         AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
         AND $user_info[query_see_board]
      ORDER BY m.ID_MSG DESC
      LIMIT $LimiteDoBruno", __FILE__, __LINE__);
   $posts = array();
   while ($row = mysql_fetch_assoc($request))
.............................


E vê lá do resultado. Atenção que pode não ser nada disto... Ainda pesquisei mas não vi nada do género, por isso cá estamos para inventar :P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

FragaCampos

A minha function getLastPosts($showlatestcount) é um pouco diferente da tua. Estou a usar o SMF 1.1.10. Fica aqui o código:

function getLastPosts($showlatestcount)
{
global $scripturl, $txt, $db_prefix, $user_info, $modSettings, $func, $settings, $ID_MEMBER;

// Find all the posts.  Newer ones will have higher IDs.  (assuming the last 20 * number are accessable...)
// !!!SLOW This query is now slow, NEEDS to be fixed.  Maybe break into two?
if (!empty($modSettings['recent_topics']) && $modSettings['recent_topics']){
    $request = db_query("
  SELECT
  m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
  IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
  IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
  IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon, t.numReplies, t.numViews
  FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
  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 = $ID_MEMBER)
  LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
  WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($showlatestcount, 5)) . "
  AND t.ID_LAST_MSG = m.ID_MSG
  AND b.ID_BOARD = t.ID_BOARD" . (empty($exclude_boards) ? '' : "
  AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . "
  AND $user_info[query_see_board]
  AND ms.ID_MSG = t.ID_FIRST_MSG
  ORDER BY t.ID_LAST_MSG DESC
  LIMIT $showlatestcount", __FILE__, __LINE__);
} else {
      $request = db_query("
    SELECT
    m.posterTime, m.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG,
    IFNULL(mem.realName, m.posterName) AS posterName, t.ID_BOARD, b.name AS bName,
    LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon, t.numViews, t.numReplies
    FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
    LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
    WHERE m.ID_MSG >= " . max(0, $modSettings['maxMsgID'] - 20 * $showlatestcount) . "
    AND t.ID_TOPIC = m.ID_TOPIC
    AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? "
    AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
    AND $user_info[query_see_board]
    ORDER BY m.ID_MSG DESC
    LIMIT $showlatestcount", __FILE__, __LINE__);
}
$posts = array();
if (!empty($modSettings['MemberColorRecentLastPost']))
$context['MemberColor_ID_MEMBER'] = array();

while ($row = mysql_fetch_assoc($request))
{
// Censor the subject and post for the preview ;).
censorText($row['subject']);
censorText($row['body']);

$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '&#10;')));
if ($func['strlen']($row['body']) > 128)
$row['body'] = $func['substr']($row['body'], 0, 128) . '...';

// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => $row['ID_TOPIC'],
'icon' => file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? $settings['images_url'] . '/post/' . $row['icon'] . '.gif' : $settings['default_images_url'] . '/post/' . $row['icon'] . '.gif',
'views' => $row['numViews'],
'replies' => $row['numReplies'],
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? (!empty($modSettings['MemberColorGuests']) ? '<span style="color:'.$modSettings['MemberColorGuests'].';">' : '').$row['posterName'].(!empty($modSettings['MemberColorGuests']) ? '</span>' : '') : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 24),
'preview' => $row['body'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'raw_timestamp' => $row['posterTime'],
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#msg' . $row['ID_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#msg' . $row['ID_MSG'] . '">' . $row['subject'] . '</a>'
);
//The Last Posters id for the MemberColor.
if (!empty($modSettings['MemberColorRecentLastPost']) && !empty($row['ID_MEMBER']))
$context['MemberColor_ID_MEMBER'][$row['ID_MEMBER']] = $row['ID_MEMBER'];
}
mysql_free_result($request);

// Know set the colors for the Recent posts...
if (!empty($context['MemberColor_ID_MEMBER'])) {
$colorDatas = load_onlineColors($context['MemberColor_ID_MEMBER']);
if (!empty($modSettings['MemberColorRecentLastPost']) && is_array($posts))
foreach($posts as $postkey => $postid_memcolor)
if(!empty($colorDatas[$postid_memcolor['poster']['id']]['colored_link']))
$posts[$postkey]['poster']['link'] = $colorDatas[$postid_memcolor['poster']['id']]['colored_link'];
}

return $posts;
}

margarett

A parte importante é igual:


function getLastPosts($showlatestcount)
{
   global $scripturl, $txt, $db_prefix, $user_info, $modSettings, $func, $settings, $ID_MEMBER;

   // Find all the posts.  Newer ones will have higher IDs.  (assuming the last 20 * number are accessable...)


Passa a:

function getLastPosts($showlatestcount)
{
   global $scripturl, $txt, $db_prefix, $user_info, $modSettings, $func, $settings, $ID_MEMBER;
   $LimiteDoBruno = 15;
   // Find all the posts.  Newer ones will have higher IDs.  (assuming the last 20 * number are accessable...)


E:

        ORDER BY t.ID_LAST_MSG DESC
        LIMIT $showlatestcount", __FILE__, __LINE__);
   } else {

Passa a:

        ORDER BY t.ID_LAST_MSG DESC
        LIMIT $LimiteDoBruno", __FILE__, __LINE__);
   } else {


Se te der erro, troca o nome "LimiteDoBruno" porque o SMF pode não gostar de nomes feios :P :P :P :P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Reflection

Faça as edições abaixo, mas você tem que ter em conta que a variável $showlatestcount é usada em mais lugares do SMF (como a localização dos ID's das mensagens)

Não tenho a certeza absoluta que $showlatestcount retornará o que você espera encontrar (neste caso, páginas), mas você pode definir no topo da função um número e deixar o código executar como tal.
Good "SMF" Portals
Tiny Portal [SMF 1.1.x only]
Simple Portal [SMF 1.1.x and 2.0]


Good "SMF" Theme Sites
SMF Themes [SMF 1.1.x and 2.0]
Dziner Studio [SMF 1.1.x and 2.0]

FragaCampos

Obrigado, Bruno. Desta vez não deu erro, mas ficou tudo na mesma... :P
Achas que deva colocar esta questão na secção em inglês?

margarett

Sim, deves. Mas explica BEM que o que queres é aumentar o número de páginas a mostrar nessa acção, e não o número de ultimas mensagens no índice do fórum! Senão é para aí que te mandam:
Admin --> Tema actual --> Número de mensagens recentes para mostrar no índice do Fórum
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

FragaCampos


FragaCampos

Graças ao SlammedDime, que deu a resposta aqui, eis a solução para este problema:

em /sources/recent.php

Code (encontrar) Select
if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95)
      $_REQUEST['start'] = 95;



Code (substituir) Select
if (isset($_REQUEST['start']) && $_REQUEST['start'] > 195)
      $_REQUEST['start'] = 195;


Code (encontrar) Select

// !!! This isn't accurate because we ignore the recycle bin.
$context['page_index'] = constructPageIndex($scripturl . '?action=recent', $_REQUEST['start'], min(100, $modSettings['totalMessages']), 10, false);
}
Code (substituir) Select

// !!! This isn't accurate because we ignore the recycle bin.
$context['page_index'] = constructPageIndex($scripturl . '?action=recent', $_REQUEST['start'], min(200, $modSettings['totalMessages']), 10, false);
}



O número de páginas passará a ser de 20 em vez de 10.
;)

margarett

Nunca lá ia :P

Boa info, deixa lá ver se se mete no índice ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Advertisement: