Questions tagged [craft3]

For use with questions relating to the Craft 3 version of Craft CMS, including the Beta and RC releases.

Filter by
Sorted by
Tagged with
4
votes
2answers
1k views

Sendmail not working on Craft 3

I'm building my first Craft 3 site, and having problems getting email to send. I've set it to use Sendmail but when I click the Test button in the CP, I get "There was an error testing your email ...
4
votes
1answer
520 views

Caching in Craft 3 causes out of memory when including grouped for loop

I have a problem with using {% cache %}in Craft 3, although the code runs fine without caching, and it works in Craft 2. I have narrowed the problem down to the following code: {% cache %} {% set ...
4
votes
1answer
321 views

Update Asset Index in Migration

I'm trying to index some asset volumes that I'm creating in a migration. These are local volumes which may already contain files. I'm hoping to avoid the step where I have to manually update the ...
4
votes
1answer
35 views

Import Stripe subscriptions into Commerce 3

Is there a straight-forward way to import Stripe subscriptions into Commerce 3? I had hoped FeedMe or similar would do it, but it seems not: https://github.com/craftcms/feed-me/issues/472 Any help/...
4
votes
1answer
660 views

How do I prevent secrets beeing logged in the PHP error log?

Background: I'm running Craft Pro 3.1.19 on PHP 7.2.15 Craft CMS, by default, uses vlucas/phpdotenv to get the configuration (containing secrets / credentials and lots of other stuff) from .env ...
4
votes
1answer
397 views

Craft 3 Custom Plugin: model validation

Struggling a bit here - have created a custom plugin where I want to validate form submission against a predefined model before saving to the database. All pretty straightforward so far … However, if ...
4
votes
0answers
785 views

How to handle Craft 3 events in a plugin? Element API is returning null data

The below refers to Craft 3 and the Element API plugin for Craft 3. I would like to do something when the Element API plugin fires its onBeforeSendData event, I can see in the controller for element ...
3
votes
2answers
1k views

How do you set a flash message in the template in Craft 3?

How does one set a flash message in the templates? I can't find any documentation about this, only for plugins or getting the message. My use-case is, I am checking if a user is allowed to access a ...
3
votes
1answer
1k views

Craft 3 Redactor Link no longer has target option

The option for opening a link in the Redactor WYSIWYG no longer includes a field for opening it in a new tab? I haven't been able to find any docs that indicate any options for the Redactor config ...
3
votes
3answers
1k views

unserialize(): Error at offset 0 of 60695 bytes

Hey guys I am getting this error: unserialize(): Error at offset 0 of 60695 bytes when i push a backup of my local db to my staging environment. I am using craft 3. Any ideas? Clearing the /storage/...
3
votes
2answers
2k views

How to query an entry by a custom field in Craft 3

How do you query an Element by a custom field in Craft 3? My first try, according to craftcms/docs was: $country = Entry::find() ->section('countries') ->where(...
3
votes
2answers
393 views

EVENT_AFTER_SAVE_ELEMENT triggered twice after saving an entry

I had this weird issue, not sure if that happens to you guys or not. I'm trying to catch the 'after entry is saved' event, using the following code in my custom module's init() function (The module's ...
3
votes
2answers
4k views

Craft 3 image asset getUrl() not showing

I came across an interesting issue. I'm using Craft CMS 3.0.0-RC14 and non of my image paths are showing but the title and the file name does. {% set image = nav.navLogo.one() %} {{image.title}} // ...
3
votes
2answers
1k views

How to access HTML input values from Twig and vice versa

I am new to Craft and Twig in general. I have encountered the following problems and struggling to find a solution for hours. I want to access the value of "foo" input field inside the twig ...
3
votes
2answers
137 views

Overriding isSystemOn setting for a single page

I have a staging site that has the isSystemOn set to false since I don't want people to stumble upon the site and be able to view content. I would like to have 1 page still "visible" though. This URL ...
3
votes
1answer
2k views

Basic ajax - how to?

I am new to Craft. I have done some ajax in the distant past. I have searched this forum and see lots of issues with ajax but it seems that there are a lot of different approaches. Craft docs have ...
3
votes
1answer
447 views

Get related posts excluding current post in Craft 3

In Craft 3, I’m trying to get the five most recent other posts sharing a category with the current post. I got this far: {% for relatedPost in craft.entries.relatedTo(entry.newsCategory).limit(5) %} ...
3
votes
2answers
612 views

How can I import a large number of new entries into Craft 3

I need to create a few hundred entries at once. I used the Import plugin for Craft 2 to create these entries from a CSV file. How can I do the same for Craft 3? I do not see a plugin for this ...
3
votes
2answers
178 views

Craft 3 plugin backwards compatibility and maintenance for 2.x

I've been updating a number of my plugins for Craft 3 lately; part of that process has been to create entirely separate repositories/projects to accommodate the differences between Craft 2.x & 3. ...
3
votes
1answer
158 views

Setting Quantity Field on Subscriptions

How can I pass in a quantity value while creating a subscription? Plugin (version): Craft CMS (3.1.21) Craft Commerce (2.1.2) Stripe for Craft Commerce (1.2.0) Problem: My website allows users to ...
3
votes
1answer
251 views

How to rename filename of asset before (or after) upload in Craft 3

I want to change the filename before the file is stored, to prevent ugly, long and weird filenames uploaded by users. I've found an example for Craft 2, but because of the changes for events I can't ...
3
votes
3answers
697 views

Create new users with front end form and put them in a group, need help with start-elevated-session

This has been a long process that I set aside to resolve "later". Well, it's "later" and the clients wants to launch asap. Only registered users can use this site. There are 2 groups: Manager and ...
3
votes
1answer
1k views

Just how do Macros work in Craft 3?

Here is what I am doing, but it's not working: In a template: {% import 'macros/global' as macros %} {{ macros sizedImage(image, alt, 't600X450', 600, 450, link, 'someClass') }} The I have a macro ...
3
votes
3answers
1k views

Setting up Craft's registration e-mails to be sent through GMail

I have a question regarding how to set up Craft 3 RC8 to send e-mails through a corporate GMail account. My website's MX records are pointed at GMail through Cloudflare I tried setting this up when ...
3
votes
2answers
239 views

Trouble parsing JSON with getBodyParams()

I'm trying to use getBodyParams() to parse a JSON posted to a module controller action from an API. The incoming headers have content-type set as application/json; charset=utf-8, and I've tested to ...
3
votes
1answer
455 views

How to query/filter by the value of a lightswitch

In my news entries, I have a lightswitch field with the handle 'pinned'. I'm trying to query my news section for both pinned and unpinned news entries (true or false essentially), but I can't get ...
3
votes
2answers
438 views

How do you save a new Entry to be enabled on 2+ Sites?

I've made a plugin that let's you import Entries from a CSV file and I'm working through adding localization (Sites) support to it, but I can't figure out the right way to enable an Entry for a second ...
3
votes
1answer
128 views

How to query entries written in a specific locale? (Craft 3)

In Craft 2 you used to be able to do something like {% set entries = craft.entries.section('something').locale('de') %} but .locale() has been removed and there's nothing similar in the docs that I ...
3
votes
1answer
103 views

Error clearing a field via migration script

I'm using a migration script to clear out the values for a field on one of my entries. The field is an Entry Field and is not required. So I do this: $product->components = []; Craft::$app->...
3
votes
1answer
93 views

Dynamic Image Variant in Template

I'm keen to set my image variants dynamically from content editor and not quite sure how I do this in twig. I have three variants. They are named imageVariantsThumb, imageVariants16by9, and ...
3
votes
1answer
177 views

Craft 3 Custom Field Type with a File Uploader

I have a custom field type I am porting from Craft 2 to Craft 3. This field type used prepValueFromPost to grab a reference to a just uploaded file and then saves said file to an appropriate place ...
3
votes
2answers
404 views

commerce/cart/updateCart throws page not found

Adding products to the cart throws a page not found (404) error that has this header; Page not found. ↵ Caused by: Invalid Route – yii\base\InvalidRouteException Unable to resolve the request: ...
3
votes
1answer
567 views

help setting up web root to point to /web

I'm new to Craft 3 and I need help getting the web root to point to /web. I can't figure it out. If I use the url "mysite.com/web" everything works fine. Any help would be gratefully received.
3
votes
1answer
1k views

Craft CMS 3 - Entries field, getURL

Just migrating a site from 2 to 3 and stuck on this little call, cannot find anything in the docs at all. Matrix field, Entries. <a href="{{ entry.featuredProjectLink.getUrl() }}"> Cannot for ...
3
votes
1answer
405 views

Macro _self no longer possible in Craft 3

This used to work in Craft 2: {% macro richText(macroParam) %} {{ macroParam |striptags('<br><p><li><ul><a><strong><i>')|raw }} {% endmacro %} {# include ...
3
votes
2answers
727 views

Saving asset programatically, eg via API

I'm working on a plugin in Craft 3 that is fetching a file reference (URL) via an API. I want to fetch the file and save it locally as an Asset. I've tried to do this via Craft::$app->getElements()...
3
votes
1answer
196 views

Find entries from related section after certain date

Does anyone know how to achieve the following in Twig with Craft 3: My sections locations and trainings. I want to find all the entries from locations which has a relation to trainings and a ...
3
votes
2answers
3k views

Deployment of Craft 3 site to the production server

I am quite new in Craft CMS 3. I have developed a new site and now I want to move it to the production server. I have just moved all the files by FTP, moved the database, changed .env variables. ...
3
votes
1answer
601 views

Missing Position Field Type in Matrix (Craft 3)

Anyone know how to get the Position field type to show up in Craft 3 (RC)? I have a Matrix field, and an Asset/Image field within that, and I'm trying to add a Position field to it.
3
votes
1answer
266 views

Need .last() functionality for categories – .last() will be deprecated going forward

I have a matrix block that calls a category channel. The categories are nested three levels "deep" at times. I want to select first, second or third level links as needed. When I use .last(), I can ...
3
votes
1answer
929 views

Updates for v3 are paid only?

There was this "one time fee" mantra overall and now I read https://craftcms.com/news/dot-all-2017-announcements They will charge additionally on yearly base? Does this include any update and ...
3
votes
1answer
38 views

Custom CP Element Indexes

I'm working on a custom Craft 3 site, and I need to be able to configure the element indexes within the control panel for a few of my custom EntryTypes. There's two particular things I'd like to ...
3
votes
1answer
66 views

Entry element query missing user field data when user is suspended

I have a channel in which each channel entry has a "users" field type that is limited to one user. My code below works fine when the user is not suspended, however if I suspend the user, the then $...
3
votes
1answer
125 views

Craft 3 Image quality is terrible after asset upload from admin panel

After I upload an asset (png), the image loses quality. I changed the defaultImageQuality from its default value of 82 to 100 but didn't make a difference. I can't add these assets via FTP as I need ...
3
votes
1answer
222 views

Craft CMS V3 Create New User

Having difficulties creating a new user in a custom controller, here's my implementation: use craft\records\User; $user = new User; $user->firstName = $userData['firstName']; $user->lastName = ...
3
votes
1answer
239 views

Is it possible to create category for only one site in a multisite setup?

If not, how would you best approach this issue? For us, different sites have different categories, and also, not always the same number of categories. At the moment, when we create a category, it ...
3
votes
1answer
186 views

How to set view path for rendering email templates?

Trying to send an email Craft::$app->setViewPath('/Users/stian/dev/site.com/templates/'); Craft::$app->mailer->compose('confirmation.twig', ['orderId' => $orderId, 'customerId' => $...
3
votes
1answer
271 views

Can you override the default sendmail path in Sendmail transport config in Craft 3?

Many shared hosting accounts require custom flags that are passed to sendmail in order for them to work properly. Since Craft 3 uses Swiftmailer for its mailing library and Swiftmailer's default ...
3
votes
3answers
1k views

Tons of Deleting Stale Template caches

My task queue (is that what it's called?) is filled with literally hundreds of "Deleting Stale Template Caches" and every day there seem to be new ones. Along there are also resaving entries tasks and ...
3
votes
1answer
459 views

Getting full native language name in Craft3 language switcher

I'm porting across a multilingual project from Craft2 to Craft3 and have to rebuild the language switcher. I was previously using the .nativeName method but apparently this is deprecated. I've got a ...

1
2
3 4 5
31