Hot answers tagged

7 votes
Accepted

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

There are different ways Extending the E-mail template in your template This could be your email template emails/_someMail {% extends 'path/of/your/layout-same-as-you-inserted-in-your-cp' %} {% ...
user avatar
5 votes
Accepted

How to access Craft classes within plugin?

craft() is just a wrapper for the singleton instance of the WebApp class and you can call its methods directly like you're doing with getSiteUrl(). You'll notice that getSiteUrl() actually isn't in ...
user avatar
  • 66.4k
4 votes
Accepted

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

In order to add multiple classes to a video added through Redactor, I'm using the Retcon plugin. This is my solution: {{ entry.body | retconWrap('iframe', 'div.embed-responsive') | retconAttr( 'div....
user avatar
4 votes

How to call Controller in Module?

You need to include your module handle to the route module-handle/site/say You also should use the correct namespace instead of app/controllers I suggest you to read the documentation You can as ...
user avatar
3 votes

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

I've been experiencing a similar problem. I originally handled it with Javascript, but this would only apply the classes I needed after the DOM was loaded. I've gone for an approach that extends ...
user avatar
  • 2,265
3 votes
Accepted

How do you deal with random class and cache?

One workaround to problems like this is using string placeholders. The basic idea is that instead of rendering the actual dynamic value inside {% cache %} tags, you can output a static string ...
user avatar
3 votes

How do you deal with random class and cache?

Randomness and caching are always gonna be at odds. Before you jump at complicated solutions, I'd have a talk about precise requirements, including mentioning the trade-offs involved. Do you really ...
user avatar
  • 5,995
3 votes
Accepted

Calling a setter via craft.app in Twig

I'm curious to know your use case for this, but have you tried using Twig's do tag? https://twig.symfony.com/doc/2.x/tags/do.html i.e. {% do craft.app.session.set("mySession", "...
user avatar
  • 3,794
3 votes

Redactor settings: stripping out classes from table

If all your tables should use the same class or classes, you could use my Retcon plugin to add the classname(s) in Twig: {{ entry.body|retconAttr('table', {class: 'someclassname'}) }} If different ...
user avatar
3 votes
Accepted

Commerce Custom Shipping Methods via Plugin

Ok, so what you're doing is returning a new instance of a shipping method class - this class must meet the Shipping Method interface - documented here: https://craftcommerce.com/docs/shipping-methods#...
user avatar
2 votes

Plugin Development: extending a vendor plugin

In your example, if you do this: $var = new \XXX(); $var->doThis = 'CONTENT HERE'; Then doThis will never exist for class \XXX because \XXX isn't where the method was defined. It would work from ...
user avatar
  • 66.4k
2 votes
Accepted

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

The loop.index0 variable will be incremented for each block, regardless of type, so assuming every other block is a header, it's not surprising that the cycle method prints "even" for every text block....
user avatar
1 vote
Accepted

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

I also noticed that Contact Form Tuner seems to be loading before my plugin when testing with die statements in both plugins. Is this the reason? This. You're probably doing this from your plugin's ...
user avatar
  • 66.4k
1 vote

Class 'Craft' not found

This is not really specific to Craft, but you should import Craft at the beginning of your class file like this: <?php use Craft; ... I suggest you take a look at that documentation for more ...
user avatar
1 vote

Using XMLReader With Plugin

You need to be in the correct namespace try $reader = new \XMLReader(); Like here
user avatar

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