19

Create a div with whatever contents you want in the modal, and with a class "modal". Then create a new Garnish.Modal object with it: var $div = $('<div class="modal">...</div>'); var myModal = new Garnish.Modal($div);


13

To do this you'll need to take a few steps: Load the necessary resources which include the redactor.css and redactor.js file. And if you are using Craft's macros for your fields, the form macro file. {% includeCssResource "lib/redactor/redactor.css" %} {% includeJsResource "lib/redactor/redactor.js" %} {% import "_includes/forms" as forms %} Add a class ...


12

This is a brain dump of learning resources I can think of. There's the official documentation. Straight Up Craft has some great learning articles and tutorials. They also happen to have the most comprehensive list of Craft plugins until the official plugin store becomes a thing. The Craft site also has help articles and tutorials. The online Craft demo site ...


11

Even if you set the limit to 1, Craft always returns an array of entries. So you need to add first() to access the first (and only) entry. {{ entry.buttonTargets.first() }} It you don't add a property, this returns the entry's title by default. So you additionally need to add url to output the URL of that entry. {{ entry.buttonTargets.first().url }}


9

You can now set allowedFileExtensions and extraAllowedFileExtensions in your config file. The first will re-define the list of allowed files, where the latter will allow you to add additional file types. For example, I needed to add 3 additional formats: 'extraAllowedFileExtensions' => 'bim, dwg, rvt' See the documentation here for details.


7

Like plugins, fieldtypes can have their own settings as you're aware but while you can grab your plugin settings from pretty much anywhere, fieldtypes are a little more contextual. In any case, like @Bryan pointed out, your fieldtype needs to implement prepValue($value) and ideally return a model containing the value as defined in defineAttributes() and the ...


6

Ah, in that case you'll need to make your own ElementType. You should probably check out https://github.com/pixelandtonic/Events - that's meant to be a simple ElementType to serve as an entry point while we get some documentation together. Also, there are some videos to watch over here: http://buildwithcraft.com/docs/plugins/working-with-elements#creating-...


6

You can do this simply by setting your field type’s defineContentAttribute() method to return AttributeType::Mixed, which will tell Craft to JSON-encode its value before storing it in the database. public function defineContentAttribute() { return AttributeType::Mixed; } Then, whatever you submit in the field’s post data will be saved as-is. For ...


6

If what you want is a multi-line plain text field, then check the Allow line breaks checkbox for that field.


6

The Tags field classifiedTags needs an array of tag IDs, not slugs/titles. Also, if this is an existing entry and you want to retain tags already added to the field, you'll need to pull the existing tag IDs using $entry->classifiedTags->ids() and merge with those. $tag = craft()->elements->getCriteria(ElementType::Tag, [ 'groupId' => 1, ...


5

Currently, no. The list you see there is the result of a function in IOHelper called getFileKinds. It just hands out an array of options. While I don't have a recommendation for making this work, I do suggest you send a feature request to: support@buildwithcraft.com With it already being a function, I can see there being a possibility of them allowing users ...


5

If you have created a Color Field the color selector dialogue uses your browsers built-in color selector. On Chrome and Firefox, you should see a dialogue like this: | | | If you click over to the 2nd tab (indicated by the sliders) you'll be able to insert a hex value for the color in the input field at the bottom. In Firefox you'll need to select ...


5

No, that's not possible with Craft at the moment (2.4). You'll have to use the Field Layout Designer from Settings -> Sections -> {Section} -> {Entry Type} to manage your fields and tabs. You could always add a feature request if you feel this is something that should be included in the core.


5

