diff options
| author | spider@app2 <spiderr@bitweaver.org> | 2018-01-11 15:54:59 -0500 |
|---|---|---|
| committer | spider@app2 <spiderr@bitweaver.org> | 2018-01-11 15:54:59 -0500 |
| commit | 6bc919bb89fb2aaabe89a2048e964f5f736004b9 (patch) | |
| tree | 8e424c56c1b6e7bbf6ea14d92d81f9d24e12c14e /modules | |
| parent | 868d2fd404d51681c0467ec3700d0aa62a9e46e5 (diff) | |
| download | liberty-6bc919bb89fb2aaabe89a2048e964f5f736004b9.tar.gz liberty-6bc919bb89fb2aaabe89a2048e964f5f736004b9.tar.bz2 liberty-6bc919bb89fb2aaabe89a2048e964f5f736004b9.zip | |
fix listing wiki books in multiple structures to do the right thing...
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/mod_structure_toc.php | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/modules/mod_structure_toc.php b/modules/mod_structure_toc.php index 7fb5d7e..a928279 100644 --- a/modules/mod_structure_toc.php +++ b/modules/mod_structure_toc.php @@ -21,11 +21,21 @@ if( is_object( $gStructure ) && $gStructure->isValid() && $gStructure->hasViewPe } elseif( @BitBase::verifyId( $module_params['structure_id'] ) ) { $struct = new LibertyStructure( $module_params['structure_id'] ); } elseif( is_object( $gContent ) && $gContent->hasViewPermission( FALSE ) ) { - $structures = $gContent->getStructures(); - // We take the first structure. not good, but works for now - spiderr - if( !empty( $structures[0] ) ) { - require_once( LIBERTY_PKG_PATH.'LibertyStructure.php' ); - $struct = new LibertyStructure( $structures[0]['structure_id'] ); + if( $structures = $gContent->getStructures() ) { + // We take the first structure by default, perhaps there is a better choice + $structureId = $structures[0]['structure_id']; + if( count( $structures ) > 1 ) { + foreach( $structures as $structureHash ) { + if( $gContent->getTitle() == $structureHash['root_title'] ) { + $structureId = $structureHash['root_structure_id']; + break; + } + } + } + if( !empty( $structures[0] ) ) { + require_once( LIBERTY_PKG_PATH.'LibertyStructure.php' ); + $struct = new LibertyStructure( $structureId ); + } } } |
