From: fabrixxm <fabrix.xm@gmail.com>
Date: Mon, 28 Dec 2015 09:21:34 +0000 (+0100)
Subject: Fix TOC links href, no TOC in home
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f579b2af55f33b663b2a81c732f3ff76f166dff6;p=friendica.git

Fix TOC links href, no TOC in home
---

diff --git a/doc/api.md b/doc/api.md
index ef8c7d4b4d..48b4f6e63c 100644
--- a/doc/api.md
+++ b/doc/api.md
@@ -269,6 +269,7 @@ xml
 	</photo>
 ```
 
+---
 ### friendica/photos/list
 
 Returns a list of all photo resources of the logged in user.
diff --git a/mod/help.php b/mod/help.php
index 5646f1ce10..5465d3e900 100644
--- a/mod/help.php
+++ b/mod/help.php
@@ -59,33 +59,36 @@ function help_content(&$a) {
 
 	$html = Markdown($text);
 
-	// create TOC
-	$lines = explode("\n", $html);
-	$toc="<style>aside ul {padding-left: 1em;}</style><h2>TOC</h2><ul id='toc'>";
-	$lastlevel=1;
-	$idnum = array(0,0,0,0,0,0,0);
-	foreach($lines as &$line){
-		if (substr($line,0,2)=="<h") {
-			$level = substr($line,2,1);
-			if ($level!="r") {
-				$level = intval($level);
-				if ($level<$lastlevel) {
-					for($k=$level;$k<$lastlevel; $k++) $toc.="</ul>";
-					for($k=$level+1;$k<count($idnum);$k++) $idnum[$k]=0;
+	if ($filename !== "Home") {
+		// create TOC but not for home
+		$lines = explode("\n", $html);
+		$toc="<style>aside ul {padding-left: 1em;}</style><h2>TOC</h2><ul id='toc'>";
+		$lastlevel=1;
+		$idnum = array(0,0,0,0,0,0,0);
+		foreach($lines as &$line){
+			if (substr($line,0,2)=="<h") {
+				$level = substr($line,2,1);
+				if ($level!="r") {
+					$level = intval($level);
+					if ($level<$lastlevel) {
+						for($k=$level;$k<$lastlevel; $k++) $toc.="</ul>";
+						for($k=$level+1;$k<count($idnum);$k++) $idnum[$k]=0;
+					}
+					if ($level>$lastlevel) $toc.="<ul>";
+					$idnum[$level]++;
+					$id = implode("_", array_slice($idnum,1,$level));
+					$href = $a->get_baseurl()."/help/{$filename}#{$id}";
+					$toc .= "<li><a href='{$href}'>".strip_tags($line)."</a></li>";
+					$line = "<a name='{$id}'></a>".$line;
+					$lastlevel = $level;
 				}
-				if ($level>$lastlevel) $toc.="<ul>";
-				$idnum[$level]++;
-				$id = implode("_", array_slice($idnum,1,$level));
-				$toc .= "<li><a href='#{$id}'>".strip_tags($line)."</a></li>";
-				$line = "<a name='{$id}'></a>".$line;
-				$lastlevel = $level;
 			}
 		}
-	}
-	for($k=1;$k<$lastlevel; $k++) $toc.="</ul>";
-	$html = implode("\n",$lines);
+		for($k=1;$k<$lastlevel; $k++) $toc.="</ul>";
+		$html = implode("\n",$lines);
 
-	$a->page['aside'] = $toc.$a->page['aside'];
+		$a->page['aside'] = $toc.$a->page['aside'];
+	}
 
 	$html = "
 		<style>