Skip to content

Commit

Permalink
Show the page name in the Docs title bar.
Browse files Browse the repository at this point in the history
  • Loading branch information
lonnieezell committed Oct 15, 2014
1 parent 18a9ee4 commit 83f50bc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions myth/CIModules/docs/controllers/Docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function index()
$data['sidebar'] = $this->buildSidebar($content);
$data['toc'] = $this->buildTOC();
$data['content'] = $content;
$data['page_title'] = $this->docbuilder->pageTitle();
} catch (Exception $e) {
$this->setMessage($e->getMessage(), 'warning');
}
Expand Down
17 changes: 17 additions & 0 deletions myth/Docs/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class Builder implements DocBuilderInterface

protected $formatters = [];

protected $page_title = null;

//--------------------------------------------------------------------

public function __construct($config = array())
Expand All @@ -61,6 +63,14 @@ public function __construct($config = array())

//--------------------------------------------------------------------

public function pageTitle()
{
return $this->page_title;
}

//--------------------------------------------------------------------



/**
* Does the actual work of reading in and parsing the help file.
Expand Down Expand Up @@ -633,6 +643,13 @@ protected function extractDocMapAndAddAnchors(&$content, $xml, $map)
foreach ($xml->children() as $childType => $line) {
$currentChild++;

// If it's an h1 - take the first and make it
// our page title.
if ($childType == 'h1' && empty($this->page_title))
{
$this->page_title = (string)$line;
}

// Make sure that our current object is
// stored and reset.
if ($childType == 'h1' || $childType == 'h2') {
Expand Down
2 changes: 1 addition & 1 deletion themes/docs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="UTF-8" />
<title>Docs</title>
<title><?= !empty($page_title) ? $page_title : 'Docs'; echo ' - '. config_item('site.name') ?></title>

<meta name=viewport content="width=device-width, initial-scale=1">

Expand Down

0 comments on commit 83f50bc

Please sign in to comment.