Doesn't seem to allow for internal links.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

smustgrave created an issue. See original summary.

smustgrave’s picture

This was a small workaround I did. Then I could add links like internal:/my-link

neslee canil pinto’s picture

Version: 1.1.0 » 1.0.x-dev

  • smustgrave authored cca6383 on 1.0.x
    Issue #3169396 by smustgrave: Doesn't allow for Internal links
    
neslee canil pinto’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

dark_kz’s picture

Sti

dark_kz’s picture

Still not working in the 1.1 version

Only local images are allowed.

smustgrave’s picture

Can't reopen the ticket but I pushed up a new fix in that PR if you want to give it a shot. Borrowed a lot of the code from the core link widget.

neslee canil pinto’s picture

Hi guys, why is this merge request for?

smustgrave’s picture

Seems this issue was not resolved completely. Took another shot at it and believe it should be working now.

neslee canil pinto’s picture

Status: Closed (fixed) » Needs review

Ok I will be opening it again

neslee canil pinto’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

nick hope’s picture

Version: 1.0.x-dev » 1.1.x-dev
StatusFileSize
new16.52 KB

I am attempting to switch over from the older Block Title Link module because of lack of activity there with producing a stable D8/D9 version.

However I am also experiencing this issue in both 1.1.2 and 1.1.x-dev (5 Mar 2021) in Drupal 8.9.13. It will not accept internal links such as `/authorities`. When I try to save the block it just prompts "Please enter a URL".

Block Title Link will not accept internal link

I was able to enter this type of link in the other Block Title Link module (also with D8.9.13 and with this patch).

kazah’s picture

I confirm the internal paths still don't work! Drupal 9.1.7
I think you need to reopen the ticket.

neslee canil pinto’s picture

Status: Closed (fixed) » Needs work
anybody’s picture

Yep, I can also confirm #16

smustgrave’s picture

Not sure what happened but the changes in the PR https://git.drupalcode.org/project/block_title_link/-/merge_requests/1/d... aren't in the 1.1.x branch. But if you apply as patch does it work?

nick hope’s picture

@smustgrave The diff you linked to will apply to 1.1.2 (which I guess is the same as 1.1.x-dev - both dated 5th March), but the following error is thrown when visiting a Configure block page (in both Drupal 8.9.14 and 9.1.7):

Warning: get_called_class() called from outside a class in block_title_link_form_block_form_alter() (line 36 of modules\contrib\block_title_link\block_title_link.module).

block_title_link_form_block_form_alter(Array, Object, 'block_form') (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'block_form') (Line: 836)
Drupal\Core\Form\FormBuilder->prepareForm('block_form', Array, Object) (Line: 279)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 706)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Edit: I went ahead and checked it with 1.1.x-dev and the same error is thrown.

smustgrave’s picture

So part of the solution I took from core menu_link. Because this code is in the .module file I wonder if you can't call get_called_class from there.

nick hope’s picture

There may be inspiration in the older Block Title Link module, but it's a bit of a mess because not even a D8 dev version was ever released. But a working D8 version can be constructed using my patch against the D7 version. Internal links worked OK in it.

smustgrave’s picture

Opened up a new PR to try and address it. I'm sure there's a better way to get the url string then copying getUriAsDisplayableString but I couldn't figure out yet. Without that function the field still saves and validates but the value would have internal:: in the string

nick hope’s picture

#24 is working for internal links (by patching with https://git.drupalcode.org/project/block_title_link/-/merge_requests/2/diffs.diff), so thank you for that.

Regarding #20, get_called_class() has been completely removed from core and replaced with static::class (see here and here). So after patching with #20 I tried replacing '#element_validate' => [[get_called_class(), 'validateUriElement']], with the apparently-like-for-like '#element_validate' => [[static::class, 'validateUriElement']],. VSCode tells me 'Cannot use "static" when no class scope is active'. Which led me to this. Does it help? I'm not a coder.

smustgrave’s picture

I got the same error when i tried. I think it’s because we are in the modules file and that needs to be called in a class.

So maybe the module needs to be refactored to use classes vs hooks? Not sure myself

neslee canil pinto’s picture

@smustgrave got this error when it tried to access any block config page

Error: Class 'EntityAutocomplete' not found in getUriAsDisplayableString() (line 119 of /Users/Documents/sites/optimus/web/modules/custom/block_title_link/block_title_link.module)
smustgrave’s picture

Haven't had that issue. When I wrote that I was only Drupal core 9.2

neslee canil pinto’s picture

Add block title data to any of the block configs, save it, and then when you revisit it, this error is occurring, and I am also using core 9.2

nick hope’s picture

I haven't seen error #28 using Drupal 9.1.7/8. I'm only using this module for links on the titles of Hierarchical Taxonomy Menu blocks.

neslee canil pinto’s picture

Status: Needs work » Reviewed & tested by the community

Ok, we had to add use Drupal\Core\Entity\Element\EntityAutocomplete; , because of this error was occurring for me, will commit it and make a release soon.

neslee canil pinto’s picture

Status: Reviewed & tested by the community » Fixed

Committed to the dev branch, will create new release soon 👍🏻. Thanks.

smustgrave’s picture

Glad you got it working! Sorry I couldn't take a look. Work took all my time the last week.

nick hope’s picture

Thanks guys. 1.1.3 working fine in D9.1.8.

Status: Fixed » Closed (fixed)

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