Documentation 2.x and 3.x

ImpressPages URL structure

ImpressPages CMS has SEO friendly URL structure by default. You don't need to configure anything. Default URL structure is: http://www.example.com/language/zone/page/sub-page/...

"language" part of URL

Usually language part of URL consists of two letters (eg. "en"). You can change your language URL to anything you like in administration panel tab Standard -> Languages.

ImpressPages languages administration

If your website has only one language and you don't need it to be displayed in URL, you can strip it out.

Steps on how to remove language part from URL:

  • login to administration panel
  • go to Developer -> Modules config tab
  • select "languages" on the left sidebar
  • click yellow folder icon near record "Options" on the right
  • click edit icon near the record "Multilingual site"
  • uncheck the value field and press "Save".
ImpressPages CMS turn off language URL

This will generate a link to current language. Usually used to generate "home" link.

<?php
echo $site->generateUrl();
?>

To generate link to another language, pass language code as a first variable:

<?php
echo $site->generateUrl('en');
?>

You can get all website languages using $site->getLanguages(). Read ImpressPages API. And it would be the best if you use $particularLanguage->getCode() instead of hardcoded string.

"zone" part of URL

Zone part of URL defines the zone in which the page exists. Usually each menu is in separate zone. By default top menu is in zone called "top" and left  menu is in zone called "left". That means that all pages in top menu will have URL prefix "top". You can change that to anything else but you can't remove it.

To change URL part of zone:

  • open administration panel
  • go to Standard -> SEO
  • click edit icon on zone record that you like to change
  • replace "url" value to anything you like (avoid special characters)
ImpressPages SEO tab

This code will genereate a link to root of current zone. You can pass any zone that exists in your Developer -> Zones tab.

<?php
$site->generateUrl(null, 'zoneName'); //replace zoneName to actual zone key. Null means that it will piont to the current language.
?>

Page url

Each zone (read about zones) has a method getElements() to return all elements (pages) that belongs to it. And each element knows how to generate a link to it self and next / previous neighbor. Here are some handy functions:

global $site;

$site->getCurrentElement()->getLink(); //get link to current page

$site->getCurrentElement->getNextElement()->getLink(); //link to next page

$site->getCurrentElement->getPreviousElement ()->getLink(); //link to previous page

You should never generate links to pages manually. Always use $site->generateUrl, when generating a link to particular language or zone. And always use getLink method to get link to particular page. Read ImpressPages API how to get required page Element object.

Generate custom URL

Here you will find code snippets on how to generate any URL using generateUrl function. It is mandatory to use this function as it generates URLs differently in management mode.

http://www.impresspages.org/docs2/working-with-themes2/frequently-used-code-1/

URL and GET vars

If you are creating some plugin that extends Zone class and add custom pages to ImpressPages system, you will need to get data about current url. Use system functions instead of manually parsing the url.

This abstraction layer enables to change URL structure without influencing the code of plugins.

Following code will give you an array of all URL parts that goes after www.example.com/en/zone_key/:

<?php

global $site;
$site->getUrlVars();

?>

Fore example, if current URL is

http://example.com/en/left/page/subpage/subsubpage/?var1=val1&var2=val2

$site->getUrlVars() will return an array

('page', 'subpage', 'subsubpage')

Don't access get vars using $_GET array. Use following function instead:

<?php

global $site;
$site->getGetVars();

?>

Write a comment

You must be logged in to comment.