[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
Developer
Posts: 173
Joined: Fri Sep 19, 2014 1:53 pm

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

Post by turboblack »

http://t0rba.tk/ my Russian-language research WonderCMS engine 8-) & also http://woua.pp.ua/ in Ukrainian
User avatar
wdj
Developer
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