Hot answers tagged

4

You can define whatever aliases/environment variables you like. In this case, I'd probably define an environment variable in my .env file like this: BASE_WEB=http://example.com And then in config/general.php I'd add an alias: <?php /** * General Configuration * * All of your system's general configuration settings go in here. You can see a * list ...


2

they updated the sourceNodes cycle since this config, you will need to update the schema first doing something like this: An example using the body hook if you need it: createSchemaCustomization({ refresh: true }).then(() => { sourceNodes({ webhookBody }); });


2

I faced the same problem in Craft v3.4.10 and have been informed that this is a bug, which has now been fixed and will be shipped in v3.4.12.


2

"Not yet" is the short answer. https://github.com/craftcms/commerce/issues/295


2

It’s possible to do this by making the entire CSS file a Twig template. Create a new file in your templates folder, such as templates/css/styles.css, with all the dynamic styles you want. To prevent the browser from reloading the file on each request, make sure you set cache headers in the template. {# Tell the browser to cache this page for 30 days #} {% ...


2

You could run a query to fetch the folderId you need based on the name: {# Change this to your volumeId #} {% set volumeId = yourVolumeId %} {# Change this to your folderName #} {% set folderName = yourFolderName %} {# Returns an ID if there is a match, otherwise false #} {% set folderId = craft .query() .select(['id']) .from('{{%volumefolders}...


2

You can use a Twig replace filter in the email template to replace the URL with whatever you like. (I'm using this method myself because we have a similar problem on multi-site installs). To do this you'll need to be using custom templates for all system emails: Settings > Email > HTML Email Template I'd set that to something like emails/index, which ...


2

It is to generate an HTML input tag with type of hidden. This will not appear on the screen like a normal input does. For more information related to input type hidden, you can refer to this. enabled means that the entry will be saved with its status toggle set to the “enabled” (green) position.


1

So, you have to "switch" template modes from the look of it! (who knew?!) This is the code you need to use templates within your module directory, assuming you have your modules template root defined as Oli referenced. $first = "john"; $last = "doe"; $params = ['first' => $first, 'last' => $last]; $mailTo = "john@example.co.uk"; // Switch the ...


1

You can define your module's template root with the following: Event::on(View::class, View::EVENT_REGISTER_CP_TEMPLATE_ROOTS, function (craft\events\RegisterTemplateRootsEvent $e) { if (is_dir($baseDir = $this->getBasePath() . DIRECTORY_SEPARATOR . 'templates')) { $e->roots[$this->id] = $baseDir; } }); You then compose emails like ...


1

Define "best". It's one way of doing it but has a couple of issues. They need to log in to see this (I presume, otherwise one issue is that there are public facing things on the website no actual visitor cares about) but it's not in the dashboard. So there's a log in then navigate to the front end and get the page workflow which is less than ideal) Why not ...


1

This turned out to be a Craft bug. I’ve posted an issue for it at https://github.com/craftcms/cms/issues/5849, and fixed it for the next release (3.4.12).


1

Author of the ImageOptimize plugin... when you say no luck with that either, what is going wrong? Once you install ImageOptimize, and add an Optimized Images field type to your asset volumes, it will create all of those responsive image transform for you. Check out the Using the Optimized Images Field section of the documentation. It can't just create all ...


1

I do not believe there is an easy way to do this with Craft out of the box. Uploading 2k images to an entry is a bit of an edge case. I would recommend uploading all of those images directly to the asset volume. That being said, you might want to search the plugin store to see if anyone has created a plugin like this. You could also create your own plugin, ...


1

If I change the mode to "production" from "dev," the errors go away, and as far as I can see no new error is created in the server or Craft log. So I can develop in production mode but I do find the dev mode useful. It sounds like you're changing the environment variable ENVIRONMENT, e.g.: ENVIRONMENT="dev" This actually doesn't do much, it's just ...


1

Even if useProjectConfig was set to false, it's not a good idea to update Craft on a live site because, as you've discovered, errors sometimes happen. There's even an allowUpdates config setting that we recommend people setting to false on the live site just so someone doesn't accidentally update Craft from the control panel. The safer workflow is to have ...


1

Found the solution. It's also necessary to create a row in the content table. Here's the query in case anyone would find it useful. Bear in mind I've hard coded the voucher type id as 7461 and the field layout ID for the gift voucher 34. # Query 1 Get all giftcards created from 1st Dec 2018 # Remove stored function DROP FUNCTION IF EXISTS ...


1

I think you'd be better off creating a quick module with a controller method to import your voucher codes, to make sure Craft (and Verbb Gift) create all the necessary table rows for the vouchers to work (code is untested, but just to get an idea): use verbb\giftvoucher\elements\Voucher; public function actionCopyVouchers() { $esVouchers = Craft::$app-&...


1

DB and eventually others files are updated in the first request after the Update.


1

Currently not possible without forking the Contact Form plugin and changing the logic to do what you're looking for. There are other form builder/contact form plugins that might have more options when dealing with SPAM you might want to look at as well: https://plugins.craftcms.com/search?q=contact%20form


1

You can get this error message even if Craft installation is OK. If you work in MAMP environment and have this error message, check if your PHP and MySQL are available from command line (Terminal). To check PHP, do following: Open terminal and type: $ which php If you see something like "/usr/bin/php" that means MAMP's PHP is not available from command ...


1

Not Commerce 2, but in Commerce 3, like this: {% set userIdsWithSubscriptions = craft.subscriptions.limit(null).all()|group('userId')|keys %} {% set users = craft.users.id(userIdsWithSubscriptions).all() %} <ul> {% for user in users %} <li>{{ user.username }}</li> {% endfor %} </ul> Via Nathaniel @ Craft Support (thanks!)


1

With Craft CMS 3, you can spit out current site values directly with currentSite. Site ID: {{ currentSite.id }} Site Handle: {{ currentSite.handle }} Site Name: {{ currentSite.name }} Site Language: {{ currentSite.language }} Is Primary Site?: {{ currentSite.primary }} Base URL: {{ currentSite.baseUrl }} https://...


1

I know this is a year and a half late, but maybe it helps someone else. I have a large multi-site project with a site for country and language. For example: Germany (German) - default - /de-de/ Germany (English) - /en-de/ Austria (German) - /de-at/ Austria (English) - /en-at/ etc I was having this problem when posting to one of my controller's actions and ...


1

That code would still work in Craft 3 and achieve the same thing it did in Craft 2.


1

The problem here was I hadn't included the Accept header xhr.setRequestHeader("Accept", "application/json");


1

This will be fixed in Craft 3.4.11, per craftcms/cms#5820.


1

Since it appears that you are using Craft CMS 3, you can try the purify filter. In your code, change this line: {% set vidcode = embed.isSafe() | trim('<iframe') %} To something like: {% set vidcode = embed | purify | trim('<iframe') %} Documentation:


1

Turned out to be a minor bug in 3.3.0.1. Fixed now.


1

I was able to fix this on my local MAMP installation by following the instructions for making MAMP play nicely with Craft in this guide, then executing the command chmod a+x craft from this tutorial.


Only top voted, non community-wiki answers of a minimum length are eligible