Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

The tag has no usage guidance.

1
vote
2answers
16 views

How do I remove segment 1 in my URL AND get the parent URI?

I have a structured group of pages in a static channel that I would like to display without "static" in the URL and show the parent URI. This is my structure: patients-visitors ---- our-stories ------...
1
vote
1answer
63 views

Template logic to address a third URL segment

I'm using Craft 3, and I'm struggling to make sense of how to address the following. (I've not had need to venture into a third URL segment before.) I have a url of the form: stories/{slug} served ...
1
vote
1answer
46 views

Locale URL segment being duplicated, eg https://website.test/en/en/

Problem I have a problem on a local Valet setup: the locale URL segment is appearing twice in URLs. Eg from a page at URL of en/about/approach, {{ url('about/approach')}} outputs https://website....
1
vote
1answer
35 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 ...
3
votes
2answers
260 views

Trimming lastSegment from a URI trims that PLUS the last number of the previous segment

I am fairly new to twig and templating with Craft (and I have inherited this code, so that makes it even more fun). I have a calendar page that lets you filter the events in the calendar based on a ...
4
votes
2answers
1k views

How to get a URL segment

I can see that craft.request.firstSegment and craft.request.lastSegment works but craft.request.secondSegment does not. Is there a way (as in ExpressionEngine) to get the value of any URL segment?
1
vote
1answer
39 views

Is it possible to change one segment of the current url and keep the rest of it the same in a cleaner way?

How would you go about changing one segment of the current url? I have a select in the footer that you can click on a country name and then it redirects you to the homepage of that country version of ...
1
vote
1answer
84 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
1answer
312 views

Use url segment as querystring parameter [Craft 3]

I have mysite.com and I need to use a segment as if it were a querystring parameter for accomplishing this: mysite.com/us -> same template as: mysite.com mysite.com/pricing/bz -> same ...
1
vote
1answer
109 views

Custom routes using kebab {type} in URL segment

I have a section that has multiple entry types. I would like to use kebab-style url segments in the URL format. I can get the articles to serve kebab URIs using this for the section's Entry URL Format:...
1
vote
1answer
61 views

AMForms Action URL

I'm setting up landing pages in Craft where someone can fill out a very basic form and get an eBook. My idea was to have the form /info/landing-page-title submit to /info/landing-page-title/thank-you,...
0
votes
1answer
78 views

Exclude entry based on segment

I am trying to exclude the current entry in a "Recommended Reading" section which works at level 1 with the ID tag, but I also need it to do the same at level 2 (children). `{% for entry in craft....
1
vote
1answer
271 views

How can I get all child categories - of a child category based on url segment?

I am missing something very obvious I think. I am trying to get all child categories based on url segment. For example: "mysite.com/foo" I have a category Group called Sections Within Sections I ...
0
votes
1answer
26 views

Filter out part of _layout on a specific template

I have a site consisting of 15 templates, all of which extend _layout.html. There is just one page (homepage) which needs to omit a chunk of the _layout.html. Is there something I can add to _layout ...
3
votes
1answer
286 views

Override a wildcard dynamic route template

I have a dynamic route for individual user /profiles. I expected it would be possible to override this route for /profiles/all but apparently not. This can be achieved in the template I expect, with ...
2
votes
0answers
276 views

Checking if a value matches an entry type handle

I am trying to check if a value provided by the user (url segment) matches an entry type, and if not redirect to 404. {% set section = craft.sections.getSectionByHandle('shop') %} {% set entryTypes = ...
2
votes
1answer
397 views

check if a route segment matches a section entry type

So i added a route to a template that shows entries by entry types. the way the template does it is by taking the last segment of the url, and using it as an entry slug for this filter: craft.entries....
2
votes
2answers
228 views

Setting a variable assets field, depending on the URL?

How can I set different assets fields depending on the URL? I tried: {% if craft.request.getSegment(1) == 'special' %} {% set assetfield = variantfield1 %} {% endif %} {% for asset in entry....
2
votes
1answer
262 views

Segment to filter through categories slug

I've seen plenty examples of using the uri segment like below, but it ain't working for me, anyone had same sort of issue? {% set segment = craft.request.segment(2) %} {% set pageCats = craft....
1
vote
1answer
947 views

How to get an entry title and URI from a segment in order to create a breadcrumb navigation

Is it possible to get an entry title and URI from a segment? e.g. If segment 1 has a value of 'about', I'd want to output an entry title of 'About Us', and a URI of 'mysite.com/about', and so on for ...
7
votes
1answer
1k views

How to use url segments like with Freebie in EE

I'm trying to make the jump from EE to Craft but struggling in this area (and thinking I may be approaching this all wrong). In EE, I often use url segments (in combination with Freebie to ignore ...
3
votes
0answers
572 views

Filter entries with segments and params based on categories and fields [closed]

I'm working on a webshop with an advanced filter / search with multiple categories, entry types and fields and sorting options. Schematic URL site.com/template/entry.type/category/?size=category OR ...