Created
January 14, 2019 20:58
-
-
Save luisfc/941f2f6b618ae15a7b96abe7225f4a5d to your computer and use it in GitHub Desktop.
mycustom_theme d8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Functions to support theming in the Pattern Lab theme. | |
*/ | |
function mycustom_theme_preprocess_page(array &$variables) { | |
// Prepare the intro values | |
$variables['intro_logo'] = file_url_transform_relative(file_create_url(theme_get_setting('intro_logo', 'mycustom_theme'))); | |
$variables['quotes'] = theme_get_setting('quotes', 'mycustom_theme'); | |
// Prepare the footer values | |
$variables['footer_logo'] = file_url_transform_relative(file_create_url(theme_get_setting('footer_logo', 'mycustom_theme'))); | |
$variables['facebook_link'] = theme_get_setting('facebook_link', 'mycustom_theme'); | |
$variables['twitter_link'] = theme_get_setting('twitter_link', 'mycustom_theme'); | |
// Prepare the phone contact values | |
$variables['us_phone'] = theme_get_setting('us_phone', 'mycustom_theme'); | |
$variables['cr_phone'] = theme_get_setting('cr_phone', 'mycustom_theme'); | |
$variables['mx_phone'] = theme_get_setting('mx_phone', 'mycustom_theme'); | |
$variables['au_phone'] = theme_get_setting('au_phone', 'mycustom_theme'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mycustom_theme_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface &$form_state, $form_id = NULL) | |
{ | |
/** | |
* Implements hook_theme_form_system_theme_settings_alter(). | |
*/ | |
$form['mycustom_theme_settings']['intro'] = array( | |
'#type' => 'details', | |
'#title' => t('Intro'), | |
'#description' => t('Configuration for intro on homepage.'), | |
'#open' => TRUE, // Controls the HTML5 'open' attribute. Defaults to FALSE. | |
); | |
$form['mycustom_theme_settings']['intro']['intro_logo'] = array( | |
'#type' => 'textfield', | |
'#title' => t('Path to custom logo for intro'), | |
'#default_value' => theme_get_setting('intro_logo', 'mycustom_theme'), | |
'#description' => t("Examples: <code>logo.svg</code> (for a file in the public filesystem), <code>public://logo.svg</code>, or <code>themes/custom/mycustom_theme/logo.svg</code>."), | |
); | |
$form['mycustom_theme_settings']['intro']['quotes'] = array( | |
'#type' => 'textfield', | |
'#title' => t('Quotes Intro'), | |
'#default_value' => theme_get_setting('quotes', 'mycustom_theme'), | |
'#description' => t("Please provide the quotes for the intro separated by commas (i.e Consulting, Theming, Development)."), | |
); | |
$form['mycustom_theme_settings']['footer'] = array( | |
'#type' => 'details', | |
'#title' => t('Footer'), | |
'#description' => t('Configuration for footer.'), | |
'#open' => TRUE, // Controls the HTML5 'open' attribute. Defaults to FALSE. | |
); | |
$form['mycustom_theme_settings']['footer']['footer_logo'] = array( | |
'#type' => 'textfield', | |
'#title' => t('Path to custom logo for intro'), | |
'#default_value' => theme_get_setting('footer_logo', 'mycustom_theme'), | |
'#description' => t("Examples: <code>logo.svg</code> (for a file in the public filesystem), <code>public://logo.svg</code>, or <code>themes/custom/mycustom_theme/logo.svg</code>."), | |
); | |
$form['mycustom_theme_settings']['footer']['facebook_link'] = array( | |
'#type' => 'url', | |
'#title' => t('Facebook'), | |
'#default_value' => theme_get_setting('facebook_link', 'mycustom_theme'), | |
'#description' => t("Please provide link of Facebook site"), | |
); | |
$form['mycustom_theme_settings']['footer']['twitter_link'] = array( | |
'#type' => 'url', | |
'#title' => t('Twitter'), | |
'#default_value' => theme_get_setting('twitter_link', 'mycustom_theme'), | |
'#description' => t("Please provide link of Twitter site"), | |
); | |
$form['mycustom_theme_settings']['phones'] = array( | |
'#type' => 'details', | |
'#title' => t('Contact Phones'), | |
'#description' => t('Please provide contact phones'), | |
'#open' => TRUE, // Controls the HTML5 'open' attribute. Defaults to FALSE. | |
); | |
$form['mycustom_theme_settings']['phones']['us_phone'] = array( | |
'#type' => 'tel', | |
'#title' => t('US Phone'), | |
'#default_value' => theme_get_setting('us_phone', 'mycustom_theme'), | |
); | |
$form['mycustom_theme_settings']['phones']['cr_phone'] = array( | |
'#type' => 'tel', | |
'#title' => t('CR Phone'), | |
'#default_value' => theme_get_setting('cr_phone', 'mycustom_theme'), | |
); | |
$form['mycustom_theme_settings']['phones']['mx_phone'] = array( | |
'#type' => 'tel', | |
'#title' => t('MX Phone'), | |
'#default_value' => theme_get_setting('mx_phone', 'mycustom_theme'), | |
); | |
$form['mycustom_theme_settings']['phones']['au_phone'] = array( | |
'#type' => 'tel', | |
'#title' => t('AU Phone'), | |
'#default_value' => theme_get_setting('au_phone', 'mycustom_theme'), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment