HendrikEng
  • Member for 5 years, 9 months
  • Last seen more than a month ago
Deploying CraftCMS to Digital Ocean
Accepted answer
6 votes

I would suggest to read through the following articles: https://nystudio107.com/blog/multi-environment-config-for-craft-cms https://nystudio107.com/blog/database-asset-syncing-between-environments-...

View answer
Redirect all but certain requests to index
Accepted answer
4 votes

This will redirect all queries but urls containing: api or robots or utm_source strings return array( '^(?!.*(api|robots|utm_source)).*$' => ['template' => 'index'] );

View answer
Does entry ID change with locale?
3 votes

The ID won't change in different locales, check this answer for reference: Craft 3 language switcher You could also test it in your templates e.g. : {% for locale in craft.app.sites.getAllSites() %} ...

View answer
Using embedded assets plugin to display youtube or vimeo embed urls on a template
Accepted answer
3 votes

You need to define your assets, if the asset field is named videoEmbed in your matrix matrixFieldHandle you would loop through the matrix and grab the first asset with: {% for block in entry....

View answer
Pass image transformations into macro
Accepted answer
3 votes

Edit: I changed it to your variables, not sure if I set the array brackets 100% correct but the idea should work. You could set the defaults in the macro as you already did, then in your template ...

View answer
Sort Categories by Entry Updated
Accepted answer
2 votes

I am not sure if i get what you mean, do you want to have the categories as content blocks, which show the entries ordered by last updated, but the category blocks should be ordered as well e.g. if ...

View answer
How should I set up redirects from http://foo.com to http://www.foo.com
Accepted answer
2 votes

It's not really Craft related, but assuming that you use .htaccess you could set up rewrite conditions to redirect the request: # Rewrite Engine RewriteEngine On # force HTTPS RewriteCond %{HTTPS} ...

View answer
Is there a way to see a fields variant relation in templates?
Accepted answer
2 votes

yes, you could filter the variants for the status enabled to output only the enabled variants of the product. {% set products = craft.products.all() %} {% for product in products %} {{ product....

View answer
Rename Assets when it is uploaded
Accepted answer
2 votes

You are mixing Craft 2 methods with Craft 3 methods. This will get the the assets extension with $asset->getFilename(true) and add test_ in the beginning of the filename: Event::on( \craft\...

View answer
Craft 3 Plugin Development: Add CSS and JS File to Frontend Templates
Accepted answer
2 votes

Did you place the init function within your asset bundle class as stated in the docs? e.g.: <?php namespace ns\prefix; use craft\web\AssetBundle; use craft\web\assets\cp\CpAsset; class ...

View answer
Transfer licenses into another Craft ID account
Accepted answer
2 votes

You will have to release the license in your Craft ID account: https://id.craftcms.com/account/licenses/cms After that you will be able to claim the license in your other Craft ID account: https://id....

View answer
Using a custom Commerce 2 Adjuster in a Craft Plugin
Accepted answer
2 votes

the adjuster had the wrong namespace, changing it to: namespace hendrikeng\friendsdiscount\adjusters fixed the issue

View answer
Element-API: Access the first url of an asset array
Accepted answer
2 votes

you could use array_values() to fetch the first image: ... 'transformer' => function (Entry $entry) { foreach ($entry->images as $image) { $images[] = $image->url; ...

View answer
Return JSON array without extra square brackets
1 votes

change $products[] = to $products = in your for each loop, that should fix the extra square brackets. And if you want to get all entries and their titleVariation fields you should use 'elementType' =&...

View answer
Setting a new / override shippingAddress via axios
Accepted answer
1 votes

Stumbled over the old questions, this is how it works: updateShipping() { const options = { method: 'post', url: '/actions/commerce/cart/update-cart', ...

View answer
Use function provided by plugin only if plugin is installed and enabled
1 votes

you can check if the plugin is installed and enabled with: {% if craft.app.plugins.isPluginEnabled('assetrev') %} {% set fileName = rev(file) %} {% else %} {% set fileName = file %} {% endif %} ...

View answer
Show Entries based on content in a Matrix Field
1 votes

If you have a product entry for each product in your section shop, you could loop and output only the ones that actually have a value in their matrix field salePrice like that: shop = the section ...

View answer
Add rows to editableTableField via custom javascript
1 votes

I would use a custom controller that requests the javascript data and then appends it to your table with a method like: public function appendDataToTable($entryId, $jsData) { $entry = \craft\...

View answer
Get a specific product with Element API, Commerce and Craft 2
1 votes

If you want to get a specific product and it's variants by the productId you could simply do: 'api/product/<productId>' => function( $productId ) { return [ 'elementType' => ...

View answer
Closure in plugin class/ saving and passing a public property
Accepted answer
1 votes

I figured that i could just use Craft::$app->getSession()->set( 'key', $value ); to store the vars in the craft session. class somePlugin extends Plugin { public function init() { ...

View answer
Redactor - formattingAdd isn't changing code
Accepted answer
1 votes

Try this for data attributes: "formattingAdd": { "add-animate": { "title": "Animate", "api": "module.block.format", "args": { "tag": "p", "attr": { ...

View answer
Updating Craft in Laravel Valet dev enviornment
Accepted answer
1 votes

I forgot to add that i use https://github.com/nystudio107/craft-multi-environment as a flexible multi-environment config for Craft CMS. I managed to fix the issue setting two variables to the linked ...

View answer
Making an entry grid with Batch 2,3 (2 in row then 3 in row)
1 votes

I think a way to achieve this, is to use a loop. If the pattern repeats after the third row, you could use odd or even. there might be a better way, https://mijingo.com/blog/where-am-i-in-the-twig-...

View answer
Adding more data to the "commerce/cart/update-cart" action
0 votes

You could either extend the craft commerce update-cart controller or get the specific fields via element-api what will unfortunately result in an extra api call.

View answer