danpros / htmly

Simple and fast databaseless PHP blogging platform, and Flat-File CMS
https://www.htmly.com
GNU General Public License v2.0
1.1k stars 266 forks source link

[FEATURE REQUEST] Menu editor, supports relative URL #779

Closed word-x closed 1 month ago

word-x commented 4 months ago

Is your feature request related to a problem? Please describe. When I test locally, I should us

danpros commented 4 months ago

Hello,

If this is menu editor, we just need to add slash before the URL, example /about and not just about

cuixiping commented 1 month ago

@danpros How to add a variable which equals site_url() in the menu link (slug) field? For example {site.url}contact

danpros commented 1 month ago

@cuixiping at the moment the menu field does not support variables in the menu yet. Perhaps we can just simply replace the {site.url} to the site_url() during menu generation.

cuixiping commented 1 month ago

I modified the parseNode function in functions.php to do the replacement. It works for me.

  1. Add a line:
    $nodeSlug = str_replace('{site.url}', site_url(), $node->slug);
  2. Then replace all $node->slug with $nodeSlug
function parseNode($node, $child = null)
{
    $nodeSlug = str_replace('{site.url}', site_url(), $node->slug);
    ...
    ...
    ...
}
Joduai commented 1 month ago

This shouldn't be hardcoded as I'm fully for relative urls, and adding automatically domain to menu links should be optional.
Maybe as a checkbox + short info about adding "/" before URI or just checking and adding automatically a missing slash