htmly icon indicating copy to clipboard operation
htmly copied to clipboard

[FEATURE REQUEST] Menu editor, supports relative URL

Open word-x opened this issue 1 year ago • 1 comments

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

word-x avatar Jul 05 '24 16:07 word-x

Hello,

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

danpros avatar Jul 08 '24 07:07 danpros

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

cuixiping avatar Oct 09 '24 02:10 cuixiping

@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.

danpros avatar Oct 09 '24 03:10 danpros

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);
  1. Then replace all $node->slug with $nodeSlug
function parseNode($node, $child = null)
{
    $nodeSlug = str_replace('{site.url}', site_url(), $node->slug);
    ...
    ...
    ...
}

cuixiping avatar Oct 09 '24 06:10 cuixiping

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

Joduai avatar Oct 09 '24 21:10 Joduai