Fix guide content language and language switcher context
- Change getGuidePage() to use currentLanguage instead of detectLanguage() - Add lang_switch_url template variable for proper context-aware switching - Language switcher now stays on guide page when switching languages - Guide content now displays in correct language based on URL parameter
This commit is contained in:
parent
d95ef42783
commit
9bb21579f7
@ -626,7 +626,7 @@ class CodePressCMS {
|
||||
* @return array Guide page data
|
||||
*/
|
||||
private function getGuidePage() {
|
||||
$lang = $this->detectLanguage();
|
||||
$lang = $this->currentLanguage;
|
||||
$guideFile = __DIR__ . '/../../../guide/' . $lang . '.md';
|
||||
|
||||
if (!file_exists($guideFile)) {
|
||||
@ -796,6 +796,8 @@ class CodePressCMS {
|
||||
'homepage_title' => $homepageTitle,
|
||||
'is_homepage' => (!isset($_GET['page']) || $_GET['page'] === $this->config['default_page']),
|
||||
'home_active_class' => (!isset($_GET['page']) || $_GET['page'] === $this->config['default_page']) ? 'active' : '',
|
||||
'is_guide_page' => isset($_GET['guide']),
|
||||
'lang_switch_url' => isset($_GET['guide']) ? '&guide' : '&page=' . $this->config['default_page'],
|
||||
'author_name' => $this->config['author']['name'] ?? 'CodePress Developer',
|
||||
'author_website' => $this->config['author']['website'] ?? '#',
|
||||
'author_git' => $this->config['author']['git'] ?? '#',
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
{{current_lang_upper}} <i class="bi bi-chevron-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li><a class="dropdown-item" href="?lang=nl&page={{homepage}}">NL</a></li>
|
||||
<li><a class="dropdown-item" href="?lang=en&page={{homepage}}">EN</a></li>
|
||||
<li><a class="dropdown-item" href="?lang=nl{{lang_switch_url}}">NL</a></li>
|
||||
<li><a class="dropdown-item" href="?lang=en{{lang_switch_url}}">EN</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -33,8 +33,8 @@
|
||||
{{current_lang_upper}} <i class="bi bi-chevron-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li><a class="dropdown-item" href="?lang=nl&page={{homepage}}">NL</a></li>
|
||||
<li><a class="dropdown-item" href="?lang=en&page={{homepage}}">EN</a></li>
|
||||
<li><a class="dropdown-item" href="?lang=nl{{lang_switch_url}}">NL</a></li>
|
||||
<li><a class="dropdown-item" href="?lang=en{{lang_switch_url}}">EN</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user