Skip to content

Get data from database

robiso edited this page Jul 23, 2017 · 12 revisions

How to get data from database.js

Short examples for getting data using the wCMS get function wCMS::get('pages', 'PAGENAME')->PARAM

  • PAGENAME is the actual page name of the page you want to get the data from
  • PARAM is the page parameter. Available PARAMs:
    • content
    • title
    • description
    • keywords
    • other PARAMs available with plugins such as additional contents

Examples A - get specific/static page content (editing of theme.php required)

Example A1: Get the content for page about from database.js

<?php echo wCMS::get('pages', 'about')->content; ?>

Example A2: Get title for page about

<?php echo wCMS::get('pages', 'about')->title; ?>

Example A3: Get keywords for page about

<?php echo wCMS::get('pages', 'about')->keywords; ?>

Example A4: Get description for page about

<?php echo wCMS::get('pages', 'about')->description; ?>

Examples B - get dynamic page content (editing of theme.php required)

Example B1: Get content for current page from database.js

<?php echo wCMS::page('content'); ?>

Example B2: Get current page title

<?php echo wCMS::page('title'); ?>

Example B3: Get current page keywords

<?php echo wCMS::page('keywords'); ?>

Example B4: Get current page description

<?php echo wCMS::page('description'); ?>
Clone this wiki locally