SimplePortal
Customization => Blocks and Modifications => Block Requests => Topic started 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 :)
-
I guess this works:
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 />';
-
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 )
The database value you're trying to insert does not exist: this_page
, and to be in alphabetical order?
-
Block will give that error out Custom Pages, I guess this can't do, sorry. For alphabetical ordering:
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 />';
-
thanks grafitus for this and for your time.
maybe someone see good in this and find way to do that work in php block.