When entering an anchor only url (ex "#content"), the url fails the link module's validation with the following error:
"The value #content provided for Link is not a valid URL."
The same occurs when entering a query only url - ex. "?search=somekey".

Anchors and query only urls should pass validation and be treated as relative internal links.

Comments

recrit created an issue. See original summary.

recrit’s picture

Status: Active » Needs review
StatusFileSize
new1.32 KB

The patch attached adds 2 new types - LINK_FRAGMENT and LINK_QUERY.

ac’s picture

Patch doesn't fully work

1) # is encoded to %2523
2) you still can't input a path like 'foo#bar'

The module claims to be able to handle anchor links but currently that seems broken.

ac’s picture

Scratch that, the encoding issue was elsewhere and you can already input foo#bar by using node/x#bar

recrit’s picture

@ac, this patch is to add only an anchor link or query link that uses the base as the current page.

dgtlmoon’s picture

Status: Needs review » Closed (duplicate)
moleCuleFFF’s picture

This patch does not work in the situation where a node is being used as the homepage as the URL is rewritten with the alias of node in full.
e.g.:
homepage#panels-ipe-regionid-center

I will provide a new patch. Also the suggested duplicate issue is in regards to rewriting of URL's, not the issue here. Reopening

moleCuleFFF’s picture

Status: Closed (duplicate) » Active
moleCuleFFF’s picture

StatusFileSize
new1.83 KB

Added check for homepage to logic

moleCuleFFF’s picture

StatusFileSize
new17.41 KB

New patch includes patch from issue #1914072: Link Module displays malformed URL

moleCuleFFF’s picture

StatusFileSize
new3.07 KB
sdstyles’s picture

Status: Active » Needs review
StatusFileSize
new2.74 KB

Patch reroll.

apugacescu’s picture

StatusFileSize
new2.89 KB
+  if (drupal_is_front_page()) {
+    $url_parts['url'] = '/';
+  }

breaks internal urls when they are displayed on homepage, not sure why @moleCuleFFF added 'Added check for homepage to logic' could you please share some context?

Checked <front> url is handled correctly by 'url' function without this logic, attaching patch.

Status: Needs review » Needs work

The last submitted patch, 13: link_anchors_and_queries_2654246_13.patch, failed testing. View results

apugacescu’s picture

StatusFileSize
new2.74 KB

Fixed file paths in previous patch.

apugacescu’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 15: link_anchors_and_queries_2654246_14.patch, failed testing. View results

apugacescu’s picture

StatusFileSize
new2.67 KB
new1.47 KB

Rerolled patch.

ok4p1’s picture

StatusFileSize
new2.33 KB

Here there is a patch for the version 1.4 in case anyone needs it.

apugacescu’s picture

Status: Needs work » Needs review
pifagor’s picture

Status: Needs review » Needs work

Hello @okapi1987@gmail.com
Create the patch correctly git diff > [description]-[issue-number]-[comment-number].patch for the version 7.x-1.x-dev

apugacescu’s picture

StatusFileSize
new2.66 KB

Created on top of latest dev.

apugacescu’s picture

Status: Needs work » Needs review
rajiv.singh’s picture

StatusFileSize
new2.42 KB

Rerolled patch

Status: Needs review » Needs work

The last submitted patch, 24: link_anchors_and_queries_2654246_24.patch, failed testing. View results

whthat’s picture

Status: Needs work » Needs review
StatusFileSize
new1.66 KB

Updated Patch by removing the including of patch from issue #1914072: Link Module displays malformed URL. #1914072 is not complete and UTF8 detection does not appear to be even working, best to leave that patch seperate for now. The inclusion only complicates this Anchor and Query String patch by duplicating its fragments, this could work if moved just before the $item array build.

chris matthews’s picture

The patch in #26 applied cleanly to the latest link 7.x-1.x-dev, but still need to be reviewed.

Checking patch link.module...
Hunk #2 succeeded at 582 (offset 2 lines).
Hunk #3 succeeded at 603 (offset 2 lines).
Hunk #4 succeeded at 1635 (offset 20 lines).
Applied patch link.module cleanly.
nishruu’s picture

I use it with success on a website.

pifagor’s picture

Status: Needs review » Reviewed & tested by the community

  • pifagor committed ccc0297 on 7.x-1.x authored by whthat
    Issue #2654246 by SurfinSpirit, moleCuleFFF, recrit, okapi1987@gmail.com...
pifagor’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.