Customization > Blocks and Modifications

Sticky Articles (display specific articles first)

(1/4) > >>

ccbtimewiz:
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:

--- Code: --- if (empty($image))
--- End code ---

Replace with:

--- Code: --- /*
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))
--- End code ---

ramzesito:
Sorry, but in my case this code does not work,
article order didn't change

Did you test on SP 2.3.6?

ccbtimewiz:
Did you follow the instructions?

♦ Ninja ZX-10RR ♦:
I can confirm it works as it worked on my test site, nice block Sayaka ;)

ramzesito:
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:


--- Code: ---/*
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))
......

--- End code ---

it doesn't work... (
how can I diagnose a problem?

Navigation

[0] Message Index

[#] Next page

Go to full version