Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [getsegment]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
60 views

Categories Structure for Landing Pages

I'm using a category group and routes to serve up entries on landing pages with a URL structure like this. www.domain.com/properties/retail/freestanding My code works, but I am wondering if there's ...
1
vote
1answer
190 views

How to write a segment that is not two other segments

How can I write: is segment 3, and is not itemA and is not itemB? both itemA and itemB are segment 3 as well. {% if craft.app.request.getSegment(3) and craft.request.getSegment(3) !== 'itemA' and ...
1
vote
2answers
271 views

Get Entries From Any Section Matching a URL segment

I have 2 issues that I need help with: I want to load ENTRIES from any section where the first URL segment of the entry matches jobs. I am using the code below to load any SECTION where the first URL ...
2
votes
1answer
170 views

Partial match in URL getSegment()

Is there a way to partially match text in a URL segment? I would like to conditionally show code if the text "vascular" is in Segment 3. If my URL is: https://website.com/segment1/segment2/10009-...
2
votes
1answer
88 views

getSegment matching category title

I'm trying to match the 2nd part of the slug with the category title to then place a 'current' class on the link. Something like: {% nav category in craft.categories.group('blogCategories') %} &...
1
vote
1answer
137 views

Using getSegment

Can anyone shed any light on why the following doesn't work for getSegment(2) but the previous does for getSegment(1)? URL structure for these two examples are: root.com/blog root.com/blog/trends ...
1
vote
1answer
812 views

Output getSegments() array in template

Is it possible to output a getSegments() array in a template to then run conditions on? I can output one segment fine using getSegment(), but if I try to select one or more segments using getSegments(...
1
vote
2answers
652 views

Filter entries by matching an url segment to Checkboxes Field values

I have succsefully managed to filter entries by matching an url segment to a Radio Buttons Field in my entries, like this: (here category is the field handle of my Radio Buttons field) {% set ...
1
vote
1answer
272 views

Having trouble setting/getting slug

I am trying to get a certain segment of the url. For this i’m setting the slug as a variable which seems to be best practice: {% set slug = craft.request.getSegment(2) %} I am interested in the ...
13
votes
1answer
6k views

Get category title by slug

I'm setting my categories by matching the third segment to a category slug. How do I get the category title? {% set catSlug = craft.request.getSegment(3) %} {% set category = craft.categories.slug(...
4
votes
1answer
313 views

Better way to find a specific asset?

I'm currently using a route to get a specific asset for a gallery section of my site. URL is similiar to http://craft.dev/place/place-name/gallery/1 (Where 1 is the number in the gallery.) I'm ...