New answers tagged

1

The EVENT_REGISTER_CP_URL_RULES event only fires if you're loading a page in the Craft admin itself. If you're loading your site frontend it won't fire, you need to use EVENT_REGISTER_SITE_URL_RULES instead. You can see the logic around this here.


1

The error you're seeing is probably caused by this: ./.env.sh: line 128: $'\r': command not found This error indicates that your OS doesn't recognise the line endings in this file. This means the file isn't parsed correctly, which in turn means your environment variables are wrong (for example, the GLOBAL_DB_DRIVER might include a control character at the ...


1

If you want full control on the activation email site/language/template you just can't rely on sendActivationEmail(). You can do this instead: use craft\mail\Message; // get activation link $verifyUrl = Craft::$app->users->getEmailVerifyUrl($user); // create email $msg = new Message(); $msg->setTo($user->email); $msg->setSubject('Activate ...


2

The getPaymentFormHtml() method will output a huge chunk of code, including Stripe's iframe and all its nested fields and functionality - you can't simply wrap that in a label element and expect it to work, as the click event of the label will not reach inside the iFrame. The default output of Commerce Stripe's getPaymentFormHtml leaves a lot to be desired, ...


1

Make sure you are importing the SproutForms base class into your php file. The code below assumes you'd be using the namespace of your actual custom module and class: <?php namespace modules/mycustommodule; use barrelstrength\sproutforms\SproutForms; class MyCustomClass { public function myCustomMethod() { $formHandle = 'my-form-handle'; $...


1

The error indicates that SproutForms::$app is not an object, which would mean it has not been initialized yet. If you look at the source code, you can see that SproutForms::$app is a static property on the SproutForms class that starts out undefined. It's only assigned the current App instance once it's init method has been executed. The static property ...


2

Rather than assembling the email yourself, you can just call the sendActivationEmail method in Craft: if ($event->isNew) { Craft::$app->getUsers()->sendActivationEmail($user); } That will automatically generate the activation link for you.


1

I like this solution: {# run queue #} {% do craft.app.queue.handleResponse %} {{ craft.app.response.content|raw }} Detailed in this post.


2

Since 3.4, you do this by passing an array of site ID/site-enabled mappings like so: $entry->enabledForSite = [1 => true, 2 => true]; Where 1 and 2 are your chosen site ids.


1

I would like to summarize the conclusion. In order to embed link on SVG image in Craft CMS website, inline SVG is the solution. It works with putting a source code into rich text field, like this; <figure style="width: 100%;"><object data="{{ image_url }}" type="image/svg+xml" width="100%"></object>&...


2

Are you placing the SVG into your web page within an IMG tag, by any chance? If so, try changing to an inline SVG instead. There are quite a few SVG features that don’t work unless you use inline SVG, and from memory links are one of them.


1

Perhaps, the config setting sanitizeSvgUploads could be of help. Whether Craft should sanitize uploaded SVG files and strip out potential malicious-looking content. https://craftcms.com/docs/3.x/config/config-settings.html#sanitizesvguploads


1

I set config variable to general config instead of commerce config. That's all..


1

This sounds like asset transforms are consuming all of the space in the storage directory. Asset transforms take the original asset from the S3 bucket and transform it (resize, crop etc.) for use in various pages on the site. However, while the newly-transformed asset gets saved to the S3 bucket, it's also cached on the local server. With a big enough site ...


1

It's not clear exactly in what context you're sending your email (i.e., whether it's in response to some event on the front/back end), but here's an example of how I'd send an email in a plugin or module. Key here is that in order to access your Craft templates directory, you need to switch the template mode from CP to SITE. You can then use setHtmlBody and ...


2

This is fixed. @brad-bell helped me to understand that the problem was likely being caused by custom module code - he was able to import our database, install composer packages, and then update to the latest Craft version. The big difference between his process and ours was that he didn't have our custom module code. I was able to find the cause by removing ...


1

I suggest to use Sprig plugin provide all ajax and other filter related functionality https://putyourlightson.com/plugins/sprig check it out. use your pagination class and get url after that call ajax. $(document).on('click', '.pagination-link', function(event) { event.preventDefault(); var url = $(this).attr('href'); $('.loading')....


1

You can use event hooks to hook into the saving process for elements to achieve this behaviour. In particular, you can use the hooks Entry::EVENT_BEFORE_SAVE and Entry::EVENT_AFTER_SAVE to perform some custom action before or after an element is saved. Both hooks receive a boolean argument indicating if the element is new. You can use that to either set a ...


1

The issue is confirmed and solved in 3.6.18


Top 50 recent answers are included