You are here

public function InstapageCmsPluginPageModel::check in Instapage plugin 8.3

Same name and namespace in other branches
  1. 7.3 core/models/InstapageCmsPluginPageModel.php \InstapageCmsPluginPageModel::check()

Checks (and returns) if a landing page should be displayed instead of normal content served by CMS.

Parameters

string $type Type of page to check ('page', 'home' or '404').:

string $slug Slug to check. Default: ''.:

Return value

string HTML to display.

File

core/models/InstapageCmsPluginPageModel.php, line 394

Class

InstapageCmsPluginPageModel
Class responsible for managing the landing pages.

Code

public function check($type, $slug = '') {
  if (!InstapageCmsPluginConnector::isHtmlReplaceNecessary()) {
    return;
  }
  $result = $this
    ->getByType($type, $slug, array(
    'instapage_id',
    'slug',
    'enterprise_url',
  ));
  if (!$result) {
    return;
  }
  $result->slug = $result->slug ? $result->slug : $slug;
  $result->enterprise_url = $result->enterprise_url ? $result->enterprise_url : InstapageCmsPluginConnector::getHomeURL() . '/' . $result->slug;
  $result->enterprise_url = rtrim($result->enterprise_url, '/');
  return $result;
}