medienbaecker / kirby-link-field

29 stars 2 forks source link

Add option for popup link #13

Closed hdodov closed 5 years ago

hdodov commented 5 years ago

When you link to external sites, you might or might not want that link to open in the same window. I think it'd be great if you can manage that with this field.

In the panel - simply show a checkmark when the link type is an actual document (URL or Page) and not email, tel or file.

In the PHP code - perhaps add a toLinkAttributes() method that returns just the HTML attributes, not a full <a> tag, because that would be pretty limiting.

For example:

mylink:
  type: page
  link: my/page
  popup: true

...and when you invoke $page->mylink()->toLinkAttributes(), you get:

href="https://mysite/my/page" target="_blank"

In your template, you use it like:

<a <?= $page->mylink()->toLinkAttributes() ?> class="my link classes">
  my <span>content</span>
</a>