K
K
kiska-x2021-03-03 19:20:28
URL Handling
kiska-x, 2021-03-03 19:20:28

(DLE) How to make a redirect from a category to a random news item that is in a child (sub) category?

Hello everyone, plz tell me!
How to make a redirect from a category to a full news item that is in the same category, the only thing is that the desired news item is also in a subcategory.
It turns out that there is this:

MAIN CATEGORY:
1 subcategory (posts in it)
2 subcategory (posts in it)
3 subcategory (posts in it)
4 subcategory (posts in it)
and so on ....

And I need the redirect to be random , that is, for random news, but which belongs to any subcategory.

If it's already easier, then it should be like this:
Click on a category and go to a random news item that is in a subcategory of this main category.

Hope someone can help me.

I have a kind of hack, a redirect to random news, but it redirects to any post on the site. Below is the code, can anyone change it?

query("SELECT COUNT(*) FROM ".PREFIX ."_post");
$row = $db->get_row();

$offset = mt_rand(0, $row['COUNT(*)']-1);
$db->query("SELECT * FROM ".PREFIX ."_post LIMIT 1 OFFSET $offset");

$row = $db->get_row();
preg_match_all( '| $height) {
$fltRatio = floatval($maxWidth / $width);
} else {
$fltRatio = floatval($maxHeight / $height);
}

$intNewWidth = intval($fltRatio * $width);
$intNewHeight = intval($fltRatio * $height);

if($imgclck) {
$pic = '

';

}

} else {$img = '';}

$news_r = ''.ucfirst($row['title']).'';
if ($pic != '') {$news_r .= '
'.$pic;}

if (strlen($story) >= 0) {$news_r .= '
'.substr($story,0,$kol) .'...
Watch random anime';}

echo $news_r;
header("Location: $full_link")

?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question