by matotominac | Jan 29, 2020 | Quick Code | gutenberg, wordpress
It can be useful in some situations to check if one specific Gutenberg block has been used on current page, for example to check if author has set hero block with image to set transparent navigation over that image. Luckily there is a simple function which checks...
by matotominac | Jan 24, 2020 | Quick Code | wordpress
There are situations where you would need to automatically set WordPress post title on post save. One situation I had was the list of past newsletters sent by client’s company. We had month and issue number information set in ACF fields because we needed that...
by matotominac | Jul 25, 2019 | Quick Code
Do you need to make an element Slick slider on mobile while it should be stacked images on desktop? Or opposite – desktop should show the Slick slider but on mobile images should be displayed one below another. You would expect for Slick’s...
by matotominac | Mar 7, 2019 | Quick Code | 404, Craft CMS, Craft CMS 3
There are situations where you need to trigger 404 error when building custom plugin. One example could be when you are querying data from database and there is no data for our query. This is how you do it: use yii\web\NotFoundHttpException; ... throw new...
by matotominac | Jun 25, 2018 | Quick Code | Craft CMS, Craft Commerce
class PluginNamePlugin extends BasePlugin { public function init() { // Clear cart before new product is added craft()->on('commerce_cart.onBeforeAddToCart', function($event){ $cart = craft()->commerce_cart->getCart();...
by matotominac | Apr 5, 2018 | Quick Code | Craft CMS, plugin development
// First we create empty category model $newCategory = new CategoryModel(); // Now we assign our new category to category group. // You can find category group id inĀ /admin/settings/categories. $newCategory->groupId = $categoryGroupId; // Give our new category a...