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
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
3k 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
532 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
98 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
3answers
3k views

Setting the Homepage URL in Craft 3

This seems like an odd question, but I've looked through the documentation, Slack, and the StackExchange and it's weird that I'm not seeing anything... so I feel like I'm overcomplicating it. How do ...
3
votes
1answer
351 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
559 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
164 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
114 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
3answers
561 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
822 views

How to fetch entries in custom plugin Craft 3?

I am creating custom search based on entries. I need to fetch entries in custom plugin.
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
1answer
252 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
224 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
89 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
77 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
179 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
1answer
125 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
1answer
662 views

Running module migrations

I must be missing something or not understanding something. I'm trying to build a module for an install, and I'd like to run the initial migration. So the module initial install migration for the DB ...
3
votes
2answers
351 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
463 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
162 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
564 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
913 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
42 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
80 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
253 views

Can't get setFieldValue to work

I've got this // Creating users through frontend Event::on(Users::class, Users::EVENT_BEFORE_ACTIVATE_USER, function(UserEvent $event) { $userId = $event->user->id; // ...
3
votes
1answer
210 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
844 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
364 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 ...
3
votes
2answers
64 views

Entry Tracker to see who has completed the course

I'm working on a project using Craft CMS for the first time, so far so good, however i'm stumped on how to do the following: Create a button on each entry in a structure that states you have read the ...
3
votes
2answers
80 views

Switching plugin license from Craft 2 to Craft 3

Dumb question, but... I purchased a plugin when using Craft 2 and now I'm trying to input the license for it in Craft 3. There's an input for the license key when I go to settings -> plugins, but the ...
3
votes
1answer
406 views

Craft 3 Element API: Query the “parent” entry of a “child” entry with Matrix blocks connected by an 'Entries' field

In a Matrix block field of a "page" entry, I'm using an Entries field to manually select a list of "article" entries to the "page" entry. When I query an "article" entry, is it possible to query its "...
3
votes
1answer
165 views

Check if a field a included in a Matrix block

Situation: I have a matrix with about 10 block types, 3 of which have a certain field. I want to check if the current block has that field. The field in question is a dropdown with values in all 3 ...
3
votes
1answer
77 views

Preserve formatting when exporting from Wordpress

I'm using the WP All Export plugin to get posts out of Wordpress, and Feed Me to import to Craft 3. Problem I'm having is I can get a great XML feed out of the WP All Export plugin, but post "Content" ...
3
votes
1answer
864 views

Example of Craft 3.0 plugin - querying an existing table

Learning how to create plugins. I want to do a select query in an existing table in the Craft database, build navigation HTML and then return that HTML using a variable. I can see how to set up my own ...
3
votes
1answer
869 views

Auto enable/install plugin through config

Is it possible to auto enable/install a plugin through config (or another way) rather than having to do this through the database?
3
votes
1answer
2k views

How to route to a controller action in Craft3?

Before I get tagged as a duplicate I have already tried everything in the 'duplicate' issues on here to no avail so I'm posting my exact config to see what I'm doing wrong. Here is my plugin code and ...
3
votes
1answer
105 views

How to limit Expanded Search (plugin) query results for pagination?

I'm using the Expanded Search plugin to display results of the search query with an excerpt of the text matching the query for each result. I want to limit the results to 10 per page, using pagination....
3
votes
1answer
144 views

Selling tickets to repeating events with Commerce (and Solspace Calendar?)

We need to build a ticketing system for venue tours, that happen every week within certain date ranges, and with an option to exclude specific dates from the availability list. Looking at Solspace ...
3
votes
1answer
125 views

Why is Sprout Forms returning 302 for ajax requests?

I am using Sprout Forms on a Craft 3 site and trying to submit my form via ajax. I've been able to do this many times in Craft 2, but not having much luck with 3 (yet). The docs look mainly for Craft ...
3
votes
2answers
344 views

Craft 3 User Registration form errors not showing for custom fields

I've built a front end user registration form and everything is working well with it except that it's not showing errors for my custom fields. They're set as required in the CP, but the form submits ...
3
votes
2answers
732 views

Craft 3.0 - Recommended development environment for Windows?

I was wondering what people who are developing on Windows 10 are using as webserver environment in 2018? I have had ok results previously using ampps, but I'm having a lot of problems with Craft 3.0 ...
3
votes
1answer
1k views

Element API display entries by category

With v2 of the Element API plugin, I'm having issues with working out how to return entries that are in a particular category. I've got the slug in the API route but can't work out what the query ...
3
votes
2answers
927 views

Craft 3: multisite and assets

I am a little bit confused by the documentation about assets. It says that paths are relatives from the directory that holds the index.php file. Now, I am working on multisite, with the following ...
3
votes
2answers
2k views

Craft 3 Plugin Routing Problems

So I am working on converting a previously-standalone Yii 2 app into a Craft module and am having some issues with routing. I wish to keep my old URL structure as much as possible. As such, I ...
3
votes
1answer
53 views

Can someone explain to me the difference between 'not' and without?

Here is an example of code I'm trying to use to eliminating have to iterate comparing the current entry.title to the related to entry.title then omitting it. {% set entries = craft.entries.relatedTo(...
3
votes
1answer
60 views

Obtain suspended users in Craft3 Dev Preview

So I'm running into an issue where I'm given the users email. From there, I use the following code: Craft::$app->getUsers()->getUserByEmail($email);. This returns a null value, not because the ...