10 votes
Accepted

Plugin settings - file field upload location

Unfortunately, a simple HTML file input on its own isn't enough to upload an image (in Craft or anywhere else) – the input simply exposes the file on your local filesystem to the browser/server. In ...
user avatar
9 votes
Accepted

Commerce & PayPal - What does "Solution Type" mean?

Ignore the terminology, it really makes no sense. What it should say is this... Require customers to use a PayPal account? [Sole] No, a PayPal account is optional. Customers can still choose to pay ...
user avatar
  • 23.6k
8 votes
Accepted

System Status flag in template context

You could use craft.app.isSystemOn. This will return 1 if the System Status is "on" in Settings -> General in the control panel. It will also respect the value of the isSystemOn config setting if you'...
user avatar
  • 601
8 votes
Accepted

Set tabs in settings on Plugin

Here’s a simple plugin with two tabs and two fields, one field per tab. This plugin was generated on https://pluginfactory.io/. It’s a great starting point to get the plugin scaffolding set up. After ...
user avatar
7 votes

How do i get variables from general.php

For Craft 3: Craft::$app->config->general->{var name}
user avatar
  • 396
7 votes

How do i get variables from general.php

craft()->config->get('JsPath');
user avatar
7 votes
Accepted

Plugin Settings UI for saving an array of values

You can use the EditableTable template component (i.e. the same UI component that Table fields use). Note that this will only work inside the Control Panel – not on the front end. The title of this ...
user avatar
6 votes
Accepted

How do I save a Plugin's date settings-field?

Yup, you need to use AttributeType::Mixed as Justin Kimbrell suggests. The date will then be escaped and stored in the database like this: * {"newregistrationdate":{"date":"2\/1\/2015"}} Now, the ...
user avatar
6 votes

How do I reference the settings of my plugin from a template?

In more recent versions of Craft 2.x (I forget when it was added), you can simply do this without needing a plugin: craft.config.get('setting', 'plugin') Where 'plugin' is the name of your plugin's ...
user avatar
  • 66.5k
4 votes
Accepted

How do I reference the settings of my plugin from a template?

Not sure if there's a build in way, but you can set up a template variable that returns the settings model. class MyPluginVariable { public function settings() { return craft()->...
user avatar
  • 35.9k
4 votes
Accepted

Change system settings email address

I think you are referring to the System Email Address under "Settings" -> "E-mail" -> "System Email Address".
user avatar
  • 2,824
4 votes
Accepted

Plugin Settings: Attribute Types, and how to receive

As far as accessing the value of the setting, try: $plugin = craft()->plugins->getPlugin('pluginHandle'); $plugin->getSettings()->getAttribute('pluginSettings1'); If you need to access ...
user avatar
4 votes
Accepted

What does the Timezone in Settings -> General represent?

You set it to whatever timezone the content authors will be in, so for example, when they say an entry’s post date is at 10 AM, Craft knows which timezone that should refer to.
user avatar
4 votes

How do i get variables from general.php

It is considered best practice to use the public get methods, so while the Craft 3 answer is correct, you should try to get in the habit of calling the methods. Craft::$app->getConfig()->...
user avatar
  • 1,031
4 votes
Accepted

Settings in Admin Panel Blank

There's a chance that one of your plugins is causing this behavior. Go into your craft_plugins table, and change the value of enabled to 0 for every single plugin. If your Settings page is then ...
user avatar
  • 23.6k
4 votes
Accepted

Can I set an environment var for SMTP mail servers?

Not an easy way to do this in Craft 2, but this is possible in the upcomgin Craft 3 (currently in beta) using craft/config/app.php, which is multi-environment aware.
user avatar
  • 66.5k
3 votes

Redactor settings: stripping out classes from table

If all your tables should use the same class or classes, you could use my Retcon plugin to add the classname(s) in Twig: {{ entry.body|retconAttr('table', {class: 'someclassname'}) }} If different ...
user avatar
3 votes
Accepted

Plugin settings are rendered wrong

Just remove the extends and set content. The settings twig-code is rendered in a container inside the CP anyways: {% import "_includes/forms" as forms %} <p>Hello Craft</p>
user avatar
  • 268
3 votes
Accepted

Custom validation for plugin settings

The solution provided here actually required some adjustments. Here is what ended up working: In craft/plugins/sample/SamplePlugin.php: <?php namespace Craft; class SamplePlugin extends ...
user avatar
  • 387
3 votes

How do I save a Plugin's date settings-field?

I didn't have time to setup this scenario locally, but you may want to use AttributeType::Mixed. I believe the dateField macro returns the value as an array, so using AttributeType::Mixed should allow ...
user avatar
3 votes
Accepted

Bilingual site page URL issues

Well... the answer was quite simple. 'siteUrl' => array( 'en_ca' => 'http://localhost/mysite', 'fr_ca' => 'http://localhost/mysite/fr', ), The _ca part was what was missing. Now my ...
user avatar
3 votes
Accepted

How to set SMTP Enrcyption with an environment variable

You can name the environment variable whatever you want. The trick is that the variable's value needs to be either none, ssl or tls (i.e. the three options that are supported for the "Encryption ...
user avatar
2 votes
Accepted

Craft Cache Config - Remote Support?

You can configure the Redis cache driver to use an external host, see the config page for the documentation and here for details on copying the default Redis config file and configuring it. Long ...
user avatar
  • 566
2 votes
Accepted

postCpLoginRedirect wrong redirect when used with autoLoginAfterAccountActivation

Ideally I'd like to keep it separate as eventually the CP will be swapped out for a front-end solution, so any clues as to why this is happening? I think you're close. Just so we're on the same ...
user avatar
  • 6,477
2 votes

How do I reference the settings of my plugin from a template?

From what I understand the only way to get plugin info back (in a template) is by doing: {% set plugin = craft.plugins.getPlugin('PluginHandle') %} This returns an instance of PluginVariable for ...
user avatar
  • 4,519
2 votes

Plugin-settings form field for chosing a user?

Copying from the widgets settings I made something that sort of works: Define the setting to be type mixed: protected function defineSettings() { return array( 'jobsemail' =&...
user avatar
  • 631
2 votes
Accepted

Problems Displaying Label and Instructions in Forms

You should be using forms.radioGroupField instead of forms.radioGroup, just like you're using forms.lightswitchField.
user avatar
  • 66.5k
2 votes
Accepted

How to conditionally hide particular plugin settings?

I'm not sure how to do a 3 way toggle with radio boxes, it might involve writing your own JS... but for the checkbox toggle it's pretty straight forward :) {{ forms.checkboxField({ ... toggle ...
user avatar
  • 4,519
2 votes
Accepted

Odd error message when editing field settings (Variable "targetLocaleFieldHtml" does not exist)

This had me stumped for a while, but it turned out to be a custom fieldtype extending BaseElementFieldType, in which the settings attribute targetLocaleField apparently was renamed ...
user avatar
2 votes

Can I disable languages from the General Config Settings?

What I would probably do is to create a new branch in version control that you can deploy to production as long as you have to disable the locales. The reason for this is that there are probably too ...
user avatar
  • 35.9k

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