Not directly. You could have a dropdown of all the global set handles (use Dynamic Fields Plugin if you don't want to maintain this dropdown manually), and then in your template fetch the global set from its handle with getSetByHandle: {% set globalSet = craft.globals.getSetByHandle(entry.globalSetHandle.value) %} {% if globalSet %} {# could conceivably be ...


5

I find accessing content like this pretty unintuitive, but I think you will need to use the Twig attribute method. Hopefully the below can help keep you moving in the right direction. I've simplified to just accessing the Matrix Field and I've made an assumption that you know the Matrix field handles you will want to access. {% for fieldLayoutField in ...


5

I don't know if any enum exists (couldn't find it in source), but you could have a look at the contents of the craft/app/fieldtypes folder (and ignore BaseFieldtypes, DataModels and interfaces) to find the identifiers: UsersFieldType.php TagsFieldType.php TableFieldType.php RichTextFieldType.php RadioButtonsFieldType.php PositionSelectFieldType.php ...


4

As far as I know, the only fields that allow defaults are those that extend the BaseOptionsFieldType, namely Dropdown, Multiselect, Checkboxes, and RadioButtons. You could change your lightswitch to one of these other fieldtypes and have a default value available.


4

Not currently, but it should probably be a setting on the field. Craft currently uses jquery.timepicker (in craft/app/resources/lib/jquery.timepicker/jquery.timepicker.js) and is just going with it's default step: 30. I'll add it to “The List”™.


4

You can use either get (via a direct link) or post (via javascript) which can be accessed in your search template using [craft.request.getParam(name)][1], and then either display the template (if a direct link) or return it (via ajax) to your original template. For a full example using post and ajax see this question or this question. These examples use ...


4

You can do this with LJ DynamicFields. In the plugin docs is an example of how to create a dropdown that is a list of all sections.


4

That message comes from from Garnish.Select, when the same DOM element is associated with two separate Garnish.Select instances. The JS will log that message right before destroying the first Garnish.Select instance. It’s not necessarily a bad thing, but could be an indication of something in your JS that could be improved. (Craft’s own JS causes several of ...


4

The values entered in Date/Time fields are always saved as Craft datetime objects. This means it doesn't matter if you configure it to show the date, the time or both, Craft always saves them the same. If you make it to show both, so you're able to enter a time for your events, you have to do this in the field's settings for all entries of your "Event" ...


4

Looks to me like a matrix field with 1 block (Navigation) and two fields : Plain Text - Headline Table - 2 columns with headings Label (Single-line text) and URL (Single-line text) It's worth noting that the table field doesn't have a relations column, so they're probably inserting these URLs manually.


4

Couple things. First, I believe you need to add an extra set of brackets to the name attribute. The reason being that category fields (as well as all 'related' fieldTypes) store more than one element, even if as in this case there is only one category being assigned. Secondly you'll need to assign the category id as the value. <select id="language" name="...


4

You can pull the field directly using craft.fields: {% set myFieldOptions = craft.fields.getFieldbyHandle('myFieldOptions') %} The options will be available under the field's settings.options property. Each option will have attributes for value and label: {% for option in myFieldOptions.settings.options %} {{ option.label }} {{ option.value }} {% ...


4

Static text on the front-end and Craft CP translations are handled through your translation files. All you need to do is name your fields without the translate filter and make sure they have suitable translation arrays in your translation files. It's also worth mentioning you will need Craft Pro to take advantage of localisation and translation features. ...


4

You could make a macro and use that as a "shortcut": {% macro optionLabel(fieldHandle, optionValue) %} {%- set field = craft.fields.getFieldbyHandle(fieldHandle) %} {%- for option in field.settings.options %} {%- if option.value == optionValue %} {{- option.label }} {%- endif %} {%- endfor %} {%- endmacro %} {% ...


4

Store it in a plaintext field, then when you output it, do: {{ entry.myfield | raw }}


4

Solution: {% if block.myFormField|length %} {{ block.myFormField.first().displayForm() }} {% endif %}


4

For those wondering, here is the link to Craft 3 reserved words: https://github.com/craftcms/cms/blob/ae64588a4963b06a093636be6686345bd3a9bca8/src/base/Field.php#L190


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