Page 1 of 1

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

Posted: Wed Jun 14, 2017 8:03 pm
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.

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

Posted: Thu Jun 15, 2017 4:30 pm
by turboblack

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

Posted: Fri Jun 16, 2017 11:37 pm
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