medienbaecker / kirby-link-field

29 stars 2 forks source link

Add toHtml() support for other field types #11

Closed hdodov closed 5 years ago

hdodov commented 5 years ago

With this change, it'll be easier to incorporate the plugin. For example, I was using fields with type url everywhere and once I started using toHtml() I began to get errors for undefined index "type" and "link". Besides, the $field->yaml() function was called twice, which was redundant.

With this, you can use toHtml() on fields of type url and text as well.

If no valid value can be found, it will simply return a blank value. You'll know the link is broken/missing when it leads you nowhere.

medienbaecker commented 5 years ago

Great work!

I always checked if link is defined in the template/snippet code. That way I could either display the button or not. But I agree an empty value is cleaner.