Anchors #2137
Answered
by
tabuna
GlenWarren
asked this question in
Q&A
Anchors
#2137
-
Is there an existing way to add an anchor to a layout/element? Thanks |
Beta Was this translation helpful? Give feedback.
Answered by
tabuna
Feb 18, 2022
Replies: 1 comment
-
Hi @GlenWarren, You can use your component/view to define the anchor. For example: Layout::views('anchor', ['slug' => 'address']); and template: <a name="{{ $slug }}"></a> or the same with a component: namespace App\View\Components;
use Illuminate\View\Component;
class Anchor extends Component
{
/**
* @var string
*/
public $slug;
/**
* Create a new component instance.
*
* @param string $slug
*/
public function __construct(string $slug)
{
$this->slug = $slug;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\View\View|string
*/
public function render()
{
return <<<'blade'
<a name="{{ $slug }}"></a>
blade;
}
} Layout::component(Anchor::class), You can put links by specifying the address, for example: Menu::make('Anchor')->url('https://orchid.software#anchor');
// or
Link::make('Anchor')->url('https://orchid.software#anchor'); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
GlenWarren
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @GlenWarren, You can use your component/view to define the anchor. For example:
and template:
<a name="{{ $slug }}"></a>
or the same with a component: