From 0f4588908839a0317c0149687e76809895560033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Say=C3=A3o=20Lobato=20Abreu?= Date: Sun, 19 Apr 2026 18:48:38 -0300 Subject: [PATCH 1/8] Redirect homepage to guides when available --- README.md | 3 +- index.html.twig | 90 ++++++++++++++++++++++++++++++++++++------------- 2 files changed, 68 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index b41f922..7b9c5b0 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ A clean and modern Bootstrap-based template for phpDocumentor, designed to impro - Responsive and mobile-friendly - Styled code blocks and documentation elements - Improved tables of contents and element listings +- Automatic homepage redirect to the guides index when guides are available ## Installation @@ -88,4 +89,4 @@ Contributions are welcome. Please open an issue or submit a pull request. ## 📄 License -This package is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details. \ No newline at end of file +This package is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details. diff --git a/index.html.twig b/index.html.twig index 5f8ede8..b780526 100644 --- a/index.html.twig +++ b/index.html.twig @@ -1,28 +1,70 @@ {% extends 'base.html.twig' %} +{% set guideHome = null %} +{% set guideFallback = null %} + +{% for version in project.versions if guideHome is null %} + {% for documentation in version.documentationSets if guideHome is null %} + {% for guide in documentation.documents|default([]) %} + {% if guideFallback is null %} + {% set guideFallback = link(guide) %} + {% endif %} + + {% if guideHome is null and (guide.file == 'index' or guide.file ends with '/index') %} + {% set guideHome = link(guide) %} + {% endif %} + {% endfor %} + {% endfor %} +{% endfor %} + +{% if guideHome is null %} + {% set guideHome = guideFallback %} +{% endif %} + +{% block head %} + {% if guideHome %} + + + {% endif %} + {{ parent() }} +{% endblock %} + {% block content %} -
-
-

Documentation

-

Welcome to the {{ project.name }} API documentation.

-
-
-
- -
- {% set node = project.namespace %} - - {{ - include( - 'components/table-of-contents.html.twig', - { - 'node': project.namespace, - 'namespaces': usesNamespaces or not usesPackages ? node.children : [], - 'packages': usesPackages ? project.package.children : [] - } - ) - }} - {{ include('components/constants.html.twig', {'node': project.namespace}) }} - {{ include('components/functions.html.twig', {'node': project.namespace}) }} -
+ {% if guideHome %} +
+
+

Documentation

+

Redirecting to the guide home for {{ project.name }}.

+
+

+ Open guide home +

+
+
+ {% else %} +
+
+

Documentation

+

Welcome to the {{ project.name }} API documentation.

+
+
+
+ +
+ {% set node = project.namespace %} + + {{ + include( + 'components/table-of-contents.html.twig', + { + 'node': project.namespace, + 'namespaces': usesNamespaces or not usesPackages ? node.children : [], + 'packages': usesPackages ? project.package.children : [] + } + ) + }} + {{ include('components/constants.html.twig', {'node': project.namespace}) }} + {{ include('components/functions.html.twig', {'node': project.namespace}) }} +
+ {% endif %} {% endblock %} From 4bec8bdeeb911a751ce5be5069ba32f57f258220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Say=C3=A3o=20Lobato=20Abreu?= Date: Sun, 19 Apr 2026 18:51:26 -0300 Subject: [PATCH 2/8] Render guide homepage content inline --- README.md | 2 +- index.html.twig | 40 +++++++++++++++++++--------------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 7b9c5b0..1384e0b 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ A clean and modern Bootstrap-based template for phpDocumentor, designed to impro - Responsive and mobile-friendly - Styled code blocks and documentation elements - Improved tables of contents and element listings -- Automatic homepage redirect to the guides index when guides are available +- Automatic homepage rendering of the guides index when guides are available ## Installation diff --git a/index.html.twig b/index.html.twig index b780526..419c0ee 100644 --- a/index.html.twig +++ b/index.html.twig @@ -3,18 +3,22 @@ {% set guideHome = null %} {% set guideFallback = null %} -{% for version in project.versions if guideHome is null %} - {% for documentation in version.documentationSets if guideHome is null %} - {% for guide in documentation.documents|default([]) %} - {% if guideFallback is null %} - {% set guideFallback = link(guide) %} - {% endif %} +{% for version in project.versions %} + {% if guideHome is null %} + {% for documentation in version.documentationSets %} + {% if guideHome is null %} + {% for guide in documentation.documents|default([]) %} + {% if guideFallback is null %} + {% set guideFallback = guide %} + {% endif %} - {% if guideHome is null and (guide.file == 'index' or guide.file ends with '/index') %} - {% set guideHome = link(guide) %} + {% if guideHome is null and (guide.file == 'index' or guide.file ends with '/index') %} + {% set guideHome = guide %} + {% endif %} + {% endfor %} {% endif %} {% endfor %} - {% endfor %} + {% endif %} {% endfor %} {% if guideHome is null %} @@ -23,24 +27,18 @@ {% block head %} {% if guideHome %} - - + {% for headerNode in guideHome.documentNode.headerNodes %} + {{ renderNode(headerNode) }} + {% endfor %} {% endif %} {{ parent() }} {% endblock %} {% block content %} {% if guideHome %} -
-
-

Documentation

-

Redirecting to the guide home for {{ project.name }}.

-
-

- Open guide home -

-
-
+ {% for child in guideHome.documentNode.children %} + {{ renderNode(child) }} + {% endfor %} {% else %}
From d666391746cca35ddea76791afc7c6cb6d6bdc9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Say=C3=A3o=20Lobato=20Abreu?= Date: Sun, 19 Apr 2026 18:54:08 -0300 Subject: [PATCH 3/8] Load guide homepage content inline --- README.md | 2 +- index.html.twig | 95 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 73 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 1384e0b..4aca125 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ A clean and modern Bootstrap-based template for phpDocumentor, designed to impro - Responsive and mobile-friendly - Styled code blocks and documentation elements - Improved tables of contents and element listings -- Automatic homepage rendering of the guides index when guides are available +- Automatic homepage loading of the guides index content when guides are available ## Installation diff --git a/index.html.twig b/index.html.twig index 419c0ee..c7ca214 100644 --- a/index.html.twig +++ b/index.html.twig @@ -1,19 +1,21 @@ {% extends 'base.html.twig' %} -{% set guideHome = null %} -{% set guideFallback = null %} +{% set guideHomeUrl = null %} +{% set guideFallbackUrl = null %} {% for version in project.versions %} - {% if guideHome is null %} + {% if guideHomeUrl is null %} {% for documentation in version.documentationSets %} - {% if guideHome is null %} + {% if guideHomeUrl is null %} {% for guide in documentation.documents|default([]) %} - {% if guideFallback is null %} - {% set guideFallback = guide %} + {% set guideUrl = link(guide) %} + + {% if guideFallbackUrl is null and guideUrl %} + {% set guideFallbackUrl = guideUrl %} {% endif %} - {% if guideHome is null and (guide.file == 'index' or guide.file ends with '/index') %} - {% set guideHome = guide %} + {% if guideHomeUrl is null and guideUrl and (guide.file == 'index' or guide.file ends with '/index') %} + {% set guideHomeUrl = guideUrl %} {% endif %} {% endfor %} {% endif %} @@ -21,24 +23,71 @@ {% endif %} {% endfor %} -{% if guideHome is null %} - {% set guideHome = guideFallback %} +{% if guideHomeUrl is null %} + {% set guideHomeUrl = guideFallbackUrl %} {% endif %} -{% block head %} - {% if guideHome %} - {% for headerNode in guideHome.documentNode.headerNodes %} - {{ renderNode(headerNode) }} - {% endfor %} - {% endif %} - {{ parent() }} -{% endblock %} - {% block content %} - {% if guideHome %} - {% for child in guideHome.documentNode.children %} - {{ renderNode(child) }} - {% endfor %} + {% if guideHomeUrl %} +
+
+
+

Documentation

+

Loading the guide home for {{ project.name }}.

+
+

+ Open guide home +

+
+
+
+ + {% else %}
From 35c2a461d4edc81f6fbb413873cf2e59b45a79fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Say=C3=A3o=20Lobato=20Abreu?= Date: Sun, 19 Apr 2026 18:58:19 -0300 Subject: [PATCH 4/8] Use guide output location for homepage loading --- index.html.twig | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/index.html.twig b/index.html.twig index c7ca214..c16334d 100644 --- a/index.html.twig +++ b/index.html.twig @@ -8,7 +8,11 @@ {% for documentation in version.documentationSets %} {% if guideHomeUrl is null %} {% for guide in documentation.documents|default([]) %} - {% set guideUrl = link(guide) %} + {% set guideUrl = guide.file ~ '.html' %} + + {% if documentation.outputLocation != '' and documentation.outputLocation != '.' %} + {% set guideUrl = documentation.outputLocation ~ '/' ~ guideUrl %} + {% endif %} {% if guideFallbackUrl is null and guideUrl %} {% set guideFallbackUrl = guideUrl %} @@ -39,13 +43,14 @@

Documentation

Loading the guide home for {{ project.name }}.


-

- Open guide home -

+ + - {% else %} -
-
-

Documentation

-

Welcome to the {{ project.name }} API documentation.

