How to check in Antlers views if a route exists? #11850
Replies: 4 comments
-
What are you actually trying to do? |
Beta Was this translation helpful? Give feedback.
-
I was wondering if there is an Antlers alternative (not {{? ... ?}}) for the solution below.
|
Beta Was this translation helpful? Give feedback.
-
You could probably just check the url instead of route, like {{ if segment_1 == “dashboard” }}On Jun 7, 2025, at 7:53 AM, Iurie Malai ***@***.***> wrote:
I was wondering if there was an Antlers alternative for the solution below.
{{? $route_exists = Route::has('dashboard') ?}}
{{ if $route_exists }}
<li class="relative leading-none" x-data="{ subnavOpen: false }">
{{ partial:navigation/auth_main }}
</li>
{{ /if }}
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I assume that {{ if segment_1 == "dashboard" }} will work when you actually access a link/page with the "dashboard" segment in the URI, but not when you want to anticipate the existence of that segment, without accessing it, which is what I want. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way in Antlers templates to check if a route exists, for example to conditionally show a link? I can't find anything like that.
Beta Was this translation helpful? Give feedback.
All reactions