Hubes
1
Hi there,
how can I create absolute links from my CakePHP 4 project to a external web page?
For my internal links, like Nav Bar and so on, I’ve used:
<?= $this->Html->link(
'displayedNameOfTheLink',
['controller' => 'pages', 'action' => 'myPage', '_full' => true]
) ?>
That’s the way from the Cook Book and it’s working well.
I didn’t found descriptions to set an external link…
Regards,
Hubes
Jawfin
2
The ['controller' => 'pages', 'action' => 'myPage', '_full' => true]
parameter is the link - it’s just getting resolved for you. So you can do -
<?= $this->Html->link(
'CakePHP',
'https://cakephp.org'
) ?>
Hubes
3
Hi Jawfin,
thank’s for your answer! It works now.
I’ve extended your code snippet to this:
<?= $this->Html->link(
'CakePHP',
'https://cakephp.org'
['target' => '_blank', '_full' => true]
) ?>
Now it is exactly what I need.
Have a nice day 
Regards,
Hubes
2 Likes