Skip to content

Commit

Permalink
PLANET-7072 Set PageType DLV for High Level & Deep Dive Topic pages (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarsdeshmukh authored Sep 13, 2023
1 parent 45eea6e commit 52ad0ff
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function __construct($pid = null)
public function set_data_layer(): void
{
$is_new_ia = !empty(planet4_get_option('new_ia'));
$new_ia_child_page_DLV = $this->get_new_ia_child_page_DLV();

if (is_front_page()) {
$this->data_layer['page_category'] = 'Homepage';
Expand All @@ -85,6 +86,8 @@ public function set_data_layer(): void
$this->data_layer['page_category'] = 'Actions';
} elseif ($is_new_ia && $this->is_about_us_page()) {
$this->data_layer['page_category'] = 'About Us Page';
} elseif ($is_new_ia && $new_ia_child_page_DLV) {
$this->data_layer['page_category'] = $new_ia_child_page_DLV;
} else {
$this->data_layer['page_category'] = 'Default Page';
}
Expand Down Expand Up @@ -209,6 +212,30 @@ public function is_about_us_page(): bool
return absint($act_page_id) === $this->id;
}

/**
* Checks if post is the children of Get Informed page, and return DLV.
*
* @return String The dataLayer value for get informed child page.
*/
public function get_new_ia_child_page_DLV(): string
{
$get_informed_page_id = (int) planet4_get_option('get_informed_page');

if (!$get_informed_page_id) {
return '';
}

$parents = get_post_ancestors($this->id);

if (1 === count($parents) && $parents[0] === $get_informed_page_id) {
return 'High Level Topic';
}
if (2 === count($parents) && $parents[1] === $get_informed_page_id) {
return 'Deep Dive Topic';
}
return '';
}

/**
* Loads in context information on the navigation links for Issue pages relevant to current Post's categories.
*/
Expand Down

0 comments on commit 52ad0ff

Please sign in to comment.