You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, that would be the only way to uniquely identify by type.
There is also {% if block.ctaButton.displayName() == 'Entry' %} but that's not unique and also gets translated. Depending on your scenario it may be another route.
I'm happy to introduce another mechanism that's a little more user friendly; I just need to keep third party link types in mind.
Off the top of my head I thought of introducing another attribute getShortType() or getType(). It wouldn't result in a unique reference, but you would know the link types installed and could handle appropriately. By default, this would produce the last part of a class name. Ex 'flipbox\craft\link\types\Entry' => 'Entry'.
To elaborate on the non-unique short type reference; someone could create their own link type with the class: your\namespace\Url which would result in two 'Url' short types (the other would come from 'flipbox\craft\link\types\Url'). Again something the developer would know and can account for; a rare scenario I assume.
Thanks for your response! I definitely understand your point about the non-unique short type references.
For my purposes, your proposed solution would work. I was more or less looking for something like that when I gave up and used the long form check.
Whatever you feel is best works for me. I've solved my problem with the solution in my initial post, but I bet it would save others some time if the type checking were simpler and more obvious.
Is there a simpler way to check what type of Link has been chosen other than something like this?
The text was updated successfully, but these errors were encountered: