Get data from database

robiso edited this page Feb 22, 2018 · 11 revisions


  • can be used to get data from database.js
  • wCMS::get('pages', 'PAGENAME')->PARAM;

Explanation of PAGENAME and PARAM and how they can be used:

  • PAGENAME - name of the page you want to get data from. For this example, we will use the page about.
  • PARAM - page parameter. Available page parameters (for pages) are:
    • content
      • example: <?php echo wCMS::get('pages', 'about')->content; ?> returns content for page about
    • title
      • example: <?php echo wCMS::get('pages', 'about')->title; ?> returns title for page about
    • description
      • example: <?php echo wCMS::get('pages', 'about')->description; ?> returns description for page about
    • keywords
      • example: <?php echo wCMS::get('pages', 'about')->keywords; ?> returns keywords for page about
    • other PARAMs are available with plugins (such as additional contents)

Get dynamic page content

  • <?php echo wCMS::page('content'); ?> returns content for current page
  • <?php echo wCMS::page('title'); ?> returns title for current page
  • <?php echo wCMS::page('keywords'); ?> returns keywords for current page
  • <?php echo wCMS::page('description'); ?> returns description for current page

How to get other data (data unrelated to pages)

Getting other data using the wCMS get function wCMS::get('config', 'PARAM'); (notice how the syntax is shorter than fetching page data shown above).

  • Available PARAMs for config
    • dbVersion
      • example: <?php echo wCMS::get('config', 'dbVersion'); ?> returns database version
    • siteTitle
      • example: <?php echo wCMS::get('config', 'siteTitle'); ?> returns main website title
    • theme
      • example: <?php echo wCMS::get('config', 'theme'); ?> returns current chosen theme
    • defaultPage
      • example: <?php echo wCMS::get('config', 'defaultPage'); ?> returns the default home page
    • login
      • example: <?php echo wCMS::get('config', 'login'); ?> returns the default login URL
    • password
      • example: <?php echo wCMS::get('config', 'password'); ?> returns a hashed password
    • menuItems
      • example: <?php echo wCMS::get('config', 'menuItems'); ?> returns each menu item as list item <li><a href="//">home</a></li>

Helpful links

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.