Skip to content

Get data from database

Robert Isoski edited this page Dec 7, 2019 · 12 revisions

$Wcms->get()

  • can be used to get data from database.js
  • $Wcms->get('pages', 'PAGENAME')->PARAM;
    • Param examples: title, content, keywords, description

WonderCMS 3.0.0 and above

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->('config', 'dbVersion'); ?> returns database version
    • siteTitle
      • example: <?php echo $Wcms->('config', 'siteTitle'); ?> returns main website title
    • theme
      • example: <?php echo $Wcms->('config', 'theme'); ?> returns current chosen theme
    • defaultPage
      • example: <?php echo $Wcms->('config', 'defaultPage'); ?> returns the default home page
    • login
      • example: <?php echo $Wcms->('config', 'login'); ?> returns the default login URL
    • password
      • example: <?php echo $Wcms->('config', 'password'); ?> returns hashed password
    • menuItems
      • example: <?php echo $Wcms->('config', 'menuItems'); ?> returns each menu item as list item <li><a href="//example.com/home">home</a></li>

WonderCMS 2.7.0 and below

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="//example.com/home">home</a></li>

Helpful links

Clone this wiki locally