SimplePortal
Customization => Blocks and Modifications => Topic started by: ccbtimewiz on October 29, 2015, 08:47:50 PM
-
Sticky Articles
SMF 2.0 | SP 2.3.6
What this modification will do is allow you to define articles that will always appear first on the articles list displayed on your portal.
Might make $article_order no longer a hardcoded array and implement into article system itself if developers don't beat me to it.
Open /Sources/PortalBlocks.php
Find:
if (empty($image))
Replace with:
/*
Usage:
$article_order (array)
- contains a numerical list of topic ids (articles) you want stickied
- the order of stickies is the order of the array
- to get a topic id, hover over it and look at the link for ?topic=xxx
- alternatively you can look at the database for id_topic under smf_messages
Example:
$article_order = array(13, 11, 12, 8, 9, 10, 5, 14, 6);
*/
$article_order = array();
/*
*
*/
$new_articles = array();
$article_order = array_unique($article_order);
foreach ($article_order as $id)
{
foreach ($articles as $article)
{
if ($article['id'] == $id)
$new_articles[] = $article;
}
}
foreach ($articles as $article)
{
if (!in_array($article['id'], $article_order))
$new_articles[] = $article;
}
$articles = $new_articles;
if (empty($image))
-
Sorry, but in my case this code does not work,
article order didn't change
Did you test on SP 2.3.6?
-
Did you follow the instructions?
-
I can confirm it works as it worked on my test site, nice block Sayaka ;)
-
I really would like to fix this problem,
I want the article to be sticked "Бескамерная резина: плюсы и минусы."
see http://www.sportgen.ru/forum/
my code in /forum/Sources/PortalBlocks.php:
/*
Usage:
$article_order (array)
- contains a numerical list of topic ids (articles) you want stickied
- the order of stickies is the order of the array
- to get a topic id, hover over it and look at the link for ?topic=xxx
- alternatively you can look at the database for id_topic under smf_messages
Example:
$article_order = array(13, 11, 12, 8, 9, 10, 5, 14, 6);
*/
$article_order = array(2285);
/*
*
*/
$new_articles = array();
$article_order = array_unique($article_order);
foreach ($article_order as $id)
{
foreach ($articles as $article)
{
if ($article['id'] == $id)
$new_articles[] = $article;
}
}
foreach ($articles as $article)
{
if (!in_array($article['id'], $article_order))
$new_articles[] = $article;
}
$articles = $new_articles;
if (empty($image))
......
it doesn't work... (
how can I diagnose a problem?
-
That's strange, it should output that topic first.
Do you have any errors in your Forum Error Log? Can you post the file PortalBlocks.php here as an attachment?
-
Forum Error log is empty,
portalBlocks.php attached...
-
Have you tried clearing your forum's cache?
-
yes, I have cleared...
how can I trace the code step by step to point problem?
-
why don't you release a real mod?
you will get more users for it and mor testers ;)
-
Well it's a block, it's not meant to be a mod since it strictly requires SimplePortal to work.
-
I'm going to see through the syntax and see if I made a mistake when it handles just one article.
-
I'm going to see through the syntax and see if I made a mistake when it handles just one article.
Sayaka?
-
I guess it works as long as the article is shown on the page.
Being the "Бескамерная" article on the third page it's not retrieved from the database and as such not displayed on the first page.
If you want to have a "really" sticky article, you need an additional query to retrieve the data.
-
Ahhh, I see now. I'll see into making that adjustment.
-
Ahhh, I see now. I'll see into making that adjustment.
Sayaka? )
-
http://custom.simplemachines.org/mods/index.php?mod=3425
it can be modded to order articles.
I did it two years ago but my work is a hatched job at best
I cannot uninstall as I modded after I installed.
If i had to do it again I would mod the files to my liking then install.