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' %}
{% ...
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 ...
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....
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 ...
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 ...
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 ...
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 ...
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", "...
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 ...
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#...
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 ...
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....
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 ...
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 ...
1
vote
Using XMLReader With Plugin
You need to be in the correct namespace try
$reader = new \XMLReader();
Like here
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
classes × 15plugin-development × 8
craft3 × 2
templating × 2
php × 2
redactor × 2
controller × 2
plugin-craftcommerce × 1
matrix × 1
form × 1
cache × 1
error-message × 1
emails × 1
modules × 1
plugin-contactform × 1
settings × 1
table × 1
extends × 1
elementaction × 1
documentation × 1
xml × 1
plugin-recaptcha × 1