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
2
votes
1answer
2k views

What is the best way to deploy a Craft CMS 3 site?

I'm unclear as to the best way to deploy a Craft CMS 3 site. I'm looking for some best practices and guidance. I'm currently using Rocketeer to deploy the code from my local environment to my staging ...
2
votes
2answers
260 views

504 error on home page of Craft 3 website

Recently, I developed a Craft 3 website. Its working perfectly on development server. But after deploying to another server, I am getting 504 error for home and all front end pages while Craft ...
2
votes
1answer
493 views

Craft 3 multi-lingual multi-sites setup with shared assets

I have 2 almost identical websites. Both have almost the same layout but different colors (so different CSS file). They share most of the same templates and assets (images, css, js, videos, etc.). ...
2
votes
1answer
1k views

Craft 3 : What are the advantages to use PostgreSQL and when should I use it instead of MySQL?

Craft 3 now supports PostgreSQL. I know this a very general question, but: I have absolutely no experience with PostgreSQL I don't know when should I use it instead of MySQL To quote Bob Olde ...
2
votes
2answers
477 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()...
2
votes
1answer
1k views

Security Key and Boilerplate

We have set up a Craft 3 installation with composer to serve as boilerplate for a number of upcoming projects. The installation sits in a private git repository and the plan is to clone it when we ...
2
votes
1answer
2k views

Craft 3 Template - Getting Image URLs

