Skip to main content

Questions tagged [routes]

Questions about how Craft handles a request.

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

Site baseUrl with locale and entry URI matching

Consider the following. I have two sites: site: the main site site_de: the German version of the site Those two sites have the following Base URLs: https://my.site.test https://my.site.test/de I ...
Low's user avatar
  • 557
0 votes
0 answers
20 views

Redirect to /commerce/payments/complete-payment returns 404

I've created a gateway with payment to an external payment provider (offsite). When the payment is successful I need a redirect to complete the order and payment to: /commerce/payments/complete-...
user3086053's user avatar
1 vote
1 answer
72 views

Can plugins have their own routes?

I'm writing a plugin. I'd like it so that a request to view the page is processed via a Controller rather than goes straight to a template (following an MVC pattern). So a GET request to the URL of ...
Chuck Le Butt's user avatar
1 vote
1 answer
135 views

Syntax for URL route instead of using url parameter

I'm confused by the syntax for URL routes. Using Craft 3. I'm working with two separate category groups and have urls like this: site.com/?parameter=123 site.com/abc?parameter=123 site.com/abc/xyz?...
Jake's user avatar
  • 43
1 vote
1 answer
179 views

Why is my custom route registering as a 404?

The context I have a URL schema that is either doing something new, via a custom Route (no entry set): bookings/new/* …or reviewing an existing entry: bookings/{slug} My custom route is working fine ...
Jonathan Schofield's user avatar
1 vote
1 answer
110 views

Website transfer places /web in all urls, cs and js not loaded when moved up directory

I just transfered my website from one server to one.com. Now nothing works anymore cuz apparently one.com wants the index.php in the root directory but my index.php is in the "web" directory....
Masary's user avatar
  • 11
2 votes
1 answer
65 views

How can i disable channel list url?

I have a channel type entry where I'm inserting services. I have created a channel and add route services/{slug} and added template services\_entry.twig. I want to keep url for single service as ...
Vinod Patidar's user avatar
2 votes
1 answer
181 views

Dynamic entries?

My website features music releases. On the homepage, it shows the current week of releases. It also offers the ability to go back to previous weeks and see the releases e.g. mysite.com/new-releases/05-...
fxfuture's user avatar
  • 279
1 vote
1 answer
106 views

Pagination breaking following update to Craft 3.7.X

Craft is no longer handling my pagination properly. This follows an update from somewhere around 3.4 to 3.7.X. {% set entries = craft.entries.section(sectionName) .orderBy('postDate DESC') ....
4midori's user avatar
  • 666
1 vote
1 answer
105 views

How can I use the final URI segment as an argument without losing the entry variable?

I have a Structure - Products - that contains multiple products, and each product contains different sub pages (details, pricing, etc). One section of the Structure is Details which is under each ...
kevindeleon's user avatar
3 votes
1 answer
1k views

Get entry associated with current uri

If I am visiting /recipes/spaghetti which corresponds to an entry in a recipes entry type and the recipes/entry template, is there a way to directly get the current entry's data from within the ...
Augustine Calvino's user avatar
1 vote
2 answers
169 views

Make page urls correspond to their structure

I set up a page entry type under Structures, and because this is for generic pages, I want it to be arbitrarily nestable. From the structure page, this is easy to set up; however, I want the urls for ...
Augustine Calvino's user avatar
1 vote
0 answers
704 views

Invalid Route in module

I'm new to craft and slowly learning how to use more advanced features. I'm trying to write a module with a controller. When the route is invoked on a fetch call I get the following error: HTTP 404 – ...
mauricio's user avatar
  • 187
1 vote
1 answer
188 views

Can some one explain Event rules in plugins

So here is what I see in a controller: $event->rules['cpActionTrigger1'] = 'plugin/default/do-something'; What does the first part 'cpActionTrigger1' refer to and what does the second part refer ...
joomkit's user avatar
  • 2,048
1 vote
1 answer
415 views

Why do i get an Invalid route error in cp when calling plugin action?

I have a plugin that has a menu and in backend which basically has a button that calls the plugins default controller actionXXXX method. The action does some database / api work then is meant to ...
joomkit's user avatar
  • 2,048
1 vote
1 answer
117 views

Using a language cookie with Craft

I work on a large, complex site that uses a cookie banner to store a language cookie. We have 11 different languages on the site. We use craft for only one part of our site, with our base URL for ...
Xarlos's user avatar
  • 11
0 votes
0 answers
167 views

Setting an entry in a dynamic route template

I have some routes i want to use like "/my-url/locationZ" "/my-url/locationX" This loads a template /dynamic.twig In the template dynamic I am trying to get the content from an ...
joomkit's user avatar
  • 2,048
1 vote
1 answer
118 views

URI with multiple URL formats (after slug)

Is it possible to have a URI like this: /artist/{slug}/news to create an overview of all news articles of this particular artist? I tried to set it up with Routes and with a section Entry URI, but I ...
Matthias's user avatar
  • 110
1 vote
0 answers
67 views

Route with unspecified number of segments

I have entry which has route like this: category1/category2/.../entry-slug There can be an unspecified number of categories - these are multilevel structure entries. I want to add an entry edit ...
Piotr Pogorzelski's user avatar
1 vote
1 answer
172 views

link twig template in a tag

I created two twig templates: home.twig and about.twig. in home.twig it's this code: <a href="/about">go to about template</a> and in about.twig it's: <h1>about</h1> when I ...
Cosmin Ciolacu's user avatar
1 vote
1 answer
130 views

Custom route with optional tokens

I have a question about custom routes set in routes.php. Can route segment be optional? Taking example from docs - 'blog/archive/<year:\d{4}>' => 'controller/action/path', can we make year ...
Piotr Pogorzelski's user avatar
1 vote
0 answers
44 views

How to append current version to post URL - versioning a post

I'm middle of a PWA app and one of the problems facing is versioning, once the post cached using Service Worker and if any change amended(ex: if it is an event post, the event end date may be extended....
Sameera Thilakasiri's user avatar
1 vote
1 answer
56 views

Filtering routes

I'm using following code to route urls to specific template '<restaurantSlug:{slug}>-nutrition' => ['template' => '_nutrition/restaurant'], is there a way to limit slug results to ...
Mark H.'s user avatar
  • 411
1 vote
2 answers
89 views

Routing and Segments

I'm using the following code for now: Route (in the control panel) recipes/{slug} loads _recipes/restaurant In the template to define the restaurant and list its items {% set restaurant = ...
Mark H.'s user avatar
  • 411
1 vote
1 answer
618 views

RegisterUrlRulesEvent rule to display site page

Within a plugin I have written I would like to route POST requests to the plugin controller and GET requests to a single entity created in craft. When the user POSTs to http://example.com/start-your-...
SloganHD's user avatar
0 votes
0 answers
412 views

How can i get the current applied route in CraftCMS?

I'm using a dynamic route that loads a template. I'm on a multisite setup with a language switch in the header menu. To be able to switch between sites or languages, the dynamic routes need to have ...
jan's user avatar
  • 101
1 vote
1 answer
252 views

Set Up Route to Template - then variable Entry is undefined

I've got a blog listing channel set up where I'm trying to filter entries listed by the entries field blogAuthors based on url segment. /articles-and-excerpts/ loads the blog fine added a route but ...
CreateSean's user avatar
  • 1,983
1 vote
1 answer
61 views

What is the best approach for multi categories filtering

I need a solution for a good filter approach in Craft. I used 3 Categories related to an entry (Project). The 3 Categories are (Type / State / Location) How do I have to set up the routes for the ...
thomas's user avatar
  • 81
1 vote
1 answer
828 views

Accessing named parameter in custom route from within a controller

I have a custom module in which I am setting a front end route that routes through to a controller. Like so: Event::on( UrlManager::class, UrlManager::EVENT_REGISTER_SITE_URL_RULES, ...
foamcow's user avatar
  • 2,029
1 vote
2 answers
440 views

Which twig file is being used and how?

I have a page in Craft (2.x) that displays several links and I was able to find which twig file had those links by searching the code base of twigs. Those links point to some Angular code with links ...
Pete Helgren's user avatar
1 vote
1 answer
44 views

Route to entry in Arabic not working but category route is OK

I have successfully managed to route Arabic categories to a custom template. The Arabic URLs appear RTL which is strange (and correct?), but I cannot get the Arabic single entry to pick up the ...
joomkit's user avatar
  • 2,048
1 vote
1 answer
505 views

Generating a precache manifest for service workers

I'm thinking of using Google's Workbox to pre-cache a bunch of files, and I've been scratching my head as to how to generate unique hashes for files when they change. Something like this: workbox....
Paul's user avatar
  • 339
1 vote
1 answer
105 views

How to make a multiple route?

Can't figure out how to create a dynamic route for the categories in this format: site.com/news/category-1-and-category-2-and-category-3 That would bring the results from these slug categories. ...
lolipop's user avatar
  • 11
2 votes
1 answer
484 views

How to create an advanced route with query strings?

I have a main structure as my navigation. Within this structure I have multiple image galleries. I want to make the image gallery's urls dynamic. If I define a gallery within the structure entry: ...
outline4's user avatar
  • 595
1 vote
1 answer
38 views

Display Relating Entry based on Page Routing

I'm trying to create a submission page at the following URL structure /campaigns/this-is-a-test-creation/submissions As you can see /campaigns/ is the Channel and the /this-is-a-test-creation/ is ...
JMKelley's user avatar
  • 1,426
1 vote
2 answers
478 views

When using Settings -> Routes in the CMS with wildcard, routes.php does not work

Not sure of this is intentional or a bug but, when we add a route using Settings -> Routes in the CMS, routes.php does not work. I guess maybe its due to us using a wildcard and this takes presedence ...
Laurence Cope's user avatar
1 vote
1 answer
573 views

Routing: How can I ignore a parameter in route definition?

I'm trying to route users to a "locations" structure entry that normally has a URL structure that looks like: locations/<slug> My client wants to use the structure of links from their old site ...
slander's user avatar
  • 73
1 vote
1 answer
408 views

Good way to handle multisite fallback templates

So I've got a multisite going on. For most of the sites, most of the time, they'll be using the same templates. But I want a good way to handle siteX needing one template to be different from the ...
mijewe's user avatar
  • 336
1 vote
1 answer
317 views

Variable "entrySlug" does not exist Routing

I currently have a routing set up as follows to enable an "Edit" entry page following on from this question but I'm getting the following error message when going to that page. Variable "entrySlug" ...
JMKelley's user avatar
  • 1,426
2 votes
1 answer
337 views

Set a route for all requests within a plugin

I’m trying to use a plugin to set up a site route that will direct every page request to a special template. This is what I’ve set up in my plugin file. public function registerSiteRoutes() { ...
foamcow's user avatar
  • 2,029
1 vote
1 answer
902 views

Templates, Routes, and URL segments

In EE, if there was a template /foo/bar.html, one could access the contents of that template by going to either example.com/foo/bar or example.com/foo/bar/more/segments/here. The additional URL ...
Sandwich's user avatar
  • 636
1 vote
0 answers
87 views

Add optional segment to Craft Commerce product Url

I currently have a Craft Commerce site where the product url is setup like this: {productCategory.level(1).first().slug}/{productCategory.level(2).first().slug}/{productCategory.level(3).first().slug}...
Steve Holland's user avatar
1 vote
1 answer
685 views

Resolving the $entry variable for custom routes somewhere but a Twig template

I have several custom routes defined on the routes.php and, as usual, I am resolving the value of the template's entry in the Twig template when it is not defined (which is when it doesn't match a ...
Rosana Ruiz's user avatar
1 vote
1 answer
293 views

Singles or routes solution

Most websites have three distinct types of page. List of items Item Special layout of items / content A list of entries require a list view. Craft lets us do this with singles - eg blog index page. ...
joomkit's user avatar
  • 2,048
1 vote
1 answer
707 views

Craft 3 multi-site route to template (no entry)

I have a Craft 3 multi-site site - / for the main site, /site1/ for site1, etc. I have a template templates/foo.twig, and /foo hits it for the main site, but /site1/foo does not hit it for site1. I ...
Marion Newlevant's user avatar
1 vote
1 answer
268 views

Setting up routes for AMP template with category-based urls

I'm stuck on implementing AMP templates with category-based URLs as I can't find a way to route the different entry types in the Routes function in the CP. I have a channel title Articles that has ...
Scott Carr's user avatar
2 votes
2 answers
522 views

Wildcard subdomain for posts

I want to assign a wildcard domain to every entry from a specific type. For instance: client.example.com Where client is the slug of an entry. Is that possible? If yes, how? Thanks!
Jim's user avatar
  • 21
1 vote
1 answer
2k views

Craft 3 with Multi-Site: how to not set a primary site, or add a first segment to all primary site URLs?

I have a main domain, www.mycompany.com, which has several groups of sites, which are available in several languages: www.mycompany.com/international www.mycompany.com/sales/en www.mycompany.com/...
Romain P.'s user avatar
  • 1,917
1 vote
2 answers
193 views

Advanced routing

I am trying to do this. Have a structure url like so: /{id}-{slug} and /{parent.id}/{id}-{slug} I need the slug on the url but I only for SEO, I want craft to ignore the slug and only go for the ID. ...
Evangelos's user avatar
0 votes
1 answer
2k views

Dynamic Entry URI's for pages

This is probably very straight forward but unfortunately I can't seem to solve it. We want to create a dynamic URI structure that allows us to easily create pages and link them with parent ...
James N's user avatar
  • 21