Skip to main content
10 votes
Accepted

How to get second last url segment

You can use negative numbers as the parameter for segment which then counts from right to left. So {{ craft.app.request.segment(-1) }} will get the last segment. And... {{ craft.app.request.segment(-...
foamcow's user avatar
  • 2,029
9 votes

Using pagination on a page with url with query string data

In most Craft projects I do I'll create a pagination include file so anything I need that requires pagination, I can just include that and I get the same pagination pattern anywhere within my site ...
Tim Knight's user avatar
  • 1,022
7 votes
Accepted

How to remove index.php?p= permanently?

Taken from this answer on Stack Overflow: .htaccess mod_rewrite: rewriting querystring to path <IfModule mod_rewrite.c> RewriteEngine On # Remove index.php RewriteCond %{...
Alex Roper's user avatar
  • 2,642
7 votes
Accepted

Entry URL Format

There are two ways you can set that up, depending on whether you want Brand entries to have a similar URI format (just without the 3rd segment), e.g. category/brand. Assuming you do, edit your Brands ...
Brandon Kelly's user avatar
7 votes
Accepted

Asset (image) public URL does not work

The issue is that your Asset Volume URL is @web/image but your Asset Volume path is @webroot/assets/art That means that Craft will look for the images on disk (to do transforms, etc.) in web/assets/...
andrew.welch's user avatar
  • 11.6k
6 votes
Accepted

If page conditions

Both titles can not appear in your condition(on the homepage). Always only one true statement is executed. To your problem: there is one global variable that solves your problem. {% if craft.request....
Dominik Krulak's user avatar
5 votes

I am unable to correctly return the url of an uploaded asset

I found the answer in a similar post here: Image asset url is not being output My problem was with my Asset Source settings. Now that I think about it, it's obvious: I had no public URL declared for ...
Steven Thate's user avatar
5 votes
Accepted

The requested URL was not found on this server

Try going to yoursite.com/index.php/(pagename). If that works, check out this article on how to remove it: https://craftcms.com/support/remove-index.php
strandall's user avatar
  • 188
5 votes
Accepted

Use global values in the Entry URL Format field

Your CraftCMS global can be accessed using the code {{craft.globals.getSetByHandle('siteDefaults').artworksList.first.uri|default}}/{slug} I believe the issue is that the Entry URL field requires ...
Regan Lawton's user avatar
5 votes

Change posts url without losing SEO positioning

Migrating Redirects should not be thought of as a one-time event but a process that includes a step where you make sure Redirects are in place and working. A rough redirect strategy Take a snapshot ...
Ben Parizek's user avatar
  • 13.5k
5 votes
Accepted

Why is $DEFAULT_SITE_URL appearing in entries URL?

You probably have a misconfiguration in your environment variables - First go to the control panel and check what you have under Settings > Sites > [choose site] > Base URL. If it's set to an ...
James Smith's user avatar
  • 5,344
4 votes
Accepted

Including two category slugs in entries’ URLs

Set your section’s Entry URL Format to this: {mySection.first.slug}/{myCategory.first.slug}/{slug} mySection.first and myCategory.first will give you the first-selected category within those ...
Brandon Kelly's user avatar
4 votes

Add home page to a structure?

From an IA and content-modelling perspective, putting all your site's "pages" in a Structure is fraught with problems, and, in my opinion, does a terrible disservice to the future-friendly approach ...
James Smith's user avatar
  • 5,344
4 votes

Strange 'index.php' Issue

This recently tripped me up. 'true' (with quotes) is not the same as true (without the quotes). Lose the quotes in the config file, clear Craft's caches, and it should stick. Also make sure your ...
RitterKnight's user avatar
  • 6,582
4 votes
Accepted

provide a 'back' or 'cancel' or 'close' button to return to whatever page that particular template was accessed from

You could use the Cookies plugin to store the last visited URL before the user hits one of the "step" templates, i.e. by putting something like the following in every template where the links to the "...
Mats Mikkel Rummelhoff's user avatar
4 votes
Accepted

Setting channel url format to include value of entries fieldtype URL

It needs to be: {destination.first().slug} Or if this is for Craft 3: {destination.one().slug}
Brandon Kelly's user avatar
3 votes

Multiple URL Formats per element type (Entries, Categories)

So semantically, I don’t love the URL format you’re coming up with. I’d like to see something like /gear/{category}/{entry} This gives you a few benefits it’s semantically readable… it gives you ...
andrew.welch's user avatar
  • 11.6k
3 votes
Accepted

Adding .html to end of page url?

You can change your entry's URL format right inside Craft. It's under Settings -> Sections then choose the section you want. Under URL Format, just add .html after the {slug}. In this example, I'...
RitterKnight's user avatar
  • 6,582
3 votes
Accepted

URL drops :8888 from localhost

I would try and put the port in your siteUrl config param: 'siteUrl' => 'http://localhost:8888', Alternatively you might be able to use this though haven't tested it (I believe the php server ...
joep's user avatar
  • 610
3 votes

Entry Types Custom Slug

You can use twig filters in url structures as mentioned by RhealPoirier in a comment above, no need for a plugin: my-section/{type.handle|replace('/(^|[a-z])([A-Z])/', '\\1-\\2')|lower}/{slug} or ...
plankguy's user avatar
3 votes
Accepted

What's the best way to build URLs for dynamic content collections?

You need that custom route. With the dynamic URI setting the "entry route" is generated dynamically on entry save, but it stores a single, fixed route only. But you don't have to miss out on Live ...
carlcs's user avatar
  • 36.3k
3 votes
Accepted

404s on custom sections and entries

You'll need to create a template, and add the path to that template to the Entry Template field in your "Services" section's settings. For instance, if you create a template called /craft/templates/...
Mats Mikkel Rummelhoff's user avatar
3 votes
Accepted

multi-domain setup: template entry.url includes index.php

OMG I'm so angry at myself! Not 'omitScriptNameInUrls' => 'true', but 'omitScriptNameInUrls' => true,
Amanda Lutz's user avatar
3 votes
Accepted

Problem with Site Running Both HTTP & HTTPs

What web server are you running? I ask because IIS will define the $_SERVER['https'] variable even if the site is being accessed via HTTP (it's value will be 'off') and Ben's answer is only checking ...
Tom's user avatar
  • 135
3 votes
Accepted

Can Craft convert requested url to lowercase?

Depending on how your server is configured, this may be a non-issue. I just checked several sites, and they all work fine with mixed-case URLs. If that's not the case with your site, you'll need to ...
Stephen Lewis's user avatar
3 votes

provide a 'back' or 'cancel' or 'close' button to return to whatever page that particular template was accessed from

If you need to set a correct link on the cancel buttons than using browser history is the easiest way. {% if entry is defined %} // Going to STEP2 <button onclick="window.history.go(-1); ...
Dominik Krulak's user avatar
3 votes
Accepted

Using pagination on a page with url with query string data

The huge advantage of craft over other CMS is the high flexibility and the ability to customize many things. Thus Craft won't provide non changeable <a> tags but links you can change like you ...
Robin Schambach's user avatar
3 votes

Equivalent of "EE Pages" module in Craft?

A common approach is to create a Structure for the pages, and use a Content Builder where you can use Matrix blocks of various types to allow the client to build out the pages as they see fit in the ...
andrew.welch's user avatar
  • 11.6k
3 votes
Accepted

Equivalent of "EE Pages" module in Craft?

There are a few different ways to do this but first I'd recommend stepping away from the idea of doing it like EE. Craft has a lot of flexibility in how the content model can be implemented. In Craft,...
Ben Parizek's user avatar
  • 13.5k
3 votes
Accepted

Get the section name based on a url segment

Do you mean {% set section = craft.sections.getSectionByHandle(craft.request.getSegment(1)) %} {{ section.name }}
Robin Schambach's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible