Skip to content

Commit

Permalink
OEL-2767: Override templates to provide styling for subscriptions pag…
Browse files Browse the repository at this point in the history
…es and links.
  • Loading branch information
brummbar committed Feb 16, 2024
1 parent d168189 commit 3ec646d
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
12 changes: 12 additions & 0 deletions oe_whitelabel.theme
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,15 @@ function oe_whitelabel_library_info_alter(array &$libraries, string $extension):
// The slim.select css is already present in the parent theme.
unset($libraries['slim.select']['css']);
}

/**
* Implements hook_preprocess_HOOK() for user subscription page.
*/
function oe_whitelabel_preprocess_oe_subscriptions_user_subscriptions_page(&$variables) {
// The content banner embeds the current page title, so we need to retrieve
// it manually.
$variables['page_title'] = \Drupal::service('title_resolver')->getTitle(
\Drupal::service('request_stack')->getCurrentRequest(),
\Drupal::service('current_route_match')->getCurrentRouteMatch()->getRouteObject()
);
}
42 changes: 42 additions & 0 deletions templates/flag/flag--subscribe-node.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{#
/**
* @file
* Default theme implementation for flag links.
*
* Available functions:
* - flagcount(flag, flaggable) gets the number of flaggings for the given flag and flaggable.
*
* Available variables:
* - attributes: HTML attributes for the link element.
* - title: The flag link title.
* - action: 'flag' or 'unflag'
* - flag: The flag object.
* - flaggable: The flaggable entity.
*/
#}
{% apply spaceless %}
{# Attach the flag CSS library.#}
{{ attach_library('flag/flag.link') }}

{# Depending on the flag action, set the appropriate action class. #}
{% if action == 'unflag' %}
{% set action_class = 'action-unflag' %}
{% else %}
{% set action_class = 'action-flag' %}
{% endif %}

{# Set the remaining Flag CSS classes. #}
{%
set classes = [
'flag',
'flag-' ~ flag.id()|clean_class,
'js-flag-' ~ flag.id()|clean_class ~ '-' ~ flaggable.id(),
action_class
]
%}

{# Set nofollow to prevent search bots from crawling anonymous flag links #}
{% set attributes = attributes.setAttribute('rel', 'nofollow').addClass(['w-auto', 'btn', 'btn-outline-primary', 'btn-md']) %}

<span class="{{classes|join(' ')}}"><a{{ attributes }}>{{ title }}</a></span>
{% endapply %}
11 changes: 11 additions & 0 deletions templates/subscriptions/oe-subscriptions-anonymous-link.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{#
/**
* @file
* Template override for the anonymous subscribe link.
* Available variables:
* - link: The link text.
* - url: The link destination.
* - attributes: associative array containing the properties of the element.
*/
#}
{{ link(title, url, attributes.addClass(['btn', 'btn-outline-primary', 'btn-md'])) }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{#
/**
* @file
* Template override for for user subscriptions page.
* Available variables:
* - introduction: The page introduction.
* - elements: Other elements that compose the page. Usually it will contain the form.
*/
#}
{{ pattern('content_banner', {
'background': 'gray',
'title': page_title,
'content': introduction,
}) }}
{{ elements }}

0 comments on commit 3ec646d

Please sign in to comment.