Topics

Content

ImpressPages provides an API to access all website's content. Use ipContent() function to get information or manipulate languages, menus and pages.

GET languAge information

<?php 
$language = ipContent()->getCurrentLanguage();  // get current language
$language = ipContent()->getLanguage($languageId); // get language by id
$languages = ipContent()->getLanguages(); // get all website's languages
?>

GET Information about current active page

<?php 
echo ipContent()->getTitle(); //current page title
echo ipContent()->getDescription(); //current page description
echo ipContent()->getKeywords(); //current page keywords
?>

Get a breadcrumb

<?php ipContent()->getBreadcrumb() ?>

Gives you an array of Page elments to genearte a breadcrumb.

Get children of current page

<?php ipContent()->getChildren(); ?>

GET menu

<?php var_dump(ipContent()->getPageMenu()); // Returns Ip\Page object
?>

 Use this code to check if current apge is in menu1.

<?php
if (ipContent()->getPageMenu() == 'menu1') {
    //current page is one of pages in menu1
}
?>

Update page SETTINGS

<?php
//all array items are optional. Set just those that need to be changed.
$params = array(
    'title' => 'My page',
    'metaTitle' => 'My page',
    'keywords' => 'my keywords',
    'description' => 'My page description',
    'createdAt' => '2013-12-31',
    'updatedAt' => '2013-12-31',
    'redirectUrl' => 'http://www.example.com',
    'isVisible' => true,
    'isDisabled' => false,
    'isSecured' => false,
    'isBlank' => false,
    'alias' => 'my-page',
    'layout' => 'home.php',
    'urlPath' => 'my-page'
);

ipContent()->updatePage($pageId, $params);

Add a new language

<?php ipContent()->addLanguage('Spanish', 'ES', 'es', 'es', true); ?>

Create a menu, then add a page

$menuAlias = \Ip\Internal\Pages\Service::createMenu('en', 'My_menu', 'My menu');
$menu = \Ip\Internal\Pages\Service::getMenu('en', $menuAlias);
$pageId = ipContent()->addPage($menu['id'], 'First page');
comments powered by Disqus