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

Questions tagged [routes]

Questions about how Craft handles a request.

0
votes
0answers
29 views

PHP error on URL routing - 404 page not found

I've suddenly got PHP errors on some, but not all, 'static' URL requests. The solution was to add routes for these URLs. Craft should automatically find directories that match URLs, so what would be ...
1
vote
1answer
21 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" ...
0
votes
0answers
20 views

Using asterix token in a routes file

Using a routes file in Craft 3 rather than the CP to manage routes. I need to to have an asterix token in my uri and have tried the following: 'users/*' => ['template' => 'users/_entry'] 'users/...
2
votes
1answer
25 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
78 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
20 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
80 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
102 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. ...
0
votes
0answers
83 views

Hosting an Angular App in Craft

I am new to Craft cms. I am trying to host an angular app in Craft but I am having issues with the routing. I created a single page in craft called /app and created a template folder called app. When ...
1
vote
1answer
158 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
107 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
94 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
367 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
78 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
386 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
32 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
38 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
122 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
86 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
126 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
138 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:...
4
votes
1answer
239 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
75 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
85 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
202 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
2answers
791 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
542 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
102 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
130 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
180 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
122 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
84 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
393 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/( ‘...
3
votes
2answers
143 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 ...
0
votes
0answers
49 views

Duplicate urls for zh_cn locale

I have an environment out of three that seems to be duplicating the url on every page for a specific locale. http://stage.website.cn/stage.website.cn/ This occurs within the cms and on the rendered ...
1
vote
1answer
87 views

How can I set up a filter URL like example.com/category/foo/type/bar/country/usa

Given a category based set of entries/products, and a filter system based on tags, how would I accept (one of) the following urls and let one template process them all (not interested in the ...
1
vote
1answer
70 views

Possible to use REGEX Backreference in Routes

I've searched and searched for info on regex backreferences in Craft's route.php file to no avail. I have a URL structure required by the client along the lines of: / [state] / [section] / region / ...
1
vote
2answers
938 views

URL drops :8888 from localhost

I'm running Craft CMS with MAMP at localhost:8888. When I pass in a URL with {{ entry.title }}, I get http://localhost/news/2016/we-just-installed-craft which gives me a 404 until I manually put in ...
1
vote
1answer
341 views

Use of tag.slug instead of tag.title in a custom route

I've followed this guide for creating a routes to list entries with specific tags. It is working fine except that I have muli-word tags so using the tag token from Settings -> Routes gives me urls ...
1
vote
1answer
56 views

Using the same title

I have an article called Main Article and I am rolling out the chapters each week (8x). So, each chapter will have the MAIN Article Title AND Chapter Title. eg: Stories from the top of the World; The ...
4
votes
1answer
342 views

Simple template routes with plugins

I'm attempting to create a simple route that points to a template from a plugin. Note that I am attempting to create a page on the front-facing website, not the admin panel. Plugin (named: 'curious') ...
1
vote
1answer
132 views

Can't open new single section

I created a new Single section and named it "test", added some content and tried to view it on domain.com/test. Unfortunately I get my default server 404 and not the new single section. I tried to ...
0
votes
1answer
109 views

Single not loading correctly with additional segments

I've got a single set up to point to /calendar on my site. the single has only one field, SEOmatic so I can add meta title, description etc.. the rest of he page is loaded with content from the ...
4
votes
1answer
217 views

Redirect entry type to another domain

I have an entry type (outsideCourse) that will never need its own page. It only exists so I can manipulate it in various lists of required courses. Thanks to Mats Mikkel Rummelhoff, I have a macro to ...
0
votes
1answer
172 views

How to setup custom site routes created by user in plugin settings

In my plugin settings I am allowing the user to specify url formats for each locale along with desired template path, much like sections. How do I then register those custom url formats as site ...
2
votes
2answers
518 views

Multiple URL Formats per element type (Entries, Categories)

I suspect this boils down to a feature request, but I'll start here in case there are any other ideas. Basically, I want to be able to define multiple URL formats for a single section or category ...
2
votes
1answer
244 views

Best solution for articles tag page?

I've been looking through the forum, it seems there's a few methods to retrieve a tags page but I'm looking for the most efficient method (both speed- and template-wise). Using tag.name with tag ...
5
votes
1answer
105 views

Is environmental routing possible?

In the general.php config file, I can target settings for multi-environments like so: return array( '*' => array( 'devMode' => false ), '.loc' => array( 'devMode' => true ...
1
vote
1answer
110 views

Advanced routing descriptive URLs to certain pages/posts

This is a general SEO question. In Wordpress you can create a page and define the permalink URL. In Craft I want to do something similar. I want to build the backend with a common sense structure, ...
1
vote
3answers
1k views

Different template for an entry in section

If I have a Section called "Pages" that uses the "page.html" Entry Template. How do I override that template for a single page in this Section? I thought I would be able to use Craft Routing but ...