Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2017-01-14 15:34:52 +0000
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
969ad8911cf5aa7b0d06a07fd2f4a0c32a50a2bc
969ad891
1 parent
581c382f
Updated page nav to hide when empty
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
app/Repos/EntityRepo.php
resources/views/pages/sidebar-tree-list.blade.php
app/Repos/EntityRepo.php
View file @
969ad89
...
...
@@ -836,18 +836,18 @@ class EntityRepo
/**
* Parse the headers on the page to get a navigation menu
* @param Page $page
* @return
Collection
* @return
array
*/
public
function
getPageNav
(
Page
$page
)
{
if
(
$page
->
html
==
''
)
return
null
;
if
(
$page
->
html
==
''
)
return
[]
;
libxml_use_internal_errors
(
true
);
$doc
=
new
DOMDocument
();
$doc
->
loadHTML
(
mb_convert_encoding
(
$page
->
html
,
'HTML-ENTITIES'
,
'UTF-8'
));
$xPath
=
new
DOMXPath
(
$doc
);
$headers
=
$xPath
->
query
(
"//h1|//h2|//h3|//h4|//h5|//h6"
);
if
(
is_null
(
$headers
))
return
null
;
if
(
is_null
(
$headers
))
return
[]
;
$tree
=
collect
([]);
foreach
(
$headers
as
$header
)
{
...
...
@@ -868,7 +868,7 @@ class EntityRepo
return
$header
;
});
}
return
$tree
;
return
$tree
->
toArray
()
;
}
/**
...
...
resources/views/pages/sidebar-tree-list.blade.php
View file @
969ad89
...
...
@@ -26,7 +26,7 @@
@endforeach
@endif
@if (isset($pageNav)
&&
$pageNav
)
@if (isset($pageNav)
&&
count($pageNav)
)
<h6
class=
"text-muted"
>
{{ trans('entities.pages_navigation') }}
</h6>
<div
class=
"sidebar-page-nav menu"
>
@foreach($pageNav as $navItem)
...
...
Please
register
or
sign in
to post a comment