Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
uw_fdsu_theme_resp
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_fdsu_theme_resp
Commits
e62cc236
Commit
e62cc236
authored
2 years ago
by
Eric Bremner
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-5500: adding alternate link to listing pages
parent
20dc2054
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!70
Feature/istwcms 5500 adding rss feeds to listing pages
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
uw_fdsu_theme_resp.theme
+76
-1
76 additions, 1 deletion
uw_fdsu_theme_resp.theme
with
76 additions
and
1 deletion
uw_fdsu_theme_resp.theme
+
76
−
1
View file @
e62cc236
...
...
@@ -35,10 +35,15 @@ function uw_fdsu_theme_resp_preprocess_html(&$variables) {
$variables
[
'attributes'
][
'class'
][]
=
theme_get_setting
(
'wcms_colour_scheme'
,
'uw_fdsu_theme_resp'
)
?
theme_get_setting
(
'wcms_colour_scheme'
,
'uw_fdsu_theme_resp'
)
:
'org-default'
;
$variables
[
'uw_admin_page'
]
=
\Drupal
::
service
(
'uw_cfg_common.uw_analytics'
)
->
administrationPage
();
// Add the fav icons.
_uw_fdsu_theme_resp_add_favicons
(
$variables
);
// Get the route name.
$route_name
=
\Drupal
::
routeMatch
()
->
getRouteName
();
// Perform actions based on the route.
switch
(
$route_name
)
{
// Add Javascript only on the user login page.
case
'user.login'
:
$variables
[
'#attached'
][
'library'
][]
=
'uw_fdsu_theme_resp/user.login'
;
...
...
@@ -50,12 +55,51 @@ function uw_fdsu_theme_resp_preprocess_html(&$variables) {
$variables
[
'head_title'
][
'title'
]
=
t
(
'Reference author:'
)
.
' '
.
$variables
[
'head_title'
][
'title'
];
break
;
// T
e
h header/page title on keywords listing page browser
// Th
e
header/page title on keywords listing page browser
// tab shows "Reference keyword: " in front of the keyword.
case
'entity.bibcite_keyword.canonical'
:
$variables
[
'head_title'
][
'title'
]
=
t
(
'Reference keyword:'
)
.
' '
.
$variables
[
'head_title'
][
'title'
];
break
;
// Adding the alternate link to listing pages.
case
'view.uw_view_blogs.blog_page'
:
case
'view.uw_view_events.event_page'
:
case
'view.uw_view_news_items.news_page'
:
// Get the parameters from the URL.
$parameters
=
\Drupal
::
request
()
->
query
->
all
();
// Get the alternate link based on the route.
switch
(
$route_name
)
{
case
'view.uw_view_blogs.blog_page'
:
$link
=
_uw_fdsu_theme_resp_get_alternate_link
(
'uw_view_blogs'
,
'uw_public_blog_feed'
,
'Blogs feed'
);
break
;
case
'view.uw_view_events.event_page'
:
$link
=
_uw_fdsu_theme_resp_get_alternate_link
(
'uw_view_events'
,
'uw_public_event_feed'
,
'Events feed'
);
break
;
case
'view.uw_view_news_items.news_page'
:
$link
=
_uw_fdsu_theme_resp_get_alternate_link
(
'uw_view_news_items'
,
'uw_public_news_feed'
,
'News feed'
);
break
;
}
// Add the alternate link to the page.
$variables
[
'#attached'
][
'html_head_link'
][]
=
$link
;
break
;
}
// Get the current path.
...
...
@@ -72,6 +116,37 @@ function uw_fdsu_theme_resp_preprocess_html(&$variables) {
}
}
/**
* Function to get the alternate link.
*
* @param string $view_machine_name
* The machine name of the view.
* @param string $view_display_name
* The display name of the view.
* @param string $title
* The title of the alternate link.
*/
function
_uw_fdsu_theme_resp_get_alternate_link
(
string
$view_machine_name
,
string
$view_display_name
,
string
$title
)
{
// Get the URL to RSS feed.
$url
=
Url
::
fromRoute
(
'view.'
.
$view_machine_name
.
'.'
.
$view_display_name
);
$url
->
setOptions
([
'query'
=>
\Drupal
::
request
()
->
query
->
all
()]);
// Return the link for the alternate.
return
[
[
'rel'
=>
'alternate'
,
'href'
=>
$url
->
toString
(),
'title'
=>
$title
,
'type'
=>
'application/rss+xml'
,
]
];
}
/**
* Implements hook_preprocess_responsive_image().
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment