Mercurial > hg > fapweb
changeset 662:2e0b11277f2f
Use more descriptive anchor IDs.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 05 Nov 2014 19:04:03 +0200 |
parents | f1016ed4b05b |
children | 7091b0c6c7c1 |
files | pages/compos.inc.php |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/pages/compos.inc.php Wed Nov 05 19:03:44 2014 +0200 +++ b/pages/compos.inc.php Wed Nov 05 19:04:03 2014 +0200 @@ -4,6 +4,12 @@ // Competitions page // (C) Copyright 2012-2014 Tecnic Software productions (TNSP) // +function stConvertNameToID($name) +{ + return preg_replace("/[^a-z0-9_]/", "", strtolower($name)); +} + + if (stChkSetting("showCompos")) { echo @@ -17,7 +23,9 @@ $list = array(); foreach ($res as $item) { - $list[] = "<a class=\"compo\" href=\"#compo".$item["id"]."\">".chentities($item["name"])."</a>"; + $list[] = "<a class=\"compo\" href=\"#". + stConvertNameToID($item["name"])."\">". + chentities($item["name"])."</a>"; } echo "<div class=\"compolist\">".join($list, "<span class=\"composep\"> | </span>")."</div>"; } @@ -30,7 +38,7 @@ foreach ($res as $item) { echo - "<div id=\"compo".$item["id"]."\">\n". + "<div id=\"".stConvertNameToID($item["name"])."\">\n". "<h2>".chentities($item["name"])."</h2>\n". stConvertCommonDesc($item["description"], FALSE). "<div class=\"backToTop\"><a href=\"#pageTop\">Back</a></div>\n".