Posts: 9
Threads: 6
Joined: Sep 2011
I apologize if this should go in plugins not feature requests -- but anyone working on a glossary plugin? I could certainly just do a page with a long glossary but would be nice to have a plugin to manage this. I.e. have a word or phrase, with the possibility of multiple definitions, and perhaps images of links to examples.
Thanks
Posts: 305
Threads: 15
Joined: Mar 2014
2015-04-30, 04:03:45
(This post was last modified: 2015-04-30, 05:07:19 by Tyblitz.)
(2014-08-12, 02:48:24)atstarr Wrote: I apologize if this should go in plugins not feature requests -- but anyone working on a glossary plugin? I could certainly just do a page with a long glossary but would be nice to have a plugin to manage this. I.e. have a word or phrase, with the possibility of multiple definitions, and perhaps images of links to examples.
Thanks
Yes this should be in the Plugins/ General Questions subforum, as the scope is probably too broad to include in the core.
Although not its primary purpose; you
could do this with
GS Custom Settings, eg create a tab named 'glossary', and create a setting for each word, set the description to the word description, and the lookup 'word_x' where x is a number. You can reorder them alphabetically in the UI in Edit mode. If you're going to frequently update the list, you need to first return the settings in a for loop, and sort them with PHP sort() to avoid having to reset the numbers.
In your PHP template you could do something like:
PHP Code:
<?php $amount_of_words = 8;
for ($i = 1; $i < $amount_of_words; $i++) {
$word = return_setting('glossary', 'gloss_' . $i, 'label');
if ($i > 0)
$wordPrev = return_setting('glossary', 'gloss_' . ($i - 1), 'label');
if ($i === 0 || ($i > 0 && strtolower($wordPrev{0}) !== strtolower($word{0}))) {
if ($i > 0) echo '</dl>';
echo '<h3>' . strtoupper($word{0}) . '</h3>';
echo '<dl>';
}
echo '<dt>' . $word . '</dt><dd>' . return_setting('glossary', 'gloss_' . $i, 'descr') . '</dd>';
if ($i === $amount_of_words-1) echo '</dl>';
} ?>
This script outputs an HTML definition list with subtitles for each letter (glossary data from http://pc.net/glossary/):
Posts: 6,267
Threads: 182
Joined: Sep 2011
Sooo fu@$#%ing pimp!
well done