Questions tagged [routes]

Questions about how Craft handles a request.

Filter by
Sorted by
Tagged with
1
vote
1answer
34 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 ...
1
vote
2answers
43 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 = ...
0
votes
0answers
18 views

Can't route to template

I have a global route set in craft 3.4 cp The url doesn't actually contain an entry it contains content from another craft site fetched by the API. My url is "companya/resources/steps-to-positive-...
1
vote
1answer
32 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-...
0
votes
0answers
37 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 ...
1
vote
1answer
35 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 ...
1
vote
1answer
28 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 ...
1
vote
1answer
46 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, ...
0
votes
0answers
38 views

Product URL does not change after updating its related category slug

I have Commerce Products set to use the following Category URI structure: {relatedPage.first().uri}/{slug} What this does is, allow us to relate the Product to an Entry and take the entries URL ...
0
votes
0answers
40 views

Homepage is blank

Craft CMS 2.6.3017 I'm very new to Craft, so forgive me if this is a bit basic. I've cloned an existing Craft CMS site for a customer and set the site up so that 'index.php' is omitted from URLS. ...
1
vote
2answers
58 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 ...
1
vote
1answer
21 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 ...
1
vote
1answer
163 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....
1
vote
1answer
55 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. ...
2
votes
1answer
116 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: ...
1
vote
1answer
23 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 ...
1
vote
2answers
109 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 ...
1
vote
1answer
91 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 ...
1
vote
1answer
100 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 ...
1
vote
1answer
166 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" ...
2
votes
1answer
73 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() { ...
1
vote
1answer
288 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 ...
1
vote
0answers
44 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}...
1
vote
1answer
383 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 ...
1
vote
1answer
194 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. ...
1
vote
1answer
365 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 ...
1
vote
1answer
198 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 ...
2
votes
1answer
225 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!
1
vote
1answer
886 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/...
1
vote
2answers
116 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. ...
0
votes
1answer
685 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 ...
1
vote
1answer
34 views

how to reroute old html pages?

I want to reroute old html pages. The format is: /title-35-of-page.863.en.html I want to route every adresse with .html at the end also get the lang and id part of the address for further handling, ...
1
vote
1answer
55 views

Use different template for same route based on user group

I'd like to have consistent URL's for an account section but depending on the current users group, the template will be different. I know I could use the same template but there would be a lot of if/...
1
vote
1answer
215 views

Loading entry based on dynamic route

I'm trying to load an entry based on the following url: /artists/nameOfArtist/nameOfCategory/myEntry/thumb This URL follows the structure of my entries: Artist > Category > Entry So, I'm thinking ...
1
vote
1answer
182 views

Specify which template/layout to use based on URI segment

I have 3 level structure for my entries with separate template for each level. /artists/artist-name/ uses artists/_types/artists.html template /artists/artist-name/section-name/ uses artists/_types/...
1
vote
1answer
231 views

How to get a proper tag Url

I use the code "Link to the Tag URLs" from the following article: https://craftcms.com/support/tag-urls {% if entry.tags | length %} <h3>This entry is tagged with:</h3> <ul> {% ...
1
vote
1answer
238 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:...
3
votes
1answer
486 views

How do you handle routes in CP with Query Parameters?

I am currently setting up routes for a one-page application. As soon as a Query Parameter is introduced, the route fails. The route "test" replaces "my-av1" in the following photos. The documentation ...
1
vote
1answer
98 views

Search going to /index.php?q= instead of results

I've pushed my site to Digital Ocean from Localhost, the site is all up and running - URL's are all working. But when I try and search the site it seems to be heading to http://123.456.789/index....
1
vote
0answers
107 views

Alter the routing in Craft for every URL independent of language

How can I alter the routing in Craft? I need to add a (variable) segment to every possible URL. The reason is we have a multi lingual site with multiple regions. We need to know the correct region in ...
0
votes
1answer
381 views

How can I have a dynamic uri segment for a single?

I am trying to have a dynamic uri segment for a single. I have this uri in the CP settings: offers/listing/{slug} Where {slug} is the entryId. For example, offers/listing/1234 I have a template ...
3
votes
3answers
1k views

Routing within a single page app integration

I'm using Craft as the backend for an app and VueJS along with Element API to deliver the content. Everything so far is working sweet, except when I try to pull up the detail page for an entry ...
3
votes
2answers
984 views

Catch-all routes based on template structure

I have many of the templates organized into sub-folders. E.g. /manager/entries/edit.html, /manager/users/edit.html etc. The site is using 4-segment URLs to access code in those templates, e.g. http://...
0
votes
1answer
131 views

How do I set a controller for my homepage

How can I set a controller for the homepage? I can't seem to find any way to override the default route to the homepage. I need to call an action from the homepage and can't find any examples of this ...
1
vote
1answer
222 views

Dynamic entry template not loading on staging site but works on local.dev

I'm having a strange issue where pages aren't loading on the staging site that were all working fine on the local.dev site. I have a Section called Available Homes and in that section it has two ...
1
vote
1answer
216 views

craft()->urlManager->setRouteVariables() loads the correct template but does not pass in the variables

everybody! setRouteVariables() doesn't appear to be working for me. If I boil my controller function down to just this: public function actionSubmitForm() { craft()->urlManager->...
1
vote
1answer
191 views

Running Craft from two subdirectories

We are trying to add Craft alongside another CMS. I currently have Craft setup with the Craft app directory above web root and then two web accessible sub-directories as follows: blog offer Each ...
1
vote
1answer
101 views

Route to User page from first segment

I am building a site for a travel agency. Each agent needs to have his/her own public profile page. I want each agent's profile page to be accessed at agencyname.com/agentname, with agentname being ...
0
votes
1answer
553 views

Confused about tags

I'm tried to following the how-to implement tags but can't see to get it to work. The how-to: https://craftcms.com/support/tag-urls I created a new route, and in the URI field, I entered: tags/( ‘...
2
votes
2answers
224 views

Prettify search URL

I can't find a way to clean up the search address from /search/?q=.../ to /search/query/. I see ways of getting the last segment of the url with something like craft.request.getSegment. My other ...