[SOLVED] How to get list of pages from database.js

Post Reply
mike
Posts: 1
Joined: Wed Jun 14, 2017 7:56 pm

[SOLVED] How to get list of pages from database.js

Post by mike »

I am planning to setup simple blog using wondercms and wondering how to get list of pages/posts from database.js.
My blog will have two unique pages,
1) List of posts (title, short description)
2) page where full text of a single post will be displayed.
User avatar
turboblack
Posts: 198
Joined: Fri Sep 19, 2014 1:53 pm

Re: How to get list of pages from database.js

Post by turboblack »

http://old.net.eu.org/ Get ready to hamsterization! 8-) code takes less than a kilobyte! shock!
https://github.com/turboblack/HamsterCMS new version for PHP 8 with new templates
User avatar
wdj
Posts: 1
Joined: Wed Apr 12, 2017 1:40 pm

Re: How to get list of pages from database.js

Post by wdj »

Hi mike,

you are searching for something like this:

Code: Select all

<?php if (wCMS::$currentPage == 'home'): ?> <!-- On which page it will be displayed -->
        <div class="container marginTop20">
            <?php foreach ( wCMS::db()->pages as $pageName => $page ): ?> <!-- loop though all pages -->
            <div class="col-xs-12 col-md-4">
                <div><a href="<?=$pageName?>"><?=$page->title; ?></a></div>
	            <div><?=$page->description; ?></div>
                <a href="<?=$pageName?>">more...</a>
            </div>
            <?php endforeach; ?>
        </div>
	<?php endif ?>
You have to put it in your theme.php.

Regards

Pascal
Post Reply