All Questions
14,269
questions
104
votes
8
answers
15k
views
What's the best practice for handling data migration and organization across development environments?
This issue becomes especially difficult when there are multiple environments, with multiple developers working on different features that affect the data structure.
The holy grail is a git-style ...
71
votes
12
answers
148k
views
Getting this SQL Error: GROUP BY incompatible with sql_mode=only_full_group_by
I am getting the following error:
Internal Server Error CDbCommand failed to execute the SQL statement:
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #18
of SELECT list is ...
60
votes
1
answer
12k
views
How secure is Craft and why is it secure?
What measures have been put in place in regards to securing Craft at the core level.
What measures have been put in place in regards to Craft's Plugins which make use of (connect to if you will) Craft'...
41
votes
2
answers
5k
views
What are the best practices for using the {% cache %} tag?
I started using the {% cache %} tag and would like to know what the best practices are:
.
Regarding performance:
For example does it make sense..
..to cache the whole template, or is it better to ...
39
votes
3
answers
11k
views
How to link to previous/next entries in a section?
What would be the equivalent in Craft of ExpressionEngine's Next/Previous entry linking? I was looking at getNext() and getPrev() (and their aliases next and prev) (via the EntryModel docs), but when ...
38
votes
5
answers
12k
views
How can I retrieve channel data in json format?
I've played around with a few implementations but I still don't feel like either is right.
I first came across building the JSON itself. This would be in a file at "craft/templates/entries.json".
[
...
37
votes
3
answers
20k
views
Reset password with MySQL
Is there a way to reset an admin account's password by modifying the MySQL directly?
I've found the craft_users table where the hashed password is stored but I don't know how to hash a string so that ...
37
votes
4
answers
7k
views
What is the current landscape regarding e-commerce plugins for Craft?
I'm developing an online store. The store needs to be seamlessly integrated with all of the editorial content on both the front and back-end. Craft is obviously a perfect candidate for the editorial ...
35
votes
11
answers
50k
views
How can I add a dynamic "active" CSS class to the navigation on any given page?
Just wondering how people approach setting a class of current in their navigation. Is there anything in Craft or Twig where you can set a conditional to check if a page is the current page. Or do you ...
34
votes
3
answers
3k
views
What's the best practice for upgrading a versioned Craft site?
It's thrilling to click The Button and watch Craft update itself. I take advantage of multi-site configurations with every deploy, and my practice thus far is to...
Upgrade Craft in production.
...
34
votes
1
answer
12k
views
What’s the recommended way to set the site URL?
There are multiple ways to set the site URL. What is the recommended way?
32
votes
1
answer
2k
views
Is there a way I can programmatically download the latest version of Craft?
If you have a base install script that you use to quickly turn out a new base install for Craft, it would be very useful for that script to be able to download the latest version of Craft when doing ...
31
votes
2
answers
2k
views
How can I prevent my client from auto-updating Craft in production?
How can I prevent my client from auto-updating Craft in production? I don't want them to run Craft updates on the production site, but the "updates" badge seems irresistible to them. I would prefer to ...
30
votes
4
answers
21k
views
Test for empty field?
How do I check if a field is blank? I thought it was something like
{% if article.articleImage is defined %}
Which in this case is testing an Assets field (and seems to work). Tried the same for a ...
29
votes
3
answers
2k
views
How do I configure Varnish to work with Craft?
Has anyone successfully used Varnish with a Craft build? I'm trying to set up Varnish on my server but I'm very new at this. Can anyone share their config file or point me in the right direction? We ...
28
votes
2
answers
4k
views
How safe is auto-updating?
I have auto-updating currently disabled using the "allowAutoUpdates" config setting, due to concerns about plugin compatibility and unforeseen breakages, mainly due to experiences with other CMS's.
...
27
votes
2
answers
4k
views
What are the most common template performance gotchas to avoid?
I'm coming to Craft as someone experienced with Expression Engine templates. When I'm coding for EE I try to avoid certain big ticket performance hits, for example:
Using embeds excessively.
Using ...
25
votes
9
answers
9k
views
How can I build a language switcher?
I'm currently building a site with two languages, and I need a language switcher so wherever you enter the website you can switch the language easily.
I've come this far:
{% for locale in craft.i18n....
25
votes
4
answers
16k
views
Access environment information in template
Is there a way to check what environment craft is running on - ie, dev or not dev - via the template.
For example:
{%if env is 'dev'%}
hello dev
{% else %}
hello world
{% endif %}
25
votes
1
answer
5k
views
Generating pending image transforms stuck in process
In the CMS the progress indicator for tasks is stuck and not completing its jobs. What can I do to resolve this?
24
votes
3
answers
11k
views
Differences between Craft and WordPress
This is a super high level question but it would be good to get a couple of summary answers. What are the main pros and cons of Craft versus WordPress?
24
votes
3
answers
7k
views
How can I automatically generate responsive images from a single hi-res asset?
I want to be able to upload a single high resolution image, and output a <picture> element that outputs it with a few different sizes and resolutions automatically (using Picturefill to sort out ...
24
votes
4
answers
9k
views
Add home page to a structure?
I am using a structure for all of my site's pages (single pages and channel index pages). The structure settings are as follows:
URL for Top-Level Entries:
{slug}
URL for Nested Entries:
{parent.uri}...
23
votes
3
answers
4k
views
How can I route a specific entry in a structure section to its own template?
While setting up a site recently I wanted to route a specific entry in a structure section to its own custom template. Using a dynamic route sounded like the right option until I remembered that it ...
23
votes
1
answer
2k
views
How can my plugin generate a generic modal window in the Control Panel?
I'm working on a plugin, and it requires a modal to be displayed when the user interacts with a field of my Field Type. When the user finishes interacting with the modal, they would click "Done".
...
22
votes
4
answers
8k
views
How do I import data into Craft?
What's the best known way to import masses of data into Craft?
Are there tools that support the migration of content/users from say XML, JSON etc.
22
votes
3
answers
4k
views
How can I get only those entries with non-empty assets field
Since Craft 2.0 it is possible to pass :empty: and :notempty: to ElementCriteriaModel parameters when you’re looking for empty/non-empty values. If you are for example looking for all entries with a ...
22
votes
1
answer
2k
views
How does template caching work?
The {% cache %} tag is quite powerful, and can be used to greatly increase the performance of templates.
But ultimately the whole thing is still pretty mysterious. I can see three tables in the ...
21
votes
3
answers
429k
views
413 “Request Entity Too Large” error with uploading a file
In assets when uploading a medium size file I get this error:
Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)
What does it mean? And how to fix?
21
votes
1
answer
8k
views
Exclude Current Entry
How can I exclude the current entry when I've structured my syntax like this?
{% set entries = craft.entries({
section: 'blog',
order: 'postDate',
limit: 5,
}) %}
20
votes
3
answers
6k
views
Is there a way to output only the first paragraph of a Rich Text field?
I have a rich text output section I want to limit to the first paragraph so I can link to a full version on another page. What's the best way to do this?
20
votes
3
answers
17k
views
How can I check on the value of a template variable?
If I'm used to PHP's var_dump() and print_r() to check the value of a variable, how can I evolve to inspect things in Craft where Twig's dump isn't available?
20
votes
1
answer
438
views
Transform Info from Handle?
Can I extract a transform's settings from its handle? I'm trying to avoid upscaling images using the workaround, and I'd like to set my transform handle dynamically within some conditionals. (see this ...
19
votes
2
answers
7k
views
Section entries - order by random
I was wondering if it's was possible to order section entries by random.
Example:
{% for entry in craft.entries.section('team').type('mainPeople').order('title random)) %}
19
votes
5
answers
19k
views
Create line breaks from text field
I'm looking for a way to output line break from a text field.
I'm aware of the "Allow line breaks" option and I have set that to true. I've then entered text with multiple new lines. However, when ...
19
votes
3
answers
31k
views
How to return a specific entry?
Hopefully this is a simple question but I couldn't find a clear answer anywhere - I just want to be able to pull in data from a specific entry, where I know the identifier.
In this particular case, ...
19
votes
2
answers
6k
views
Can a plugin add JS or CSS to the control panel?
Say for example, I wanted to add a "Expand/Collapse All" button to Matrix fields.
Is there any way to do this, or is this something more appropriate for a feature request for P&T?
19
votes
1
answer
3k
views
Where can I download previous versions of Craft?
Auto-updating is great and all, but sometimes you need to roll-back to a previous version or build of Craft for whatever reason. Where can you download these?
19
votes
4
answers
5k
views
Can I run one Craft install on multiple domains and/or subdomains?
Is it possible to have one Craft install running multiple domains and/or subdomains?
For example having the same Craft install running a blog Channel at blog.example.com and also an about Single at ...
19
votes
1
answer
2k
views
How do I check if a lightswitch field is false?
I have a Resources page and an archived Resources page made up of entries. I want to show all current resources on the main page (this list should not include the archived ones) and on the archived ...
19
votes
1
answer
8k
views
How do I output the locale’s name?
When I output {{ craft.locale }} in my template, I get the current locale’s ID (e.g. “en”) rather than its name (e.g. “English”).
How do I get the locale’s name?
18
votes
6
answers
6k
views
Solution for Matrix-within-Matrix (or More Robust Table Fields)
I was wondering if anyone has stumbled on a good solution for including matrix-like fields within a matrix block. I’m working on a site where each page's is constructed in one big matrix with several ...
18
votes
9
answers
7k
views
Craft constantly logging out from admin area
While working in the Craft admin area, on a fresh install, I get logged out every once in a while. It makes the CMS unusable.
I have tried:
Clearing cookies
Resetting the cache in the backend
...
18
votes
3
answers
5k
views
Allow user to change or delete their photo for their profile from the front end
How can I allow a user to change or delete their photo for their profile from the front end?
I currently have a form setup for the user to edit their profile but I want to load their current photo (...
18
votes
1
answer
13k
views
How can I determine if a user is logged in, and who that user is?
I'm running some checks to see if there is a user logged in, and if that user is someone specific. When accessing user.isCurrent it's returning 1 when I'm logged in, but returns null when I'm not. ...
18
votes
4
answers
14k
views
What is the recommended Nginx configuration for Craft?
I'm looking for the recommended way of how to configure Nginx server to run Craft.
Currently, I use the following configuration, it works, but I don't know if it could be better:
server {
listen ...
18
votes
2
answers
4k
views
How do I force Craft to regenerate assets transform?
I had to add an image size in the assets transforms; all my pics were previously uploaded, but when I use getUrl('headIpad'), it makes urls like this:
http://host.com/cpresources/transforms/4/
...
18
votes
1
answer
7k
views
How do you create a front-end form for users to submit content?
I'd like to create a form for users to load events (that I will moderate and publish).
How do I do this?
18
votes
4
answers
3k
views
Cache invalidation to automatically update all cached template content?
I am using the cache tag in my templates. How can I assure that a site visitor always gets the data directly from the cache and never has to wait for it to be generated?
My cache gets invalidated ...
17
votes
4
answers
63k
views
How do I target the first item in a Twig for loop?
I'm looping through some images and want to target just the first image. How do I do that?
{% for image in entry.images %}
<img src="{{ image.url }}" alt="{{ image.title }}">
{% endfor %}