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
6
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
2k 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 ...
7
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
3k 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
273 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 ...
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
324 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
494 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
104 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&...
2
votes
1answer
261 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->...
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...';...
3
votes
2answers
4k 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
740 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
2answers
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
609 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
152 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 ...
6
votes
1answer
480 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/...
4
votes
1answer
492 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
169 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 ...
2
votes
2answers
545 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
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
466 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 ...
2
votes
1answer
36 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
1answer
695 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
1k 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/...
1
vote
1answer
327 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
70 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
1k 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 ...
3
votes
1answer
331 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
63 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 ...
2
votes
1answer
1k 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
213 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
248 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
176 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
2answers
248 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
1answer
112 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 ...
1
vote
1answer
217 views

Match Matrix Fields Before Looping Through Results

I hope someone has an example or something similar they have done in Craft before. Her is what I have. Structure: Section -> Flight Company Matrix Name -> Plane Details Matrix Block: Plane Model ...
1
vote
1answer
54 views

Sprout Forms Email

I have an entry where I select which form displays on the page. Is there a way for me on the entry using a text input for an email address to use that email address for the sending of emails via the ...
1
vote
1answer
84 views

Excluding Array of Entry Ids Not Busting Cache

-- UPDATED -- My understanding of how the cache busting works is to make sure the query is within the {% cache %} tag. When looking into how it works I may not really be understanding the ins and ...
1
vote
1answer
185 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
1answer
100 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
82 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
1answer
427 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
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". ...
1
vote
1answer
533 views

Craft CMS 3 admin panel returns 404 with SSL

I'm using MAMP Pro for local development and was gong to set up my site with SSL this time around. I got a self-signed cert for local dev and I can go to my development site over https:// without any ...
1
vote
2answers
569 views

yii\web\ServerErrorHttpException Craft 3 install

I'm new with Craft CMS and receive this error when I try to install it -------------------ERROR----------------------------- An Error occurred while handling another error: yii\web\...