I am having a problem getting image urls from Craft 3. I understand that there is a new syntax but I cannot find the syntax to use. The craft 2 version of what I am trying to accomplish is {% set ...
2
votes
3answers
94 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 ...
2
votes
1answer
88 views

How to build contact form from scratch (no plugin)

I want to build a simple contact form without plugin, i am new to craft cms coming from wordpress, how can i build a simple form that will be save on entries and will send an email.
2
votes
2answers
144 views

Entry Query relatedTo Two Categories

This has to be something that is easy, but I've been beating my head on my desk for a a few hours with this. Most solutions I have come across are way to complex - when all I need to do is query a ...
2
votes
1answer
65 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 ...
2
votes
1answer
61 views

How can I return only 1 random block in a Matrix in Craft using Twig?

I have a matrix with a couple of text fields for a caption, location and URL and an image Every time this page loads I want a random slide to show - so the background image is random, as well as the ...
2
votes
1answer
51 views

Any reason why {% requirePermission 'editEntries:1' %} would stop working within the past week or so?

This worked fine last week when the site was in development: {% requirePermission 'editEntries:1' %} We made the site live a few days ago. I dont know if its related, but when I now go to pages with ...
2
votes
1answer
1k views

“Craft isn't installed yet” error after updating to Craft 3.1

I just updated to Craft 3.1 and logged into the admin to make the required updates to the database and this all worked fine. However, when I use the new ./craft update CLI feature, it responds with "...
2
votes
1answer
190 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
105 views

Empty matrix object after checking for a block type

Not sure if this is a bug or my logic is off. I'm trying to add caching logic to templates to not cache certain pages if they have a block type form present because of the dynamic CSRF tokens. The ...
2
votes
1answer
107 views

Method for creating Category Group landing pages

I have a selection of category groups as follows: Suitability Colour Finish etc They all have many categories within them. I have set up some routes for /suitability etc to show the user a /shop/...
2
votes
2answers
206 views

How to store custom data into a user

I need some direction in how to store (complex) data into users (best practice) I'm working on a project for a fitness app. I created a structure with 2 levels for workouts where level 1 entries are ...
2
votes
2answers
264 views

How to include asset fields in query in php?

I am trying to figure out how to return asset field(s) in a PHP entry query. Also if I could learn how to return "custom fields" when returning an Object that would be great too! Right now I am having ...
2
votes
1answer
160 views

How can I pass a variable defined in a Controller to my variables?

In my Craft 3 plugin I would like to pass a variable defined in my Controller to my PluginVariable.php file. Is this possible?
2
votes
2answers
399 views

Redactor formattingAdd not working

I've used redactor's custom formatting option before, but now I can't get anything to work. Here's what my file currently looks like: { "buttons": [ "formatting", "bold", "...
2
votes
1answer
226 views

Eager loading on entry not reducing queries

Using this snippet returns me 38 queries on my homepage without the Eager Beaver plugin. {% do craft.app.elements.eagerLoadElements( className(entry), [entry], ['headerImage', 'image1', '...
2
votes
1answer
1k views

Clear template cache from the CLI?

I was looking for a way to clear the “template caches” and “compiled templates” from the CLI, as I want to automatically do this after every auto-deploy of the site I've created. For this I was ...
2
votes
2answers
287 views

Getting products with Craft 3 and Craft Commerce 2

I've never had success using Craft 3 with Commerce 2 beta. I always get an error that ".find()" is not recognized, and ".all()" doesn't work either. My latest attempt has given me this error: Twig ...
2
votes
1answer
98 views

Install instructions

I'm having difficulties following the install instructions found at https://docs.craftcms.com/v3/installation.html. I've ssh'd into my server, and I'm running composer to install Craft, as directed in ...
2
votes
1answer
579 views

From a Twig template, how to retrieve the content of a HTTP header in the current request?

I would like to detect if a header in the current request is present and obtain its value, directly within a Twig template. I know that craft.app.request gives access to a few variables like isAjax ...
2
votes
1answer
181 views

How to get an entry url from EVENT_AFTER_SAVE_ELEMENT callback?

In my plugin I am registering a callback for Elements::EVENT_AFTER_SAVE_ELEMENT event. Previously, in Craft2, I could access the URL of the saved entry from the $event parameter passed into the ...
2
votes
1answer
260 views

Make segment in the middle of a route optional

In the following route configuration i want to make the height segment optional. So that /images/400/200/placeholder.png /images/400/placeholder.png are both possible with one route. $event->...
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
632 views

Craft 3 and Macros

re: macros I'm trying to use one for an SVG sprite. But I'm not sure what I'm doing wrong. macros template: {% macro icon(iconId) %} <svg class="icon icon-{{ iconId }}" role="img" title="{{ ...
2
votes
1answer
31 views

Is there a way to retrieve the type of an entry?

To be more specific, I would like to know if an entry is a Single or part of a Structure or Channel. entry.type seems to return the name of the single or section. Is there a way to retrieve this ...
2
votes
1answer
230 views

How to make PNGs crisp using Imager + Optipng and Craft 3?

I've installed Imager in a Craft 3 site and everything looks fine except my PNGs are fuzzy. I've set 'pngCompressionLevel' => 0, because I'm using Optipng and the docs say to do this. The PNGs have ...
2
votes
1answer
806 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 ...
2
votes
1answer
145 views

What is the proper way to set `currentSite` in a CP template when managing multi-site stuff in Craft 3?

In some of our plugins, we have added multi-site support. For the most part, things are working fine but I'm feeling a bit confused about the correct way to set the currentSite in the Control Panel. ...
2
votes
2answers
607 views

Add custom attribute to standard element from plugin

Developing plugin for Craft 3, I want to add extra property to Assets (data being pulled from other table) I am able to pull in the data by extending element query: Event::on( ...
2
votes
1answer
52 views

Plugin init function executed more than once

To test a service method, I'm executing it in my init function. The method adds a row to the database table with a mail address and variant id: $this->waitingListService->add(7, 'email@...
2
votes
1answer
497 views

How to add a button or format style in Craft 3 CKEditor (rich text field)

I'm looking to customize the CKEditor (rich text field) to restrict my client to only these buttons: h2, p, bold, italic, underline, link & unordered list.
2
votes
2answers
440 views

Craft 3 upload path on webserver

My hoster has i public html folder where all websites are lying. Different Websites are separeted by subfolders. Should i upload all Craft3 installation files to this public html folder and point the ...
2
votes
1answer
343 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 ...
2
votes
1answer
789 views

Craft CMS 3 - Redis Sessions cause error

I've configured Redis to handle cache and sessions for Craft 3, and while cache configuration is working as expected, I had to disable session configuration due to the below error. It fails on the ...
2
votes
1answer
243 views

Craft or Twig converting html tags to alt characters

Just starting with plugin development. I modified the code from pluginfactory.io for a custom tag: public function navHTML() { $result = '<h2>Hello again</h2>'; return $result; } ...
2
votes
1answer
220 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
115 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
1answer
393 views

How to get user's photo url without transform?

Craft 3: I'm trying to get User Photo URL WITHOUT any transforms, but none of those options seems to work: (some of it prints the url with some transform) user.photo user.getPhoto() user.getPhoto('...
2
votes
1answer
214 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 ...
2
votes
1answer
717 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
2k views

Setting absolute path to asset files for Craft 3 multisite

Currently, I have 3 sites set up in Craft 3 beta. I'm trying to get all my sites to share one asset folder by using absolute path. However, I can't seem to set it up. The siteUrl is not parsing as I ...
2
votes
1answer
462 views

Craft 3: How to get Volume by handle?

How can I get the details of an asset volume in Craft 3, if I only know the handle? I found the Volumes and the Assets service, but I believe none of them provides a method for that purpose. The only ...
2
votes
1answer
402 views

Craft 3: query matrixBlocks and eager load its owner?

Does anybody know if it's possible to load matrixBlock and eager load the entries (=owner) the matrixBlocks belong to in Craft 3? I tried: {% set blocks = craft.matrixBlocks.type('eventDate')....
2
votes
1answer
22 views

Invalid KML file using SmartMap Plugin

I'm using SmartMap for Craft3 to develop this filterable map for Columbia, Missouri. Here's the staging site: http://visionzerodev.org/map-alpha/ This works brilliantly. Huzzah. Now, I also need to ...