Antlers Tag
Runway provides a{{ runway }}
Antlers tag to enable you to get model data for your resources.
For example, if you wish to create a listing/index page for a resource, you can use the tag like shown below:
Sorting
You may use thesort
parameter to adjust the order of the results.
Eloquent Scopes
If you’ve defined a scope on your Eloquent model and you want to filter by that in your front-end you may use thescope
parameter.
argument
can either be a string or we’ll grab it from ‘the context’ (the available variables) if we can find it.
You may also provide multiple scopes, if that’s something you need…
Filtering
Just like with the collection tag, you may filter your results like so:where
parameter. Simply provide the ID(s) of the related models.
where_in
parameter to filter by multiple IDs.
Eager Loading
If your model has a relationship that you’d like to bring into the template, you may specify thewith
parameter.
Eager Loading can make a massive difference in the speed of your queries.
Limiting
If you only want X number of results returned instead of ALL of them, you may specify alimit
.
Scoping
As with the collection tag, you may use theas
parameter to scope your results.
Publish State
By default, when you’re using Runway’s Publish States feature, only published models are included. Models can be queried againstpublished
or draft
status with conditions on status
like this:
Pagination
If you want to paginate your results onto multiple pages, you can use thepaginate
parameter, along with scoping and limiting.
Using the Runway tag with pagination is a little more complicated but it’s not rocket science.
Counts
When you just want to know how many results you have, you can use the{{ runway:count }}
tag.
where
parameter to filter the results:
Blade
You can even use Runway’s tag in Blade views, thanks to Statamic’s Antlers Blade Components feature (available in Statamic 5.36 and above):Augmentation
All the results output from the Runway tag are ‘augmented’, which essentially means everything is the same as you’d expect if you had the same data in an entry. The process of augmentation takes a value (from the database in our case) and processes it via the fieldtype into a value appropriate for the front-end. Let’s imagine you have an Assets field in your blueprint, you may have something selected for the field. In the database, the path to the asset is stored. When this field is then augmented, Statamic does a lookup of the asset by it’s path and spits out variables likeurl
, alt
and a couple of others.
(There’s another explanation of augmentation over on the Statamic documentation)