Commit 924050a3 authored by Pablo Rauzy's avatar Pablo Rauzy
Browse files

fix relative link bug when header links to group at root of website

parent f7369949
......@@ -273,6 +273,7 @@ function render ($file, $mode='edit', $entry_dt='NEW') {
$group_file = @reset(array_filter($menu, function ($p) { return $p['status'] != 'lnk'; }))['file'];
$page_entries = array_filter($entries, function ($e) use ($file) { return $e['page'] == $file; });
$relroot = str_repeat('../', substr_count($file, '/'));
if (empty($relroot)) $relroot = '/';
$title_head = str_replace(array('%site%', '%group%', '%page%'),
array($settings['title'], $groups[$group]['name'], $page['title']),
$settings['title_hformat']);
......@@ -280,7 +281,7 @@ function render ($file, $mode='edit', $entry_dt='NEW') {
array($settings['title'], $groups[$group]['name'], $page['title']),
$settings['title_bformat']);
$title_url = str_replace(array('%site%', '%group%', '%page%'),
array(empty($relroot) ? '/' : $relroot, ($group == -1) ? $settings['url'] : $relroot.preg_replace('/index\.html$/', '', $group_file), $relroot.preg_replace('/index\.html$/', '', $page['file'])),
array($relroot, ($group == -1) ? $settings['url'] : $relroot.preg_replace('/index\.html$/', '', $group_file), $relroot.preg_replace('/index\.html$/', '', $page['file'])),
$settings['title_bformat']);
if ($mode == 'publish') { ob_start(); }
?><!doctype HTML>
......@@ -311,7 +312,7 @@ function render ($file, $mode='edit', $entry_dt='NEW') {
<menu><?php
foreach ($menu as $p):
?><li<?php if ($p['file'] == $file) { echo ' class="current"'; } ?>>
<a href="<?php echo ($mode != 'publish') ? CIGALA_PHP.'?edit='.$p['file'] : (($p['status'] == 'lnk') ? ((strpos($p['content'], '//') === false) ? $relroot : '').$p['content'] : $relroot.preg_replace('/\/?index\.html$/', '/', $p['file'])); ?>"><?php echo $p['title']; ?></a>
<a href="<?php echo ($mode != 'publish') ? CIGALA_PHP.'?edit='.$p['file'] : (($p['status'] == 'lnk') ? ((strpos($p['content'], '//') === false) ? $relroot : '').$p['content'] : $relroot.preg_replace('/\/?index\.html$/', '', $p['file'])); ?>"><?php echo $p['title']; ?></a>
</li><?php
endforeach;
?></menu>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment