Skip to content
This repository was archived by the owner on Feb 21, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c9daf2d
init commit
patrickbrown-io Jul 11, 2022
440cefa
wip: category, tag, and setting passed to dom via data attributes
patrickbrown-io Jul 12, 2022
5915672
wip: initial related articles js
patrickbrown-io Jul 13, 2022
65ae10d
wip: init commit and linking of stylesheet
patrickbrown-io Jul 14, 2022
1918b69
wip: getting taxonomy ids for cats and tags for api call
patrickbrown-io Jul 15, 2022
4a24d0b
wip: api url for tags and categories working
patrickbrown-io Jul 18, 2022
e2ca741
wip: url properly fetches articles with categories OR tags that are p…
patrickbrown-io Jul 18, 2022
89b7bee
wip: slight refactor to grab categories first and check. adjusted tem…
patrickbrown-io Jul 19, 2022
00528de
wip: filters out the current article from the lineup of related articles
patrickbrown-io Jul 20, 2022
fe61e52
wip: initial link css and temp styles
patrickbrown-io Jul 20, 2022
7690240
wip: adjusted render styling, more adjustment needed. some cleanup
patrickbrown-io Jul 20, 2022
5901241
final styling pass
patrickbrown-io Jul 21, 2022
e31b228
wip: scoring works, added article images, css fix, working on 2nd cal…
patrickbrown-io Jul 21, 2022
b00f1f6
wip: tags seem to be working if less than 3 are gathered from categories
patrickbrown-io Jul 21, 2022
56dc6c5
wip: second call seems to be working, needs testing
patrickbrown-io Jul 21, 2022
cadfd8a
wip: code cleanup, need to add exclusion filters
patrickbrown-io Jul 22, 2022
79e2aa6
wip: passing tag and category exclusion data via twig
patrickbrown-io Jul 25, 2022
164d92f
wip: exclusion filters on categories sort of working
patrickbrown-io Jul 25, 2022
1c4aeeb
wip: Category check working with excluded categories
patrickbrown-io Jul 26, 2022
bbf3ec1
Tag filters working on both calls, template cleanup
patrickbrown-io Jul 26, 2022
9b97072
Javascript cleanup
patrickbrown-io Jul 26, 2022
8b052ec
merge main
patrickbrown-io Jul 26, 2022
e454bd3
minor: fix to Article Category tempalate
Jul 28, 2022
bf62456
wip: using focal image thumbnail
patrickbrown-io Jul 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions css/ucb-related-articles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.ucb-related-articles-block{
display: none;
}

.ucb-article-card-img {
max-width: 100%;
height: auto;
}

.ucb-article-card-data {
display: flex;
flex-direction: column;
}

.ucb-article-card {
margin-bottom: 2em;
}

.ucb-related-article-card-body{
font-size: 85%;
}
408 changes: 408 additions & 0 deletions js/ucb-related-articles.js

Large diffs are not rendered by default.

27 changes: 26 additions & 1 deletion templates/content/node--ucb-article.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

{{ attach_library('ucb2021_base/ucb-page') }}
{{ attach_library('ucb2021_base/ucb-article') }}
{{ attach_library('ucb2021_base/ucb-related-articles') }}

{%
set classes = [
Expand All @@ -18,6 +19,7 @@ view_mode ? 'node--view-mode-' ~ view_mode|clean_class,
]
%}


{% set social_share_button_position = drupal_config('ucb2021_base.settings', 'ucb_social_share_position')%}
{% set social_share_class = "" %}
{% if social_share_button_position == "0"%}
Expand All @@ -36,9 +38,27 @@ view_mode ? 'node--view-mode-' ~ view_mode|clean_class,

{#Dummy variable to ensure that all content tags are set for caching purposes#}
{% set content_render = content|render %}

{% if not content.field_ucb_article_external_url|render %}

{# Related Articles setup #}
{# {% set showRelated = ''%} #}

{% set myTags %}
{{ content.field_ucb_article_tags }}
{% endset %}
{% set myCats %}
{{ content.field_ucb_article_categories }}
{% endset %}
{% set showRelated %}
{{content.field_ucb_related_articles_parag.0}}
{% endset %}
{# {% if show_Related != "Off" %}
{% set showRelated = true %}
{% endset %}
{% endif %} #}

<article{{attributes.addClass(classes)}}>

<div class="container ucb-article" itemscope itemtype="https://schema.org/Article">
{{ label }}
{# TO DO - conditional render #}
Expand Down Expand Up @@ -83,8 +103,13 @@ view_mode ? 'node--view-mode-' ~ view_mode|clean_class,
{{ content.field_ucb_article_tags }}
</div>
{% endif %}
{# TO DO -- Related Articles Block #}
<div class="ucb-related-articles-block" data-catsjson="{{content.field_ucb_article_categories| json_encode(constant('JSON_PRETTY_PRINT'))}}" data-tagsjson="{{ content.field_ucb_article_tags| json_encode(constant('JSON_PRETTY_PRINT')) }}"data-relatedshown="{{showRelated|striptags|trim}}"data-tags="{{myTags|render|striptags|trim|replace({"\n": "", "\r": "", "\t": ""})}}"data-cats="{{myCats|render|striptags|trim|replace({"\n": "", "\r": "", "\t": ""})}}">
{{content.field_ucb_related_articles_parag}}
</div>
</div>
</article>

{% else %}
{% if not user.hasPermission('update node') %}
{# redirect non-authenticated users to the specified URL #}
Expand Down
2 changes: 2 additions & 0 deletions templates/field/field--field-ucb-article-categories.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
#}

{% for item in items %}
<div>
{{ item|render }}
</div>
{% endfor %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% for item in items %}
<h2>{{item}}</h2>
{% endfor %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% set excludeCategories = '' %}
{% set myExCategories =
items|render|striptags|trim|split(' ')
%}


{% for item in myExCategories %}
{% if item %}
{% if loop.last %}
{% set excludeCategories = excludeCategories ~ (item|trim) %}
{% else %}
{% set excludeCategories = excludeCategories ~ (item|trim) ~ ',' %}
{% endif %}
{% endif %}
{% endfor %}

<div id="ucb-related-articles-exclude-categories" data-excludeCategories="{{excludeCategories}}"></div>


Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% set excludeTags = '' %}
{% set myExTags =
items|render|striptags|trim|split('')
%}

{% for item in myExTags %}
{% if item %}
{% if loop.last %}
{% set excludeTags = excludeTags ~ (item|trim) %}
{% else %}
{% set excludeTags = excludeTags ~ (item|trim) ~ ',' %}
{% endif %}
{% endif %}
{% endfor %}

<div id="ucb-related-articles-exclude-tags" data-excludeTags="{{excludeTags}}"></div>
9 changes: 8 additions & 1 deletion ucb2021_base.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,14 @@ ucb-article-list:
theme:
css/ucb-article-list.css: {}

ucb-related-articles:
version: 1.x
js:
js/ucb-related-articles.js: {}
css:
theme:
css/ucb-related-articles.css: {}
ucb-site-contact-info-footer:
css:
theme:
css/ucb-site-contact-info-footer.css: {}
css/ucb-site-contact-info-footer.css: {}