a random post on main page?
- Edi
- Site Admin
- Posts: 3121
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 54 times
- Been thanked: 78 times
- Contact:
There is a thread about it:
Page static with random
Perhaps the code has to be adapted a little bit for Bludit 3.9.2.
Page static with random
Perhaps the code has to be adapted a little bit for Bludit 3.9.2.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
- Edi
- Site Admin
- Posts: 3121
- Joined: Sun Aug 09, 2015 5:01 pm
- Location: Zurich
- Has thanked: 54 times
- Been thanked: 78 times
- Contact:
There are some changes. You can use the following:
Code: Select all
<?php
global $pages;
$onlyPublished = true;
$pageNumber = 1;
$publishedPages = $pages->getList($pageNumber, $numberOfItems, $onlyPublished);
$random_key=array_rand($publishedPages);
$random_content = $publishedPages[$random_key];
foreach ($publishedPages as $pageKey){
if ($pageKey == $random_content ) {
$page = new Page($pageKey);
echo $page->title();
echo $page->permalink();
echo $page->content();
}
}
?>
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets