Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stats links broken when Grav is not in the web root #34

Open
bleutzinn opened this issue Jan 29, 2023 · 3 comments
Open

Stats links broken when Grav is not in the web root #34

bleutzinn opened this issue Jan 29, 2023 · 3 comments

Comments

@bleutzinn
Copy link

First of all thanks for this great plugin!

On development and often in production too I have Grav installed in a subdirectory.

If so the ''view page' and 'view page stats' links on the 'admin/page-stats' page do not have the subdirectory or path in them. They always link to the web root.

For example if I have Grav in 'htdocs/grav' on localhost the URL of the standard 'typography' page is http://localhost/grav/typography. However the 'view page' link is http://localhost/typography and the 'view page stats' link is http://localhost/admin/page-stats/page-details?page=/typography.

@francodacosta
Copy link
Owner

@bleutzinn can you change false to true on https://github.com/francodacosta/grav-plugin-page-stats/blob/master/page-stats.php#L209 and let me know if it works ?

Otherwise I have to look at it with more attention

@bleutzinn
Copy link
Author

It does fix the problem with links to pages but unfortunately all links to stats remain broken. That is all links with the fa-line-chart icon. For example the URL of the Top Users statistics details is http://localhost/grav/admin/page-stats/top-users but the link is http://localhost/admin/page-stats/top-users.

@bleutzinn
Copy link
Author

It appears that adding the theme variable home_url to the start of links adds the subdirectory in which Grav is installed.

For example in https://github.com/francodacosta/grav-plugin-page-stats/blob/master/themes/admin/templates/widgets/recently-viewed-pages.html.twig#L54 changing
href="{{ pageStats.urls.pageDetails}} to
href="{{ home_url }}{{ pageStats.urls.pageDetails}}.

The documentation) states that the home_url variable takes the currently active language into account. So I tested using an active language and it works okay.
I did not test with Grav being in the document root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants