This guide will add the glossary feature into the content of pages and article summaries.
Open /includes/classes/class.page.php and find:
$GLOBALS["Content"] = $GLOBALS["AL_CLASS_PAGE"]->GetContent();
and change it to:
$output = $GLOBALS["AL_CLASS_PAGE"]->GetContent();
// Get all glossary words
$arrWords = AL_HELPER::GetGlossaryTerms();
if (sizeof($arrWords) > 0) {
// Make the replacements
for ($i = 0; $i < sizeof($arrWords); $i++) {
$regex = "#(?![^<]*?>)(?!<a[^>]*>)\b" . preg_quote($arrWords[$i]["word"], '#') . "\b(?![^<]*</a>)#si";
$output = preg_replace($regex, $arrWords[$i]["token"], $output, 1);
}
}
if (sizeof($arrWords) > 0) {
// Make the replacements
for ($i = 0; $i < sizeof($arrWords); $i++) {
// Just replace the first instanse of the token
$title = str_replace("\r\n", "<br>", str_replace(''',
'\\'', str_replace('"', '', $arrWords[$i]["desc"])));
$title = str_replace(''', '\\'', $title);
$popup = "<a class=\"HelpLink\" href=\"javascript:void(0)\"
onclick=\"showHelpTip(event, '<b>" . $arrWords[$i]["word"] .
"</b><br><br>" . $title . "'); return false\">" .
$arrWords[$i]["word"] . "</a>";
// Replace the rest of the tokens back with the word
$output = str_replace($arrWords[$i]["token"], $popup, $output);
}
}
$GLOBALS["Content"] = $output;Then add these lines into /templates/{your-template}/Panels/Pages.html before the </head> tag:
<link href="%%Config.CurrentTemplatePath%%/Styles/HelpTip.css" type="text/css" rel="stylesheet"> <script type="text/javascript" src="%%GLOBAL_siteURL%%/javascript/helpTip.js"></script>
Now open /includes/classes/class.article.php and find:
$GLOBALS['content'] = $articleRow["Summary"];
and change it to:
$output = $articleRow["Summary"];
// Get all glossary words
$arrWords = AL_HELPER::GetGlossaryTerms();
if (sizeof($arrWords) > 0) {
// Make the replacements
for ($i = 0; $i < sizeof($arrWords); $i++) {
$regex = "#(?![^<]*?>)(?!<a[^>]*>)\b" . preg_quote($arrWords[$i]["word"], '#') . "\b(?![^<]*</a>)#si";
$output = preg_replace($regex, $arrWords[$i]["token"], $output, 1);
}
}
if (sizeof($arrWords) > 0) {
// Make the replacements
for ($i = 0; $i < sizeof($arrWords); $i++) {
// Just replace the first instanse of the token
$title = str_replace("\r\n", "<br>", str_replace(''',
'\\'', str_replace('"', '', $arrWords[$i]["desc"])));
$title = str_replace(''', '\\'', $title);
$popup = "<a class=\"HelpLink\" href=\"javascript:void(0)\"
onclick=\"showHelpTip(event, '<b>" . $arrWords[$i]["word"] .
"</b><br><br>" . $title . "'); return false\">" .
$arrWords[$i]["word"] . "</a>";
// Replace the rest of the tokens back with the word
$output = str_replace($arrWords[$i]["token"], $popup, $output);
}
}
$GLOBALS['content'] = $output;Then open /templates/{your-template}/Panels/Categories.html adn the Default.html file and add these two lines before the </head> tag:
<link href="%%Config.CurrentTemplatePath%%/Styles/HelpTip.css" type="text/css" rel="stylesheet"> <script type="text/javascript" src="%%GLOBAL_siteURL%%/javascript/helpTip.js"></script>
