SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: rocknroller on February 06, 2011, 07:27:48 AM

Title: page list
Post by: rocknroller on February 06, 2011, 07:27:48 AM
can someone create block for index of SP pages?

 ;D Or better for next version of simple portal.
Option for select pages what will be uset like index links relative to content of page.

when visitor read some content of the page, this will add at the bottom or right.... of the page somthing like:

 "Also read this pages:"
1.page title
2.page title
3.page title



sorry for my grammar  :)
Title: Re: page list
Post by: grafitus on February 07, 2011, 06:07:54 AM
I guess this works:
Code: [Select]
global $context, $smcFunc, $scripturl;

$words = explode(' ', $context['SPortal']['page']['title']);

$related_query = array();
$related_query[] = '
WHERE id_page != {int:this_page}
AND status = {int:status}';
foreach ($words as $word)
{
if (strlen($word) <= 3)
continue;

$related_query[] = ' OR title LIKE \'' . $word . '%\'';
}

$request = $smcFunc['db_query']('', '
SELECT namespace, title
FROM {db_prefix}sp_pages' .
implode(' ', $related_query) . '
LIMIT 5',
array(
'this_page' => $context['SPortal']['page']['id'],
'status' => 1,
)
);
$related_pages = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$related_pages[] = '<a href="' . $scripturl . '?page=' . $row['namespace'] . '">' . $row['title'] . '</a>';

$smcFunc['db_free_result']($request);

foreach ($related_pages as $page)
echo $page . '<br />';
Title: Re: page list
Post by: rocknroller on February 07, 2011, 01:19:35 PM
WOW   8) geat. thanks

is it possible to work in the php block(when i create new page and place code in there work great, but when I place code in php block getting this error )
Quote
The database value you're trying to insert does not exist: this_page
, and to be in alphabetical order?
Title: Re: page list
Post by: grafitus on February 08, 2011, 01:18:14 PM
Block will give that error out Custom Pages, I guess this can't do, sorry. For alphabetical ordering:
Code: [Select]
global $context, $smcFunc, $scripturl;

$words = explode(' ', $context['SPortal']['page']['title']);

$related_query = array();
$related_query[] = '
WHERE id_page != {int:this_page}
AND status = {int:status}';
foreach ($words as $word)
{
if (strlen($word) <= 3)
continue;

$related_query[] = ' OR title LIKE \'' . $word . '%\'';
}

$request = $smcFunc['db_query']('', '
SELECT namespace, title
FROM {db_prefix}sp_pages' .
implode(' ', $related_query) . '
ORDER BY title
LIMIT 5',
array(
'this_page' => $context['SPortal']['page']['id'],
'status' => 1,
)
);
$related_pages = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$related_pages[] = '<a href="' . $scripturl . '?page=' . $row['namespace'] . '">' . $row['title'] . '</a>';

$smcFunc['db_free_result']($request);

foreach ($related_pages as $page)
echo $page . '<br />';
Title: Re: page list
Post by: rocknroller on February 08, 2011, 01:44:33 PM
thanks grafitus for this and for your time.

maybe someone see good in this and find way to do that work in php block.
SimplePortal 2.3.8 © 2008-2024, SimplePortal