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
8
votes
2answers
2k views

How to save Matrix data programmatically in Craft 3

How can you programmatically save an entry that has a Matrix field in Craft 3? (Something like this gist for Craft 2)
8
votes
5answers
2k views

How do you set a user's group on a registration form?

In a registration form with public signup possible, how do you set the user group for a particular form? As a stop-gap I am attempting to use the following code: function init() { craft()->on(...
4
votes
5answers
4k views

Craft 3 language switcher

Does anybody successfully implemented a language switch run Craft 3? Trying the Craft 2 variant slightly adjusted but still running into issues: Invalid site handle: nl <ul> {% set otherLocales ...
8
votes
1answer
3k views

{parent.uri}/{slug}

In Craft 2.x you have the option of setting the top-level entries URL format for a structure section separately from nested entries i.e. top-level/{slug} and {parent.uri}/{slug} But in Craft 3 the ...
8
votes
2answers
2k views

Craft CLI RC1 Connectivity Issues with MAMP Pro

I've been trying to run the new Craft CLI for the last couple of versions without any success. I figured maybe since we weren't at RC1 yet that it wasn't fully working. After seeing Ryan's video about ...
7
votes
3answers
4k views

Multi-site setup in Craft3

Hi guys are the any more detailed tutorials on how to setup a multi site on Craft3 BETA? I created two sites now, a Danish and English through the admin (Settings → Sites). The domain is the same but ...
2
votes
1answer
401 views

How to get the previous or next two entries

I have an entry which needs to display the previous two entries, and the next two. I see in the docs there's a nextSiblingOf method. That does nothing in a channel, and in a structure it will only ...
6
votes
2answers
651 views

How to setup assets in multi site where each site should have its own assets?

I have a setup with multi sites that are separate domains. site-a.com site-b.com I would also like to have assets separate for each site, like so: site-a.com/images/picture1.jpg site-b.com/...
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 ...
2
votes
0answers
405 views

Searching for Multiple Categories and Tags

I've been pulling my head for the past day on how to filter products with multiple categories. After a long search, I found and implemented on my project, Advanced Search with tags and categories It ...
3
votes
1answer
511 views

500 Error with no details on site migration

I'm trying to migrate my site from a PHP5.6 host to a PHP 7 host in preparation for Craft 3. I've copied everything across and am trying to load an exact copy of the production site on a different ...
2
votes
1answer
368 views

How can I set new user accounts to pending status in a Craft 3 module?

I have the following code in my site module: Event::on( User::class, User::EVENT_BEFORE_SAVE, function (ModelEvent $event) { /** @var User $user */ $user = $event->...
2
votes
1answer
135 views

Missing Matrix row types on output after upgrade to Craft 3 (subsetting and cloning ElementQueries)

Update: Now I know the cause of my problem, I have appended to the original question title to try and help other people stumbling across the same issue. I have a pending support ticket open with P&...
1
vote
1answer
2k views

How to save a new entry with custom fields - Craft 3

I'm trying to create a new Entry via PHP, with custom fields (Craft 3). I can save it, however my custom fields don't appear. I've tried using setFieldValue, as well as $entry->excerpt = 'Lorem...';...
4
votes
2answers
5k views

Craft 3: how can I set dynamic Base URL in sites setting?

Sites localized versions are setup using Base URL like this: — http://{baseUrl}/en/ — http://{baseUrl}/fr/ But {baseUrl} variables are not transformed using craft.app.sites.getAllSites(). {% set ...
7
votes
3answers
3k views

Plugin logging in Craft 3

How is logging handled in Craft 3? There's nothing mentioned in the docs at all. None of the below exist. Craft::log() MyPlugin::log() MyPlugin::$plugin->log() I'm not seeing any logging in any of ...
4
votes
1answer
851 views

Craft 3 Multi-site with no “default” site

I have setup a Craft 3 multi-site with the following configuration: But what I really want is: Additionally, I want to have a 'default' http://localhost:8888 so I can always redirect to /en or /es ...
7
votes
3answers
1k views

Craft 3 plugins - Logging in a separate *.log file

In Craft 2, it was possible to have your plugin log to a separate file. For example, it would record items to a myplugin.log file. You would simply be able to do it like this... MyPlugin::log('Lorem ...
4
votes
1answer
818 views

Craft 3 Multi Category and Field Search

Looking for the solution to searching entries in one section that are related to multiple categories and match number field criteria. This is for a used auto website. Categories: Make/Model/Trim: ...
4
votes
1answer
2k views

Set up Craft 3 when the craft folder is above public_html on shared hosting

I'm trying to setup Craft 3 on a shared host. It succeeds when I place all files in the public directory and then go to /web. But if I move the craft files to the folder /private_html/craft and the ...
3
votes
1answer
193 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 ...
2
votes
3answers
404 views

Including the category group in nested category URIs?

I've asked already about nested categories here, but I've just upgraded to Craft 3 and things seem to have changed a little. I have three top-level category groups: - Home - About - Funding Each of ...
5
votes
1answer
648 views

How can I install modules with Composer?

Installing a Craft 3 plugin via Composer is pretty simple. You require the package, update Composer, and install it via the CMS. My circumstances require that our company use a private Module on all ...
3
votes
1answer
227 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
797 views

How to get section content from another site with multisite setting

I have a multisite on Craft 3 and I was wondering how to get section content from another site? Let's say I'm on a default site and I want to get contact content from site with handle siteA? Can this ...
2
votes
2answers
660 views

Nested Entries in Craft 3

In Craft 2 there used to be a Nested Entries field, but this is not available in Craft 3. I know I can do {parent.uri}/{slug} in the Entry URI Format field, but if I want it to be appended by ...
2
votes
1answer
55 views

How to return a hierarchical list of a site's page structure using the ElementAPI

I'm experimenting with using Craft in a headless way and am successfully using the Element API to return all the data required to show individual pages. However, to be able to show sub navigation and ...
2
votes
2answers
2k views

Error on Craft 3 install

When attempting to install Craft 3 in OSX El Cap, I'm getting the following errors: Script @php craft setup/welcome handling the post-create-project-cmd event returned with error code 255 /Craft3/...
2
votes
1answer
2k views

How to saveElement in EVENT_AFTER_SAVE_ELEMENT without infinite loop

I am trying to update an entry's title in a Craft 3 module after an entry is saved. I cannot use EVENT_BEFORE_SAVE_ELEMENT because the title gets updated after this. If I use EVENT_AFTER_SAVE_ELEMENT ...
2
votes
1answer
536 views

What is the difference between the Translation Methods when creating a new site

I am creating a new multi-lingual site and the documentation does not explain the difference between the options in the translation method dropdown. What is different for each of these and when is it ...
1
vote
1answer
417 views

query on Super Table field's date field

I have a section (events) with a Super Table field that has a date field. I am looking for a way to make a request to have the events superior to now. I cannot find how to do it. The event have ...
1
vote
0answers
83 views

Element type vs. Field type - or: Element type without database storage?

I have already searched for information on this topic but I did not find much. I hope I did not overlook something. My problem is the following: I want to try to write a plugin that lists entries ...
5
votes
2answers
2k views

Craft 3 404 and 503 pages in devMode

Is there any way to get Craft 3 to display 404.html and 503.html for the 404 and 503 pages while in devMode, as it did in Craft 2, rather than returning the entire Yii 2 error stack? Sometimes, we ...
4
votes
1answer
472 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 ...
3
votes
2answers
72 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
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(...
2
votes
1answer
282 views

Craft 3: how can I auto-redirect to a site version using the user IP?

I have set up multi-sites using several locales: — International Website — English — Local Website — French — Dutch — etc. If the user has a French or Dutch IP, it should be auto-...
2
votes
1answer
217 views

Missing “Plugin Store” navigation on Craft 3 admin section

I am a newbie to CraftCMS and just installed my very first Craft Project on local Xampp. Everything looks good except the "Plugin Store" navigation menu is not showing up. Is there any trick or tweak ...
2
votes
1answer
251 views

EVENT_REGISTER_TABLE_ATTRIBUTES not working in Craft 3

I am developing a plugin to add custom column to entries table for which I am using EVENT_REGISTER_TABLE_ATTRIBUTES and EVENT_SET_TABLE_ATTRIBUTE_HTML and code example is: Event::on( Element::...
2
votes
1answer
143 views

Getting unique values from SmartMap addresses

Using the following filter will return all the entries for 'CA'. {% set params = { filter: { state: 'CA' } } %} {% set meetings = craft.entries.address(params) %} Let's say that I ...
2
votes
2answers
295 views

Still not able to manage tags in Craft 3?

I have page where I display some items and there are filters by tag. So I make a list of all tags that are created. Then when the user click on some of the tag, he see only the product with that tag. ...
2
votes
3answers
134 views

Craft CMS/Feed Me slow performance

I am wondering if I have structured my data badly and was hoping someone could advise on an alternative. Essentially I have a structure with two types, a catalogue and the catalogues children. Some ...
1
vote
1answer
196 views

How to grab all images from and section

I am sure this must be answered somewhere and I cannot find it. I need to grab all images from a section (channel) and display them in a slide show on the index page (index page is a single,so index ...
1
vote
2answers
354 views

How do I access current site handle in Craft 3 controllers

When my multisite is set up as @web/site, I cannot access the current site handle from my controllers. Craft::$app->getSites()->currentSite->handle I think this is because my form action ...
1
vote
1answer
163 views

Headless Live Preview with Gatsby

I am following Andrew Welch's post here - https://twitter.com/nystudio107/status/1168220713158942720?lang=en I used the gatsby-config.js file he shared here - https://gist.github.com/monachilada/...
1
vote
1answer
41 views

Additional criteria to filter status of field passed into RelatedTo

I'm trying to save all the images related to an entry in a variable. I need the images that are added through a matrix field in the entry. I'm using the following code, but am then also getting images ...
1
vote
1answer
573 views

Craft query Matrix blocks in twig

Is it possible to query elements of type MatrixBlock in Twig like other elements? You can get entries with {% set entries = craft.entries.all() %} Is there something similar available for Matrix ...
1
vote
1answer
113 views

Plugin settings per site/locale

I'm trying to make a plugin in Craft 3 but want it to be possible to set different settings for each separate site or locale. How would I go about doing this?
1
vote
0answers
103 views

Querying a supertable field

I have an entry type called people which has a superTable field called programmeAffiliations, with three fields, jobTitle, researchProgramme, primary where: researchProgramme is a category field (...
1
vote
3answers
2k views

Installing Craft 3 - Internal server error

Using Ampps on Windows, I'm trying to install a fresh Craft 3.0 and I've followed the steps and everything seems to be working. Until the very last step, where Craft says "Oops something went wrong". ...