Hot answers tagged

3

I agree that any solution where you run a query and then conditionally render the result isn't very efficient. You can do this in SQL by using the where() condition. craft.entries .section('mySection') .where('content.field_field1 > content.field_field2') .all() Documentation on the where() condition can be found here.


2

As per the docs at https://craftcms.com/docs/3.x/extend/element-types.html#saving-custom-field-values When saving values on a custom field, always use the setFieldValue() or setFieldValues() methods rather than directly accessing the field handle as a property on the element object. This ensures the value is normalized and marked as dirty for delta saves. $...


2

It's not currently possible to charge a fixed tax fee natively, it needs to be a percentage. You can however implement your own tax adjuster within a plugin or module, which is what Craft is doing under the hood. You can specify an amount on the adjuster with a type of tax and it will then show on orders within Craft.


2

To remedy the issue here is some more detail on top of Craft's Knowledge Base Article at Craft on setting up MAMP with Craft CMS: You want to ensure you are using the MAMP PHP executable and MAMP MySQL Server Create bash file in your user folder touch ~/.bash_profile Add the following to the top (make sure you change the PHP version to match Craft Control ...


1

I figured it out. You have to create a separate block and it somehow figures out it's a child based on the level you specify. So something like this: [ 'new1' = [ 'modified' => 1, 'type' => 'parentBlock', 'enabled' => 1, 'collapsed' => 0, 'level' => 0, 'fields' => [ 'theme' =&...


1

Have you tried the $element->isFieldDirty() method, or checking through the $element->dirtyFields array for your asset field, rather than checking revision dates? There may be a good reason why you're not using those, but I thought I'd suggest it in case you hadn't considered it.


1

I can see what you're trying to do here, and it's really not a great idea to be honest: Just to clarify for anyone else - we're not talking about "Entry Types" here - you're talking about the order of the fields as defined in the entry type's field layout. A client should not have access to alter this. Clients and future developers would not expect ...


1

I was able to get the field structure using the below code. {% for entryType in entry.section.entryTypes %} {% set fieldLayouts = entryType.getFieldLayout().getFields() %} {% for field in fieldLayouts %} {{field.blockTypes[0]}}<br/> {% endfor %} {% endfor %} outputs the handles like this header whyChooseUs whatWeDo whoWeWorkWith ourClients ...


1

I think you might be going about this the wrong way. Personally, I'd create a single Matrix or Super Table field and attach that to your home page single. This is far easier for your editors to maintain and doesn't require the entry type's field layout every time you want to rearrange content. However, to answer your question: What you're looking for is the ...


1

It sounds to me like you're running into a collision with Vue's template delimiters vs Twig's, which by default are the same as each other ({{ ... }}). The solution is to change Vue's delimiters to something else when you initialise, like this: const vm = new Vue({ el: '#app', delimiters: ['${', '}'], ... ... }); You'd then need to use ${ ......


1

After endless try and error I finally got it work. I used the ACE version of the email address e.g. client@clientwithö.de -> client@xn--clientwith-ncb.de Although I tried this at the beginning it is working now and I do not know what changed the result. :)


1

You don't need to use Javascript/jQuery for this. You can get the the current url from craft.app.request in some way and do a check as you output your navigation. It looks like you have some custom fields for urls but, For instance, if you wanted to check the last url segment you could use craft.app.request.segment(-1) to get it. Then when outputting your ...


1

Welcome to Stack Exchange! Yes, your syntax is wrong - you need to remove the curly brackets around entry.contactForm.handle, and the quotations, and actually get the handle. {{ craft.freeform.form( entry.contactForm.handle, { instructionsBelowField: true } ).render() }} Source: Freeform docs


1

Here's the documentation you're looking for: Working with Dropdown Field Data You can get the label by adding .label, so you'll end up with {{object.exampleOne.label}} The dropdown field contains a few properties: label selected value (default) valid


1

I am also using MAMP on a Mac, and had similar issues first setting up. There are a few things to check. Under your host settings, use the traditional ports instead of MAMP's custom ports, and set your servers to run as your local Mac user. Then on the MySQL settings window, make sure to allow incoming connections, and check the box to include it in "...


1

Try using _count -- there are some examples here: https://github.com/craftcms/cms/issues/4847


1

The priority option is for setting the jobs in priority order before they start. A job that is already running will not be interrupted for a more important one. I would suggest setting up another queue for the longer tasks. That way, your smaller tasks can continue to run separate to the more demanding ones. There is some guidance on how to do this on an ...


1

Updating Craft on the production server Assuming the up-to-date composer file was committed and pushed to the repository: cd /path/to/repo # Removes any changes that would block the pull and then pulls from master (or your branch name of choice) git reset HEAD --hard git pull origin master composer install --no-dev --no-interaction --prefer-dist --optimize-...


1

Even so this thread is old, maybe my answer can help someone: Cleanup Craft Logs Basically it's possible via app.php to remove all unnecessary logs such as all the $_GET, $_POST, $_SERVER variables and all the SQL being logged. The main point you need is to configure in app.php the log component. The entry 'logVars' will get rid of all the $_SERVER values ...


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