In many cases it would be nice to have the glossary descriptions link to other terms if they are in the glossary.

This patch adds that functionality. It can be enabled/disabled and tweaked similarly to the other input format options. The new settings are attached below the current General settings.

Comments

nancydru’s picture

Did you try using the already available related links capability?

harking’s picture

I looked into the related links capabilities and determined that for our internal use case we would need to have the text in the description link to other terms automatically. From what I understand, the related terms need to be defined manually.

I still feel that the related terms are useful in the case where the description or term might be part of a larger topic and can use a direct link with the "More info" style annotation.

nancydru’s picture

I will look into this.

George, in the future when you do a patch for a module that is changing frequently, it would help to use the "-p" option on your diff.

nancydru’s picture

Status: Needs review » Needs work

There are lots of changes to "glossary_filter_form" that seem to have nothing to do with this.

nancydru’s picture

Hmm, I applied the relevant parts of the patch (as best I can tell) and it doesn't seem to do anything. I've tried it with both icon and hovertip settings.

harking’s picture

The changes to the glossary filter form allowed the reuse of the filter form elements that were in common.

I'm not sure if the patch can be chopped up. What parts did you try applying?

nancydru’s picture

Index: glossary.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/glossary/glossary.module,v
retrieving revision 1.100.2.20
diff -u -r1.100.2.20 glossary.module
--- glossary.module 20 Feb 2008 16:06:41 -0000 1.100.2.20
+++ glossary.module 20 Feb 2008 18:06:24 -0000
@@ -266,7 +266,7 @@
}
}

-function _glossary_filter_process($format, $text) {
+function _glossary_filter_process($format, $text, $current_term = null) {
global $user;
if ($user->glossary_disable_indicator && variable_get('glossary_disable_indicator', false)) {
return $text;
@@ -282,6 +282,12 @@
$terms_replace = array();

foreach ($terms as $term) {
+ //Skip the term if we are creating glossary links inside of another glossary item.
+ if (variable_get('glossary_link_term_to_self', false) == false) {
+ if ($term->name == $current_term) {
+ continue;
+ }
+ }
$term_title = $term->name .': '. strip_tags($term->description);
$fragment = null;
if ($term->nodes > 0) {
@@ -596,7 +602,12 @@
$output .= l(t('Detailed definition of @term', array('@term' => $term->name)), "taxonomy/term/$term->tid");
}
else {
- $output .= $term->description;
+ if (variable_get('glossary_internal_links', true)) {
+ $output .= _glossary_filter_process(0, $term->description, $term->name);
+ }
+ else {
+ $output .= $term->description;
+ }
}

if ($relations = taxonomy_get_related($term->tid, "name")) {
@@ -857,6 +868,28 @@
'#description' => t('Glossary term descriptions may be large and/or include pictures, therefore the Glossary page can take a long time to load if you include the full descriptions.'),
);

+ $form['general']['glossary'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Glossary Internal Links'),
+ '#collapsible' => true,
+ '#collapsed' => false,
+// '#description' => t('Settings for glossary items')
+ );
+
+ $form['general']['glossary']['glossary_internal_links'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Link between glossary terms.'),
+ '#default_value' => variable_get('glossary_internal_links', true),
+ '#description' => t('If checked, glossary descriptions that contain other elements in the glossary will be linked to them.')
+ );
+
+ $form['general']['glossary']['glossary_link_term_to_self'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Link a term back to itself?'),
+ '#default_value' => variable_get('glossary_link_term_to_self', false),
+ '#description' => t('If checked, when a term contains its own term in its description it will be converted into a glossary item. Requires "Link between glossary terms."')
+ );
+
$click_options = array(
t('Show only the single term.'),
t('Advance the whole glossary to the term.'),

harking’s picture

I think your patch is missing the extra form elements which will set the glossary settings that allow the internal linking to occur.

When the glossary filter does not see the settings it does not insert the links into the keywords.

nancydru’s picture

StatusFileSize
new88.36 KB

see the picture

harking’s picture

StatusFileSize
new120.74 KB

This screen shot shows the full patch, with the additional settings for the internal glossary links. The extra fields are required since they tell the glossary filter which vocabularies to apply to the glossary items.

nancydru’s picture

It looks like you have global settings and input format settings intermingled. I don't want that. A setting should be one or the other and only on that appropriate settings page.

harking’s picture

Perhaps another tab would be appropriate. How does that sound?

nancydru’s picture

If I don't turn off my unused input formats on my site, I already have 9 tabs.

Maybe I just don't understand how your patch is supposed to work, particularly at the UI level.

harking’s picture

9 input formats is quite a bit. Do you have an input format for each content type?

At the UI level, the patch is just adding another section to configure the glossary filter for when processing content in the glossary pages.

Since the glossary filter needs to know the same amount of information to process the glossary items as it does to process a node's content, it needs the same configuration options. They way I saw to get the filter this information was to add another set of configuration options.

I stuck the new options in the general settings area because I thought it applied to the glossary as a whole.

nancydru’s picture

No, only 6 input formats. To start with there is the General tab, followed by the Alphabet tab, followed by the Clear cache tab. Everyone has those 3. Most sites are then going to have 3 input formats (filtered, full, php). My other 3 are because of wanting to omit certain filters in certain cases.

I am trying to keep it so that the tabs for the various input formats contain only settings for that format. The general tab contains settings that all formats would use. I do not want duplication because it can be (and usually is) confusing. I tried using your patch to put the settings only on the general settings page, because they appeared to be general in nature. However, the code did nothing as far as I could tell, so I have removed it again.

nancydru’s picture

Status: Needs work » Closed (won't fix)

When you can construct a patch that fits in with the overall module design and shows me that it does something, feel free to re-open this issue.

harking’s picture

Version: 5.x-1.8 » 5.x-2.2
Status: Closed (won't fix) » Needs review
StatusFileSize
new8.57 KB

Reopening with an updated patch for 2.2.

Similar to old patch in that the additional control is placed in the "General" tab. The additional features are still disabled by default and the now the fieldset is collapsed by default.

This does not create any additional tabs, and still allows for the additional internal linking features to integrate well.

harking’s picture

Status: Needs review » Closed (won't fix)

Looking at glossary module again, it seems that internal linking between terms is already being taken care of by the module, and thus this patch for more configuration isn't required.

nancydru’s picture

Okay, that was easy.