Skip to content

Commit

Permalink
add term variable
Browse files Browse the repository at this point in the history
  • Loading branch information
kringkaste committed Sep 28, 2021
1 parent 29448c6 commit 6d145bf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Release Notes for Glossary for Craft CMS

## 1.0.4 - 2021-09-28

### Added

- Add the term element to the term template variables. So you can now acces the hole term element within the template.

### Deprecated

- The custom fields values of a term in the term template are accessible by the handle, e.g. `{{ myCustomField }}`. This will be removed in the future. You should now access the custom field values using the term variable, e.g. `{{ term.myCustomField }}`.

## 1.0.3 - 2021-09-27

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "codemonauts/craft-glossary",
"description": "Add glossaries with tooltips to Craft CMS.",
"version": "1.0.3",
"version": "1.0.4",
"type": "craft-plugin",
"keywords": [
"craft",
Expand Down
5 changes: 5 additions & 0 deletions src/services/Terms.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ public function renderTerms(string $text, Glossary $glossary): string

$token = $term->uid . '-' . $index++;
$replacements[$token] = $replacement;

/**
* @deprecated Remove field values with version 2.0 and only use term to access all fields.
*/
$variables = $term->getFieldValues();
$variables['term'] = $term;

try {
$usedTerms[$term->id] = $view->renderTemplate($glossary->tooltipTemplate, $variables, 'site');
Expand Down

0 comments on commit 6d145bf

Please sign in to comment.