Oli
  • Member for 6 years, 9 months
  • Last seen this week
How do you set a flash message in the template in Craft 3?
7 votes

Edit: Brandon replied as I was writing this. Feel free to remove :) You can do that using this in your conditional, just above your redirect tag {% do craft.app.session.setFlash('error', 'no no no') ...

View answer
Why is the summary and body returning an empty object using the Element API?
Accepted answer
6 votes

Try this: ... 'transformer' => function (EntryModel $entry) { return [ 'title' => $entry->title, 'url' => $entry->url, 'summary' => (string) $entry->...

View answer
Undefined index: siteSettings when updating entry types
Accepted answer
5 votes

Even with 'useProjectConfigFile' => false, it is still active under the hood. Could you run ./craft project-config/rebuild and see if that fixes the issue?

View answer
Asset Volume using Environment Variable on File System Path as literal string on upload
Accepted answer
5 votes

If you use environment variables, you have to be aware that you can't add anything to it in your fields. What this means is that $ASSET_ADHOC_PATH/website in your CP will not be parsed. If you use ...

View answer
No plugin exists with the handle "contact-form-extensions"
Accepted answer
5 votes

Try running ./craft project-config/rebuild from your terminal.

View answer
Math with numeric values derived from a dropdown field
5 votes

Have you tried subhead.hLevel.value?

View answer
How to modify the login panel
4 votes

You can add a logo to the login page by uploading one to Settings → General Login Page Logo. If you need further tweaking, you could use the Control Panel CSS plugin. I wouldn't recommend modifying ...

View answer
Folder Permissions denied with Nitro
Accepted answer
4 votes

This could be because you are setting your Settings → Assets → your volume File System Path to an absolute location outside the VM. Create an alias (or hard-set webroot) using: 'aliases' => [ '...

View answer
How to use Sprig's "Load More" Recipe After Update
Accepted answer
4 votes

The problem is that you are doing .relatedTo(category) but the variable you are passing is called relatedTo, not category. Just like with limit, based on your code, it should be .relatedTo(relatedTo). ...

View answer
How to reprocess image transforms that already exist in the database
Accepted answer
4 votes

You can run ./craft clear-caches/transform-indexes to clear your transform indexes.

View answer
How to duplicate entries and loop them without getting a Twig or deprecation error?
Accepted answer
4 votes

Instead of duplicating the entries, you could run your entries loop twice (or as many times as you want) maybe? {% for i in 0..1 %} {% for entry in entries %} {{ entry.title }} <br&...

View answer
Programmatically add entries to an Entry field (craft\fields\Entries)
Accepted answer
4 votes

If you use Craft::$app->getGlobals()->saveSet($reglages); you are saving the Global's itself (its settings), not its content. Here, you should use Craft::$app->elements->saveElement($...

View answer
Error while trying to upgrade to Craft 3
4 votes

You can add: 'aliases' => [ 'siteUrl' => 'http://yoursiteurl.com', ], To your config/general.php or use: 'aliases' => [ 'siteUrl' => getenv('DEFAULT_SITE_URL'), ], And define ...

View answer
How to order Sites
Accepted answer
4 votes

I've seen that before, if you look at the sites table in your DB, you'll see that a few sites might have their sortOrder set to 1. If you go to Settings → Sites → [the offending group] in your ...

View answer
Tabs in a Matrix Field
Accepted answer
4 votes

This is a plugin, yes. It's Spoon by Angell & Co.

View answer
Event triggered when Craft sends email
Accepted answer
3 votes

There is craft\mail\Mailer::EVENT_BEFORE_SEND. You can use the Event Code Generator to find out more

View answer
Output post category
Accepted answer
3 votes

At the moment, you are loading all categories in the line {% set categories = categoryEntry.all() %} and that's why you are getting them all for each entries. What you need to do is to fetch your ...

View answer
Improve performance and element queries when used multiple times
Accepted answer
3 votes

Since you have two sections, you will need your two initial queries, however, in your example, although you are eager loading the children (with(children)), you are querying them a second time when ...

View answer
GraphQL: get prev / next entry from current entry (channel)
Accepted answer
3 votes

You should be able to use next and prev (see documentation and this issue). query getEntryData($id: [QueryArgument]) { entry(id: $id) { id, slug, title, uri, prev(section: "...

View answer
Invalid Configuration Error in Craft CMS 3 using Nitro 2
Accepted answer
3 votes

This path is on your host machine but this isn't how docker sees things. To Nitro, the location of the folder is /app/web/cpresources. Without going into too much details, I'd recommend going with an ...

View answer
Autogenerate complex Date / Count based Title
Accepted answer
3 votes

Unless I'm missing something, you should be able to use the seq Twig function (docs) and use something like: {{ 'now'|date('Ymd') ~ '-' ~ seq('now'|date('Ymd'), 3) }} This would generate the format ...

View answer
Display message on logout (flash?)
Accepted answer
3 votes

You can set postLogoutRedirect in your config/general.php (docs) to redirect your users to a specific page, something like 'postLogoutRedirect' => 'your-page' If you want to use an existing page, ...

View answer
Order by reverse relationship count
Accepted answer
3 votes

If you don't have tons and tons of creators, you could do that by querying creators and re-arranging the results: {# Get all creators and eager-load the products #} {% set creators = craft.entries() ...

View answer
Fetching Unique Categories related to Entries via GraphQL
3 votes

You can run a categories query and pass it your product id(s) as well as the category group id (though that's not necessary) to fetch all categories related to your products. The query: query ...

View answer
Simple Product Listing Pages by Category Slug
Accepted answer
3 votes

You're nearly there! You are missing the part that fetches the entries related to your category. With your current set up, you would need to do: {# Get the requested category slug from the URL #} {% ...

View answer
How can I programmatically change the system's status?
Accepted answer
3 votes

There are two existing console commands you can use, ./craft on and ./craft off (on and off). If you want/need to implement your own, take a look at the commit.

View answer
Create folder in asset volume via GraphQL
Accepted answer
3 votes

Currently, there’s no direct way of doing this. You can pass an existing folder ID but you can’t create folders on the fly. However, you can create folders via an asset field (with dynamic path) ...

View answer
Updating Entry field with GraphQL mutation
Accepted answer
3 votes

To edit an entry via a GraphQL mutation you will need to pass the id of the entry you want to edit (similar to front end entry form). This example assumes a news Section, an article Entry Type and ...

View answer
Filter Entries by Custom date
3 votes

You need to query using strings and your condition should be written as follow: {% set catYear = craft.app.request.segment(-1) %} {% set firstDayOfYear = catYear ~ "-01-01" %} {% set ...

View answer
Site url is not generated correctly when using environment variables
Accepted answer
3 votes

Cache poisoning would only happen if you don't hard-set your @web alias manually and it is auto-determined. Set it in your config/general.php with: 'aliases' => [ 'web' => getenv('...

View answer
1
2 3 4 5
8