What's the deal with Deno? We talk with a major contributor to find out. Listen now.

Hot answers tagged

26

Composer! There's already a package for Stripe: https://packagist.org/packages/stripe/stripe-php Install composer. Add a composer.json file in your plugin's root folder. Add this to the composer.json file: { "require": { "stripe/stripe-php": "1.17.2" } } Run php composer.phar update from your plugin's root folder. The library will be ...


19

You can get to any of your config variables (including custom ones) like this: {{ craft.config.xyz }} The environmentVariables array is no different: {{ craft.config.environmentVariables.baseUrl }} See the craft.config documentation.


14

Craft itself, limits the filesize only in the maxUploadFileSize. Default: 16MB However Craft gets limited by: PHP: Has a few values which might cause the problem: memory_limit max_input_time upload_max_filesize post_max_size AmazonS3: If not limited by a policy value, the default is 5GB. User: Sometimes it can be just a Browser issue causing the problem....


12

Craft’s bootstrap file in located at craft/app/index.php. Importing that will get you 99% of the way there. The only problem is, index.php not only loads Craft, it also runs it. In doing so, Craft is going to insist that it completely resolves the request, with a response to the browser. I’m thinking we should move most of that code into a new bootstrap....


12

Update for Craft 3 Craft 3 includes native support for multi-site installation. Here's a link to the official docs and here's a link to another question with more resources. Old answer for Craft 1 & 2 Credit to @LukeHolder for the original answer, but here's a bit more detailed and technical answer. Note, this might not be possible on all hosts. ...


12

Make sure to change the "Site URL" setting to {siteUrl} in your control panel settings... Control Panel > Settings > General > "Site URL" Within your config file, you'll also want to put your siteUrl value inside of an Environment-Specific Variables sub-array: 'mynewcraftsite.dev' => array( 'devMode' => true, 'environmentVariables' => ...


12

One method is using something like the following in your general.php file. Using this method the config settings will take on the scheme of the request being made. I've set both the siteUrl and example environmentVariables below: <?php // Ensure our urls have the right scheme define('URI_SCHEME', ( isset($_SERVER['HTTPS'] ) ) ? "https://" : "http://" ...


11

It's almost always an environmental limitation. The most common culprits are: 1) PHP's memory_limit setting: http://us3.php.net/manual/en/ini.core.php#ini.memory-limit 2) PHP's post_max_size: http://us3.php.net/manual/en/ini.core.php#ini.post-max-size 3) PHP's upload_max_filesize http://us3.php.net/manual/en/ini.core.php#ini.upload-max-filesize These ...


11

Options: 1) Craft will automatically run a backup of the database anytime an update is performed and save it to craft/storage/backups 2) You can manually create a database backup by going to Settings->Tools->Create Database Backup. 3) You can install something like the Dump plugin and create a cron job that points to it to run the backup on a automated ...


10

Move the check the SERVER_NAME switch up above the require_once $path;. You need to set CRAFT_ENVIRONMENT earlier.


10

Yes, it is possible to have a Craft install on multiple domains and subdomains as long as you only access the control panel from a single domain and you only have a single installation of craft that all the domains and subdomains use. The limitation is all domains would be using the same url router and content - although for multi language content having ...


10

The default template path can be changed by setting the CRAFT_TEMPLATES_PATH PHP constant in your index.php file: define('CRAFT_TEMPLATES_PATH', "path/to/templates"); I would recommend, however, that you start with the default path locations, until you are more comfortable with the app. There is a logical system in place which works really well once you ...


10

Solution: return craft()->config->get('environmentVariables')['baseUrl'];


10

For those coming here using Craft 3, it's now Craft::$app->getConfig()->general->devMode.


9

As @Brandon said, the defaults are hardcoded in redactor.js so there isn't a default.json file, but if there was, this is what it would be (from Craft 2.3.2615): { buttons: ['html', 'formatting', 'bold', 'italic', 'deleted', 'unorderedlist', 'orderedlist', 'outdent', 'indent', 'image', 'link', 'alignment', 'horizontalrule'], formatting: ['p'...


9

The simplest way to transform dynamic routes into advanced routes, is to go to your craft_routes table and copy it out of urlPattern: Example: If you have set this in your backend: news-sort/month/<year>/<month> You'll find this in urlPattern: news\-sort\/month\/(?P<year>\d{4})\/(?P<month>(?:0?[1-9]|1[012])) Just remove the ...


9

I solved the problem and am writing it down for future people encountering the same problem. Add the following configuration to the your craft/config/general.php config file: 'omitScriptNameInUrls' => true URLs will start to work fine.


9

Something like this in a .json file should work: { "HTML.SafeIframe": true, "URI.SafeIframeRegexp": "%^(https?:)?//(www\\.youtube(?:-nocookie)?\\.com/embed/)%", "Attr.AllowedFrameTargets": ["_blank"], "HTML.AllowedComments": ["pagebreak"] } Note that the first two lines were ...


8

I had to run sudo php5enmod mcrypt to enable the module. It seems this has changed between 12.04 and 14.04—in 12.04 it was enabled automatically.


8

It's most likely PHP. Most PHP installations come standard with a 2M limit. Check out this Stack Overflow thread for more information on what needs to be adjusted.


8

You can download the locales you want from https://github.com/yiisoft/yii/tree/master/framework/i18n/data and place in your craft/app/framework/i18n/data folder and they will show up as options. Since Yii ships with so many locales, we initially stripped a lot of them out to keep the Craft download size to something reasonable. If there are some locales we ...


8

If you want to use the {siteUrl} tag in your Asset source settings, you'll still additionally need to define it in your environment variables as well. See here as well.


8

There are multiple ways to set the URLs to your files. I don't know if I got your folder structure right. But let's suppose that your web root is set to /var/www/craft-portfolio/public/, your CSS folder is /var/www/craft-portfolio/public/css/ and your Craft folder (actually not relevant) is /var/www/craft-portfolio/craft/. Root-relative URL Root-relative ...


8

Have you tried it? I'm pretty sure that's not going to work as Active Record is tied to the db connection in craft/config/db.php hanging off of craft()->db. You should be able to pull it off with a plugin that instantiates its own DbConnection, though and uses Query Builder instead of Active Record. Completely untested, but something like this: $...


8

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'), '@baseUrl' => getenv('CRAFTENV_BASE_URL'), ], (or whatever/however you want to set them). These aliases can be used in sites’ Base URL settings, ...


7

Currently multi-site support isn't planned. If you want simple multi-site-support you could use the localization feature with a custom locale. But with Craft's auto-update's and easy deployment, why would you want to use MSM anyway? . ...we're pretty against adding it to Craft... at least in the way EE did it, where everything is stored on a per-site ...


7

In your Control Panel, go to Settings > General. Then set your Site URL to {siteUrl}. This will parse out the siteUrl environment variable. For more information, see this thread...


7

On recent Ubuntu systems (for sure on 14.04), mod_rewrite is installed but not enabled within Apache. You may just need to enable the rewrite module and restart Apache. $ sudo a2enmod rewrite $ sudo service apache2 restart


7

If you're not specifically running IIS on Windows, then you can safely remove it.


7

It's as simple as if ( craft()->config->get( 'devMode' ) ) { //do stuff }


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