Hot answers tagged

5

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 that list of WebApp methods, though. That's because it (along with other methods) live in AppBehavior, which is a Yii behavior and is very similar to a trait ...


4

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.embed-responsive', { 'class' : 'embed-responsive-16by9' }, false ) }} There are two Retcon filters applied here. The first filter retconWrap wraps matching ...


3

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' %} {% block main %}Hello World{% endblock %} And in your PHP file use craft\mail\Message; $message = new Message(); $message->setTo('john@doe.com'); $message->...


3

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 tables need different classes, this isn't a solution, though.


3

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#shipping-method-interface That is, you must implement each of those functions as defined by the interface in your shipping method class. You'd define this ...


2

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 your extended class, though: $var = new YYY(); $var->doThis = 'CONTENT HERE'; Keep in mind that (usually) if the vendor plugin instantiates any instances ...


2

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. I think what you need is a different variable which only increments whenever you hit a text block (note that this variable should be declared outside the for ...


2

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 well define a route if you like


2

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 existing functionality of the Redactor video plugin. The risk is that future updates to Redactor could break the video plugin. The benefit is that this will make ...


1

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 init() function. If you listen to the EVENT_AFTER_LOAD_PLUGINS event and do your logic there, it should work.


1

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 details about how to import PHP classes: https://www.php.net/manual/en/language.namespaces.importing.php


1

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


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