Skip to main content

Questions tagged [classes]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3 votes
2 answers
188 views

How do you deal with random class and cache?

I recently started using tailwindcss and I generate random classes via the function random() and get "text-nature", "bg-nature", bg-nature-light", "text-culture", &...
Elodie Grondin's user avatar
1 vote
1 answer
277 views

Calling a setter via craft.app in Twig

apologies if this has been asked, I don’t seem to be able to find the solution. What is the correct way to call craft.app.session.set in a Twig template (or any other setter function for that matter)? ...
mitrol's user avatar
  • 262
0 votes
0 answers
24 views

Extending Craft controller classes and using private methods in child class

I created Controller that exptends Craft AssetsController. Hovewer some of AssetsController methods are private - and I cannot use them using $this context in child module, so i just copied them to ...
Piotr Pogorzelski's user avatar
2 votes
1 answer
256 views

\ns\prefix\Plugin::getInstance() returns null from another plugin in Craft 3

I'm building a plugin that extends the functionality of the Contact Form Tuner plugin and customize the email recipients based on different scenarios. The email addresses need to be managed in the ...
biko's user avatar
  • 670
1 vote
1 answer
802 views

Class 'Craft' not found

I am new to PHP and trying to call reCaptcha API in CraftCMS. I have the following variable: $captcha = Craft::$app->getRequest()->getParam('g-recaptcha-response'); But I get the following ...
Amir's user avatar
  • 111
2 votes
2 answers
1k views

How do I wrap my Youtube video from a Redactor field with Bootstrap's responsive classes?

In my Redactor field, I'd like to programmatically wrap all Youtube videos that have been added through Redactor's video plugin with Bootstrap's responsive embed classes. This answers how to add a ...
Vaughn D. Taylor's user avatar
4 votes
1 answer
3k views

How to use the default HTML email template when sending an email from a plugin?

On /admin/settings/email, when the HTML Email Template field is set to a valid template, all system messages are sent using it. They inject the content of the messages inside the {% block main %}{{...
Romain P.'s user avatar
  • 1,840
1 vote
1 answer
109 views

What's the differences between the Mailer and the Message classes?

In the Craft 3 Class Reference (https://docs.craftcms.com/api/v3), there are two classes under craft\mail: Mailer Message I found that I was able to send an email using this: <?php use craft\...
Romain P.'s user avatar
  • 1,840
2 votes
1 answer
3k views

How to call Controller in Module?

I'm very new to craft and I'm having trouble finding an answer to my question (I've scoured the questions on here - but the only answers appear to be for plugins). Basically, I want to submit a form ...
matt's user avatar
  • 21
1 vote
1 answer
49 views

Using XMLReader With Plugin

In my project, I have a reference to XMLReader in a plugin; however, I get this error message: Class 'Craft\XMLReader' not found Here is the code which calls it: $reader = new XMLReader(); Can ...
buck1112's user avatar
  • 400
1 vote
1 answer
273 views

Plugin Development: extending a vendor plugin

I'm using composer to import a third-party (vendor) plugin into my own Craft plugin. But can't figure out how I extend the functionality of the imported (vendor) plugin. For example assuming imported ...
Cole Henley's user avatar
  • 1,741
0 votes
1 answer
51 views

How do I (also) cycle a class on a Matrix block?

I think I am doing exactly the same as here but I only get the "even" class at each iteration. {% for block in entry.articlebody %} {% set index0 = loop.index0 %} {% switch block.type %} ...
Nutmeg's user avatar
  • 598
0 votes
1 answer
299 views

Redactor settings: stripping out classes from table

I have a site (Craft 2.5.2754) and am trying to add a class to a table within Redactor. Even if I disable Clean up HTML and Purify HTML (which would rather not do) the style is getting stripped out on ...
Cole Henley's user avatar
  • 1,741
1 vote
1 answer
548 views

Commerce Custom Shipping Methods via Plugin

I'm looking to add additional shipping methods through a plugin, using the documentation here: https://craftcommerce.com/docs/shipping-methods I'm a little bit lost about how to hook things up, ...
taylor's user avatar
  • 1,128
5 votes
1 answer
453 views

How to access Craft classes within plugin?

I'm working with dates and want to use Craft's Class reference to speed things along but am struggling to figure out how to use them. For example, this works as expected and returns the siteUrl: ...
Clive Portman's user avatar