-
-
-
- -
- {% set node = project.namespace %} - - {{ - include( - 'components/table-of-contents.html.twig', - { - 'node': project.namespace, - 'namespaces': usesNamespaces or not usesPackages ? node.children : [], - 'packages': usesPackages ? project.package.children : [] - } - ) - }} - {{ include('components/constants.html.twig', {'node': project.namespace}) }} - {{ include('components/functions.html.twig', {'node': project.namespace}) }} -
- {% endif %} +
+ +
+ {% set node = project.namespace %} + + {{ + include( + 'components/table-of-contents.html.twig', + { + 'node': project.namespace, + 'namespaces': usesNamespaces or not usesPackages ? node.children : [], + 'packages': usesPackages ? project.package.children : [] + } + ) + }} + {{ include('components/constants.html.twig', {'node': project.namespace}) }} + {{ include('components/functions.html.twig', {'node': project.namespace}) }} +
{% endblock %} diff --git a/layout.html.twig b/layout.html.twig index fceb201..7f91eb7 100644 --- a/layout.html.twig +++ b/layout.html.twig @@ -20,7 +20,7 @@ - + {% endblock %} @@ -84,9 +84,9 @@ - - - + + + {% endblock %} diff --git a/template.xml b/template.xml index 749aede..51dcec7 100644 --- a/template.xml +++ b/template.xml @@ -5,7 +5,6 @@ github@mentordosnerds.com 1.0.0 - From 38a9bf05fed26ff62fc62b479c605228e1a6827f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Say=C3=A3o=20Lobato=20Abreu?= Date: Sun, 19 Apr 2026 19:21:32 -0300 Subject: [PATCH 6/8] Remove base href dependency from local assets --- components/sidebar.html.twig | 12 ++++++------ graphs/class.html.twig | 5 ++--- js/searchIndex.js.twig | 1 - layout.html.twig | 1 - 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/components/sidebar.html.twig b/components/sidebar.html.twig index 4da80e5..79e326c 100644 --- a/components/sidebar.html.twig +++ b/components/sidebar.html.twig @@ -26,26 +26,26 @@ - \ No newline at end of file + diff --git a/graphs/class.html.twig b/graphs/class.html.twig index 0385623..c866fd2 100644 --- a/graphs/class.html.twig +++ b/graphs/class.html.twig @@ -1,5 +1,4 @@ {% extends 'base.html.twig' %} -{% set baseUrl = renderBaseUrlHeader() %} {% block stylesheets %} {% endblock %} @@ -40,7 +39,7 @@ id="graph-container" > Class diagram -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/js/searchIndex.js.twig b/js/searchIndex.js.twig index 2ae3a4a..fb84c39 100644 --- a/js/searchIndex.js.twig +++ b/js/searchIndex.js.twig @@ -1,4 +1,3 @@ -{% set baseUrl = renderBaseUrlHeader() %} Search.appendIndex( [ {% for element in project.indexes.elements %} diff --git a/layout.html.twig b/layout.html.twig index 7f91eb7..d028ec6 100644 --- a/layout.html.twig +++ b/layout.html.twig @@ -7,7 +7,6 @@ {% endblock %} - {{ renderBaseUrlHeader() }} {% block stylesheets %} From 3bfa3ae4655829d1fac0690510407a06ff9893c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Say=C3=A3o=20Lobato=20Abreu?= Date: Sun, 19 Apr 2026 19:26:00 -0300 Subject: [PATCH 7/8] Fix search result URLs on local homepage --- js/search.js.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/search.js.twig b/js/search.js.twig index f50fc5a..31b5b4f 100644 --- a/js/search.js.twig +++ b/js/search.js.twig @@ -65,7 +65,7 @@ var Search = (function () { var summary = result.summary ? escapeHtml(result.summary) : ''; var fqsen = result.fqsen ? escapeHtml(result.fqsen) : ''; var name = escapeHtml(result.name || 'Untitled'); - var url = document.baseURI + result.url; + var url = result.url; return '' + '
  • ' + @@ -208,4 +208,4 @@ window.addEventListener('DOMContentLoaded', function () { window.addEventListener('load', function () { Search.init(); -}); \ No newline at end of file +}); From d188ce55442afa73d017b1c024932f577aec3931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Say=C3=A3o=20Lobato=20Abreu?= Date: Sun, 19 Apr 2026 19:28:48 -0300 Subject: [PATCH 8/8] Compute base href from current destination --- layout.html.twig | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/layout.html.twig b/layout.html.twig index d028ec6..6a653c8 100644 --- a/layout.html.twig +++ b/layout.html.twig @@ -6,7 +6,31 @@ {% block title %}{{ project.name }}{% endblock %} {% endblock %} + {% set currentDestination = destinationPath|default('') %} + {% if (currentDestination is empty) and env is not null %} + {% set currentDestination = env.currentFileDestination|default('') %} + {% endif %} + + {% set normalizedDestination = currentDestination + |split('#')|first + |split('?')|first + |replace({'./': '', '.\\': ''}) + |trim('/') + %} + + {% set destinationDepth = normalizedDestination ? (normalizedDestination|split('/')|length - 1) : 0 %} + {% set baseHref = './' %} + + {% if destinationDepth > 0 %} + {% set baseSegments = [] %} + {% for i in 1..destinationDepth %} + {% set baseSegments = baseSegments|merge(['../']) %} + {% endfor %} + {% set baseHref = baseSegments|join('') %} + {% endif %} + + {% block stylesheets %}