You are here

public function InstapageCmsPluginPageModel::getByType in Instapage plugin 8.3

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

Gest the single page based on type and slug.

Parameters

string $type Type of the page. ('page'|'home'|'404').:

string $slug Slug of the page.:

array $fields List of fields to retrieve. Default: array('*').:

Return value

object Page object.

2 calls to InstapageCmsPluginPageModel::getByType()
InstapageCmsPluginPageModel::check in core/models/InstapageCmsPluginPageModel.php
Checks (and returns) if a landing page should be displayed instead of normal content served by CMS.
InstapageCmsPluginPageModel::migrateDeprecatedData in core/models/InstapageCmsPluginPageModel.php
Migrates the depracated pages to current DB structure.

File

core/models/InstapageCmsPluginPageModel.php, line 117

Class

InstapageCmsPluginPageModel
Class responsible for managing the landing pages.

Code

public function getByType($type, $slug = '', $fields = array(
  '*',
)) {
  $db = InstapageCmsPluginDBModel::getInstance();
  $sql = 'SELECT ' . implode(', ', $fields) . ' FROM ' . $db->pagesTable . ' WHERE type = %s';
  if ($slug) {
    $sql = $sql . ' AND slug = %s';
    return $db
      ->getRow($sql, $type, $slug);
  }
  else {
    return $db
      ->getRow($sql, $type);
  }
}