-
Notifications
You must be signed in to change notification settings - Fork 0
Site maintenance notes
Sarah Jones edited this page Sep 6, 2024
·
9 revisions
- This site is hosted on AWS and uses Cloudfront as the CDN. When you update something on the site, you do have to invalidate the cache if you want to see the updates immediately. If you do not have access to AWS, you should ask someone who does.
-
https://www.drupal.org/docs/updating-drupal/updating-modules-and-themes-using-composer
composer update "drupal/*" --with-all-dependencies vendor/bin/drush updatedb vendor/bin/drush cache:rebuild
-
https://www.drupal.org/docs/develop/using-composer/manage-dependencies#patches
- As of 28 Nov 2023, version 2 does not apply core patches correctly
- Remember to use
composer require cweagans/composer-patches:~1.0 --update-with-dependencies
as advised by the docs for now
- If adding a child link to a top-level menu item for the first time, check that the “Show as expanded” is checked, this will add the corresponding CSS class to the menu item such that the dropdown functionality works as intended (otherwise it will just link directly to whatever the href on the link is)
-
Remember that
{{ dump() }}
is your best friend -
If your image files are managed using the Media module:
{% set svgUrl = file_url(content.field_text_block_image[0]['#media'].field_media_svg.entity.uri.value) %} {% set svgAlt = content.field_text_block_image[0]['#media'].field_media_svg.alt %} {% set imageUrl = file_url(content.field_text_block_image[0]['#media'].field_media_image.entity.uri.value) %} {% set imageAlt = content.field_text_block_image[0]['#media'].field_media_image.alt %} {% if svgUrl|default(null) %} <img src="{{ svgUrl }}" alt="{{ svgAlt }}"> {% elseif imageUrl|default(null) %} <img src="{{ imageUrl }}" alt="{{ imageAlt }}"> {% endif %}
-
For templates using Display Suite (e.g. ds-reset--node-article-teaser.html.twig):
{% set svgUrl = file_url(content.field_feature_image['#items'].entity.field_media_svg.entity.uri.value) %} {% set svgAlt = content.field_feature_image['#items'].entity.field_media_svg.alt %} {% set imageUrl = file_url(content.field_feature_image['#items'].entity.field_media_image.entity.uri.value) %} {% set imageAlt = content.field_feature_image['#items'].entity.field_media_image.alt %} {% if svgUrl|default(null) %} <img src="{{ svgUrl }}" alt="{{ svgAlt }}"> {% elseif imageUrl|default(null) %} <img src="{{ imageUrl }}" alt="{{ imageAlt }}"> {% endif %}
-
If you want the markup to contain field formatting choices made from the Manage display interface, then you’ll have to use
{{ content.FIELD_NAME.ETC }}
, but note that there will be a wrapping<div>
around the field -
If you just want the pure value, then you’ll want to use
{{ node.FIELD_NAME.0.value|raw }}
but occasionally you’ll have to format the field in the template yourself (like dates)
- In general, nodes will use only a single view mode, with the layout set to None
- An additional view mode for nodes that use view displays will be Teaser
- When layout is set to None, we are unable to control the visibility of the node title, so if the title is required to be rendered, we will use the Display Suite provided Reset layout, which exposes more fields for rendering.
- Use the No classes option under Entity classes, because our custom templates do not render any programmatic classes anyway
- We use the Paragraphs module to create multi-value fields with unlimited cardinality, e.g. the FAQ field, the Gradient field (for hero banners) etc.
- Go to
/admin/structure/paragraphs_type
to add a new paragraph type- Add a title and a good description explaining what the field is for (see existing descriptions as a reference)
- Create new fields as required and save
- Go to the content type that needs to use this new multi-value field, at the add field interface, select Paragraph as the field type
- Fill in the field information, then select the specific Paragraph type that you created previously
- JSON data from Sessionize is pulled in using the Feeds module (Feeds Extensible Parsers is required to handle JSON)
- Configure the module at
admin/structure/feeds
- To set up a new feed, first create the content type that the feed will populate, e.g. if pulling from an API that provides speaker information, you might want to create a Speaker content type and set a path pattern for that type, if needed, before importing data
- Create fields to match up with the keys provided from the JSON API
- When you first create the new feed type, under Processor settings, choose "Insert new content items" and "Update existing content items", also maybe set the owner to
feedimporter
if you feel like it - The complicated bit is the mapping of fields (Feeds uses JSONPath, so you can use a tool like https://jsonpath.com/ to validate the query)
- Remember to mark the
id
field as unique (there is a checkbox) - If we want to map an array to a multi-value field, the query looks like
sessions[*].id
, and this value is configured in/admin/structure/feeds/manage/FEED_NAME/sources
- Remember to mark the
- For long fields, we are handling line breaks with the
nl2br
filter, specifically for the talk description field, this is used in the full view talk template - For more in-depth notes, see https://chenhuijing.com/blog/pulling-content-from-external-api-into-drupal-10
- Reference: https://drupalsun.com/2020/02/28/drupal-8-feeds-import-external-json-api
- Home
- Recurring tasks
- Local site development
- State of interledger.org
- One-time setup notes