You are here

function acquia_lift_personalize_agent_page_alter in Acquia Lift Connector 7

Implements hook_personalize_agent_page_alter().

File

./acquia_lift.module, line 2425
acquia_lift.module Provides Acquia Lift-specific personalization functionality.

Code

function acquia_lift_personalize_agent_page_alter(&$build, &$agent_data) {

  // Add a link to return to the page for variations if this is a page variation
  // campaign.
  module_load_include('inc', 'acquia_lift', 'acquia_lift.admin');
  module_load_include('inc', 'acquia_lift', 'acquia_lift.page_variations');
  $agent_instance = personalize_agent_load_agent($agent_data->machine_name);
  if ($agent_instance instanceof AcquiaLiftPageVariationInterface) {
    $build['return_link'] = array(
      'link' => array(
        '#type' => 'link',
        '#title' => t('Go to %campaign campaign', array(
          '%campaign' => $agent_data->label,
        )),
        '#href' => acquia_lift_page_variation_get_path($agent_data->machine_name, $agent_data->machine_name),
        '#options' => array(
          'html' => TRUE,
        ),
      ),
      '#weight' => -10,
    );

    // Fix the weights for re-sort.
    $build['option_sets']['#access'] = FALSE;
    $build['mvt']['#access'] = FALSE;
    $build['personalize_messages']['#weight'] = 10;
    $build['agent']['#weight'] = 20;
    $build['goals']['#weight'] = 40;
  }
}