14
votes
How can I check from a plugin config file if devMode is enabled?
For those coming here using Craft 3, it's now Craft::$app->getConfig()->general->devMode.
10
votes
Accepted
Multiple developers working on the same site - Project config issues
Your trouble comes from working in the main branch directly, don't do that. Instead, follow a feature branch workflow where every feature is developed in a dedicated branch. This way, every developer ...
9
votes
Accepted
HTML Purifier Config File
Something like this in a .json file should work:
{
"HTML.SafeIframe": true,
"URI.SafeIframeRegexp": "%^(https?:)?//(www\\.youtube(?:-nocookie)?\\.com/embed/)%",
&...
8
votes
Accepted
How can I check from a plugin config file if devMode is enabled?
It's as simple as
if ( craft()->config->get( 'devMode' ) )
{
//do stuff
}
8
votes
Accepted
Craft 3: how can I set dynamic Base URL in sites setting?
So as of Craft CMS 3 RC7, they added a new alias() Twig function.
So what you can do is something like this in your general.php:
'aliases' => [
'@basePath' => getenv('CRAFTENV_BASE_PATH'),
...
7
votes
7
votes
7
votes
Accepted
How to remove index.php?p= permanently?
Taken from this answer on Stack Overflow:
.htaccess mod_rewrite: rewriting querystring to path
<IfModule mod_rewrite.c>
RewriteEngine On
# Remove index.php
RewriteCond %{...
7
votes
Upload file size limits to 256MB
When determining the maximum upload file size, Craft first takes the php.ini file upload_max_filesize, post_max_size and memory_limit into account by getting the minimum value and only then applying ...
6
votes
Accepted
devMode, phpdotenv variable ignored
It looks like getenv returns a string (or false if the variable is not set, but it is in this case). So you need to cast the string to a boolean value to make it work. However, (bool)'false' gives ...
6
votes
Overriding isSystemOn setting for a single page
I realized there is a simpler solution after stepping away from this issue for a bit. There is one page that still returns a 200 code on a Craft site even when the isSystemOn (or isSystemLive as of ...
5
votes
Accepted
How can I localize a URL in a plugin?
You can use UrlHelper::getSiteUrl() instead, which does have a $localeId argument, for generating a URL relative to a given locale’s base URL (per the siteUrl config setting).
So if your siteUrl ...
5
votes
Accepted
Craft can't connect to db.php on live server
The cooldownDuration setting should go in your general.php config file, not in your db.php config file. On your server, is the db on a separate server or is it on the same server? If so, the value for ...
5
votes
Accepted
Passing JSON to Twig
The answer is to create a custom plugin that will read the json files from the folders in the public directory, parse the json, and pull them into the template.
An alternative solution is to use ...
4
votes
Accepted
Plugin Multi-Environment config not working
The issue is that you're putting the multi-environment config code in your plugins/pluginHandle/config.php file, which is just meant to supply default plugin config values.
Users can set custom ...
4
votes
Craft internal error exposing sensitive data
Your guess is correct... as the docs say, you should never have devMode enabled in production environments specifically for reasons like this (as well as many others).
If you find errors that are ...
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()->...
4
votes
Accepted
Some paths and settings being ignored in config
You're close! Those config settings are off in no-mans-land right now. If you want them to apply across all of your multi-environment configs, you need to move them into the '*' array like so:
...
4
votes
Accepted
Hide the Week Start Day
You could do this using the CP CSS plugin from Lindsey DiLoreto.
Install the plugin then add the following custom css:
#weekStartDay-field { display: none; }
Note that this will hide the field for ...
4
votes
Accepted
Cannot remove index.php from URLs either
In this case, the Apache mod_rewrite module wasn't installed, so the <IfModule mod_rewrite.c> block of Craft's default .htaccess file was being skipped not allowing index.php to be rewritten in ...
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.
4
votes
Issues upgrading Craft 2 to 3 - Keep seeing Install Screen not Update screen
If you've seeing any install screen instead of an update screen, that means that Craft can connect to the database server specified in craft/config/db.php file, but it either can't find the database ...
4
votes
help setting up web root to point to /web
You need to configure your webserver/virtualhost to point to the /web directory.
For apache you have DocumentRoot: your_disk_path/web
For nginx you have root: your_disk_path/web
4
votes
Accepted
Working locally after cloning Craft 3 from Hyperlane
Solved. The config/db.php cloned from Hyperlane refers to different env variable names than those used within my .env file. Changing the names in config/db.php solved the issue.
Before:
return [
...
4
votes
Accepted
Invalid Configuration Error in Craft CMS 3 using Nitro 2
This path is on your host machine but this isn't how docker sees things. To Nitro, the location of the folder is /app/web/cpresources.
Without going into too much details, I'd recommend going with an ...
4
votes
Accepted
Project config priority between project config files and database
Question part A. Does the database take precedence or do the project config files take precedence? When Craft loads and there is an inconsistency between both... which setting makes it to the admin ...
3
votes
Set return URL after password is set
Solved this by
creating the Set Password form in a template with the correct
return
setting it's path with setPasswordPath
setting a path for setPasswordSuccessPath to catch forgot password
...
3
votes
siteUrl not updating
When setting siteUrl in config.php, it overrides the "Site URL" setting in CP → Settings → General. It doesn't show the settings in that field.
This is being overridden by the siteUrl config ...
3
votes
General Settings > logo in the template
For version 3.x.x.
Check and get rebrand logo:
{% if craft.rebrand.isLogoUploaded() %}
<img width="{{ craft.rebrand.getLogo().size[0] }}" height="{{ craft.rebrand.getLogo().size[1] }}" src="{{...
3
votes
Accepted
Custom Environmental Settings
Yes it's absolutely possible, and available out of the box with craft.
In your public/index.php file you specify the different environments based on your server name.
With the environment set, ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
config × 256craft3 × 25
multi-environment × 24
url × 18
database × 17
assets × 15
templating × 14
configuration × 14
users × 13
control-panel × 12
plugin-development × 11
localization × 11
php × 11
install × 10
siteurl × 10
server × 8
environmentvariables × 8
multi-site × 7
session × 7
cache × 6
emails × 6
error-message × 5
password × 5
redactor × 4
error × 4