15

This is because you loop through all but the current locales. Remove the without filter to loop them all. {% set otherLocales = craft.i18n.getSiteLocaleIds()|without(craft.locale) %} . Add "current" class: To assign the current locale's link a class of "current", compare the looped locale to the current locale and set a variable that you can later test ...


12

This is not the answer you were looking for, but if you decide to just go with a normal drop-down, then you can paste the following into the dropdown field in the database. This would go in the craft_fields table, yourCountryField row, settings column. After editing the list the way you need it I would suggest removing all line-breaks using grep find/replace ...


11

The not so elegant way to do this is to re-use the field somewhere else, where you do have access to (e.g. a global set). But you probably want to avoid this, right? What you can do instead is to access the field directly using craft.fields. This function returns the FieldModel of your field, containing all of its properties. The FieldModel property you ...


6

This would be a good task for a plugin. You'd essentially need to build the plugin to do a couple of things: (1) Use PHP in a service to list the contents of a directory. Once you have that list, you'd then need to... (2) Deliver that information to the front end via a custom field type. You can then use your new custom field type wherever you'd like.


5

I've used the code provided by carlcs and it works great (many thanks for the sample code). I did have to make an adjustment for cases where an entry wasn't translated in every locale. Would have put this in a comment but don't have enough reputation. Nothing fancy, just added another if. Here's what i ended up with: {% set locales = ['nl_be', 'fr_be', 'en'...


5

try using this: https://github.com/lukeholder/dir to populate this plugin with the template names: https://github.com/lewisjenkins/craft-lj-dynamicfields/


5

Have you tried subhead.hLevel.value?


4

This doesn't really address the problem either, but for anyone looking for "States" data (to replicate what Douglas McDonald did), here it is: {"options":[{"label":"Alabama","value":"AL","default":""},{"label":"Alaska","value":"AK","default":""},{"label":"Arizona","value":"AZ","default":""},{"label":"Arkansas","value":"AR","default":""},{"label":"California"...


4

Unfortunately the drop down options in Territories Dropdown Plugin are not automatically available in templates. It need to be accessed through a field on an element. You're currently trying to access it through 'entry' which i assume doesn't exist in your template (as you would have copied this part). eg. I'm using it on projects in my template: {% for ...


4

If the client selects an empty value you probably will get an empty value back. Try this: {# Make sure we have a value #} {% if entry.dropdownFieldHandle != "" %} <dt>Title</dt> <dd>{{ entry.dropdownFieldHandle }}</dd> {% endif %}


4

Yes, if you don't include the dropdown field in your entry form, Craft will store the default value for that field, if one has been set. If no default value has been set, then the value will be null.


3

When working with a dropdown in Twig, it's important to remember that you're dealing with an object (not a simple string). This is an object: {{ entry.myDropdown }} It's easy to forget, however, because Craft works a little magic behind the scenes. There are many objects (including this one) which have an internal __toString behavior. This is called a "...


3

Solved! {% for letter in currentUser.newsletters.options %} <input type="checkbox" value="{{ letter.value }}" name="{{ letter.value }}" id="{{ letter.value }}" {% if letter.selected == true %}checked="checked" {% endif %}/> <label for ="{{ letter.value }}">{{ letter.label }}</label> {% endfor %}


3

You are using a dropdown field, so you can't query for the counties in use directly from the database. (This would be possible if you had chosen to use categories or tags for them.) But what you can do is to loop all your jobs entries to collect their respective counties. {% set entries = craft.entries.section('jobs').limit(null) %} {% set counties = [] %}...


3

I think you just need to get rid of the [] on the field name, so your field becomes: <input type="hidden" name="fields[questionStatus]" value="answered"> As long as the value is the same as the value in the dropdown, it should change. I think the issue you are getting is because you are telling the field that its value is an array, where you just ...


3

Your Code has two errors: 1. was missing. 2. The way you were fetching options was wrong. Here is the correct code: <input type="hidden" name="fields[emergencyContact]" value=""> <input type="hidden" name="fields[emergencyContact][new1][type]" value="contact"> <input type="hidden" name="fields[emergencyContact][new1][enabled]" value="1"> ...


3

You don't need to (more specifically, you can't) nest Twig tags within other Twig tags. Ditch the inner Twig tag and its respective quotes, and just pass the variable directly into the outer Twig tag... {% include entry.dropSubsection %} That being said, I'm not sure this will achieve exactly what you're looking for. You may need to append .value as well......


3

You can use the neo Plugin or you can copy and paste the field settings manually from one field to your matrix field in your database interface. In your craft_fields table there is a column settings you can search for your field handle and copy the settings to your new field. You'll not be able to do this without a custom plugin or copy pasting the values ...


2

Might formattingAdd be something you can use for this? Not tested, just a quick look at Redactor's options page. formattingAdd: [ { tag: 'code', title: 'Code' } ]


2

UPDATE: Knowing your use case I would use a dropdown as you were inside your matrix block and then query what the chosen value was and output the relevant global field. {% if block.dropdownValue == 'globalName' %} {{ globalHandle.globalField }} {% endif %} You won't be able to do this dynamically but as you're adding the values to the dropdown matrix ...


2

Craft saves only the option value of a field, not the option description. After saving and editing again, it loops trough all the option values and compare it with the saved value. If it matchs it selects the first option. You always need to have unique values. For example you can use 5fix and 5var as option values. If you need different outputs in your ...


2

You will only get the defaults for new entries.


2

A checkboxes field returns an array of models, that you can inspect using {{ dump(sourceCountry) }} in your loop. The model has a __toString method that outputs the checkbox value when you output the model using {{ sourceCountry }}. This magic method doesn’t do its thing when you use the model in a comparison operator, so you are currently comparing a model ...


2

What you're currently seeing is the correct URL for a GET form submission. You'll need to update the onsubmit handler to construct the URL you wish to visit, based on the selected option. Here's how to do that, using the omnipresent jQuery. You could probably do the same in plain JS, but I have no idea which browsers you're targeting: (function ($) { $...


2

This can be done like so... {% set matrix = craft.app.fields.getFieldByHandle('myMatrixField') %} {% for field in matrix.blockTypeFields if field.handle=='myDropdownField' %} <select> {% for option in field.options %} <option value="{{ option.value }}">{{ option.label }}</option> {% endfor %} </select> {% ...


2

That is most likely happening because usage is ambiguous for your logos field, so Craft isn’t sure which column to assign the condition to. If you give the usage field within your img block type a different handle, you should get reliable results.


1

Dropdowns are not relations, and therefore they don't need to be eager loaded (and indeed can't be eager loaded). Here's an explanation of what's going on under the hood with eager loading: Speed up your Craft CMS Templates with Eager Loading TL;DR only things that are relations, which are other Elements are candidates for eager loading. Other fields like ...


1

i've got now a working approach to my question above: {% set field = craft.fields.getFieldByHandle('jahrgang') %} <form action="tourdefrance.html" method="post"> <select class="dropdown" name="modelljahr" size="1" onchange="this.form.submit();"> {% for opt in field.settings.options %} <option name="fields[myFieldHandle][]" ...


1

This should get you headed in the right direction: https://www.webstoemp.com/blog/combined-searches-and-filters-craft-cms/


1

I would probably create some categories for make, color and transmission and relate every entry to it. Then you have the ability to use craft.entries... to fetch the entries as you need them. You can find all specs of the entries method in Craft's docs - just fetch all entries that are related to the category you want. Depending on the total number of ...


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