HtmlHelper link with anchor target


#1

Hi

I would like to build a link with an anchor target to jump to a specific place on an other page.

Ive tried using the # as stated in the documents:

['controller' => 'documents', 'action' => 'index', '#' => $document['slug']]

but it doesnt work :frowning:

# Invalid path provided; must not contain a URI fragment

Whats wrong here?

I am using latest CakePHP 3.6

Thanks,
Frank


#2

i dont see this error in cake source https://github.com/cakephp/cakephp/search?q=URI+fragment&unscoped_q=URI+fragment

are you sure its from cake?


#3

Thanks for your hint: Interesting - its from Zend:

\vendor\zendframework\zend-diactoros\src\URI.php

Its installed through cake…so what now?

Frank


#4

ive checked it on 3.6.13 and it works for me,

<?= $this->Html->link('test', [
  'controller' => 'Home', 
  'action' => 'index', 
  '#' => 'test'
]) ?>

you need to give more code at this point