All Questions

Filter by
Sorted by
Tagged with
15 votes
1 answer
3k views

What is getContent() / the ContentModel, and how do I use it to get and set custom field values?

If I want to retrieve content on an element, should I be calling $entry->$fieldHandle or $entry->getContent()->$fieldHandle? What’s the difference? Likewise, if I’m setting new content on an ...
Brandon Kelly's user avatar
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 ...
Eric Ressler's user avatar
  • 1,139
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 ...
user3818623's user avatar
12 votes
2 answers
1k views

Why are some entry detail views empty in the control panel?

I can't seem to edit entry details all of a sudden: in this Products section (and only this one section), the page title and "Current Version" button will render, but the rest of the page is missing. ...
Matt Stein's user avatar
  • 3,996
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}...
carlcs's user avatar
  • 36.2k
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?
Tim Kelty's user avatar
  • 3,071
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 ...
Jason D's user avatar
  • 1,132
4 votes
1 answer
1k views

Complex logic on a ElementCriteriaModel parameter?

How would you combine multiple logical expressions on a ElementCriteriaModel parameter? You could query twice and then merge the two returned arrays of entry models, but that probably wouldn't allow ...
carlcs's user avatar
  • 36.2k
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 ...
bravokiloecho's user avatar
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....
KSPR's user avatar
  • 3,776
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 ...
mohd4482's user avatar
  • 612
16 votes
2 answers
5k views

How to save Matrix data programmatically in Craft 3

How can you programmatically save an entry that has a Matrix field in Craft 3? (Something like this gist for Craft 2)
Brandon Kelly's user avatar
14 votes
4 answers
30k views

FastCGI error when accessing a local development site using MAMP Pro

I'm running across a problem developing a site locally using OS X 10.10 and MAMP Pro 3.0.5 with PHP 5.5.10. Accessing both the site front-end and the back-end admin interface is throwing an error 500 ...
Alex H's user avatar
  • 945
12 votes
2 answers
1k views

What are the differences between an elementCriteriaModel and fetched elements?

I am a little confused about the differences between an elementCriteriaModel and fetched elements. Why do I sometimes have to fetch elements with first(), last(), find(): {% set entries = craft....
Victor's user avatar
  • 8,366
11 votes
1 answer
3k views

Matrix field input error from within the control panel

I have a matrix field with around 26 block types with between 2-6 fields on each. It seems like I've hit a limit and cannot add any more fields to any of the block types. I can add a field if i delete ...
Matthew Woods's user avatar
9 votes
2 answers
8k views

How can I use CSRF protection with AJAX routes?

I have CSRF enabled on my install. I have a bunch of frontend forms so CSRF is pretty important for me. However, when I use AJAX to post to a controller action I get the following error. <div id="...
David A McInnis's user avatar
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 ...
Victor's user avatar
  • 8,366
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 ...
philzelnar's user avatar
17 votes
4 answers
6k views

Is it possible to use Twig in a Rich Text Field?

I have global variables that I want to include in Rich Text Fields, for example: This is a rich text field, call us today at at {{ phone.number }}! This doesn't work out-of-the-box, are there any ...
Jason D's user avatar
  • 1,132
13 votes
1 answer
8k views

How to display all fields belonging to current entry?

How do I modify a template to include a loop that displays all custom fields that I added to the field group that the current entry belongs through? I know how to display the fields individually by ...
Marc's user avatar
  • 233
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 ...
Ben Croker's user avatar
  • 7,266
17 votes
3 answers
7k views

How do i setup ajax paging for entries

Im looking for a good way to setup paging for new items with a simple "load more" button at the bottom. I know i'd use something like {% if craft.request.isAjax %} on the listing template to not ...
Keith Mancuso's user avatar
16 votes
1 answer
3k views

How to get matrix editor into frontend?

I've currently setup a matrix-field for adresses. I added the field as required field to my user-group "Customer". Which breaks the registration, as a user can only be registered, when the matrix has ...
Andre Mohren's user avatar
15 votes
2 answers
4k views

How do I create a locale dropdown to switch between languages?

I’m trying to create a dropdown menu to switch between language’s on my site. I am currently doing this with this snippet found on the google plus community: {% block locale__switch %} {# Loop ...
simonsweeney's user avatar
14 votes
1 answer
9k views

What are the cache options available to a Craft installation?

Reading the Craft docs and other related questions on Stack Exchange there seems to be a lot questions about caching, what it does under different scenarios and how to best utilize it. Is there an ...
Brad Bell's user avatar
  • 67.2k
13 votes
5 answers
7k views

Image transforms returning cpresources url

I'm trying to get Craft to render an image transform defined in the control panel. No image is added to the "filelocation/_transformhandle" folder and returns the url "/cpresources/transforms/98" ...
FrankFlitton's user avatar
11 votes
3 answers
2k views

How to set up {siteUrl} to work with both http and https

I'm looking for a way to set up the general.php file's siteUrl to be able to use both http and https. Only the front-end login would be using the https. This is how I currently have it set up: '...
Kyle's user avatar
  • 367
11 votes
5 answers
7k views

What's the best way to skip CSRF for plugin controllers?

I'm working on a plugin that'll create a private API for content authors to post entries to Craft from desktop-based scripts. These scripts post data to plugin controller actions (anonymous-allowed), ...
Matt Stein's user avatar
  • 3,996
10 votes
2 answers
3k views

Would you use a Structure as navigation over multiple sections (channel entries, indexes and singles)?

I'm setting up my first Craft project and I have a lot of different content. I have around 6 different Channels (News, Events, Blog, Pages, Products, Staff) and ~10 Singles. I have this idea of using ...
naboovalley's user avatar
  • 2,834
7 votes
1 answer
1k views

Is it possible to use the ElementType Modal UI for a custom Field Type Plugin?

So I'm writing a plugin to try and create a relationship between two entry sections that is a two way street (Many to Many). I would love to co-opt the UI and functionality of the ElementType modal ...
Peter Tell's user avatar
  • 1,828
7 votes
3 answers
2k views

Craft Commerce: Validation on Address Fields

Can someone break down how I should validate empty address fields as a plugin for Craft Commerce and take the following answer further? The Craft Commerce documentation provides the following example ...
Dan Lee's user avatar
  • 1,107
4 votes
3 answers
1k views

Get array of titles instead of whole collection of entries' attributes

I know that to get the entries I can do: craft.entries.all() but instead of getting the whole collection of entries, I would like to get an array of titles from those entries (or any other field). ...
Paloma Martinez's user avatar
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 ...
Derek Hogue's user avatar
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?
Brandon Kelly's user avatar
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. ...
Matt Stein's user avatar
  • 3,996
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 ...
pumkincreative's user avatar
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". ...
Lindsey D's user avatar
  • 23.9k
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?
Brad Bell's user avatar
  • 67.2k
16 votes
1 answer
6k views

Git Workflow and Multi Environment - how to approach

I'd like to be able to use git version control with Craft. Is this possible and if it is what is the best approach to ensure that all files/assets and the database are properly synced across local, ...
CreateSean's user avatar
  • 1,963
15 votes
4 answers
13k views

Check user is in User Group / Custom User Permissions

I'm trying to restrict access to items in a channel using some form of custom user permissions however I don't appear to be able to create or set custom read permissions for a channel using crafts ...
Darren's user avatar
  • 433
14 votes
2 answers
3k views

Is it possible to move an entire asset source?

S3 is seemingly costing us a lot. While it has its benefits, I think we could do with moving images from s3 to the server we are running the site from. How difficult/impossible of a task would that be?...
Seán O'Grady's user avatar
13 votes
2 answers
11k views

What's the difference between "is defined" and "is not null"?

{% if var is defined %} and {% if var is not null %} Is there a difference in usage of them?
nicael's user avatar
  • 2,382
11 votes
3 answers
1k views

Prevent Asset Transforms from scaling Image past 100%

There is almost never a reason why I would want an image to be scaled past 100% by a transform. This usually results in an image being looking worse than it would if scaled by the browser. Is there a ...
cmal's user avatar
  • 815
11 votes
2 answers
4k views

How to filter entries by clicking multiple categories on front end

I would like to be able to filter my entries list by multiple categories on the front end. For example, if I first click a category button "lunge" then the results would show entries which are ...
Lori's user avatar
  • 866
9 votes
1 answer
1k views

Two Plugins not showing in CP after pushing to staging server

Two different plugins not showing in the CP after code was pushed to staging server. My questions: 1) Why wouldn't the plugins show in CP if plugins are present in the craft_plugins table? 2) How ...
Moto_Nomad's user avatar
6 votes
1 answer
3k views

Move entry from one structure to another with parenting

Seeing as moving entries between sections isn't supported (yet) through the Craft interface, I followed Brandon's answer for a workaround through the database. I am moving entries from one structure ...
Jamie Wade's user avatar
  • 3,644
5 votes
2 answers
2k views

How to save a matrix content of a new entry in my plugin?

I have a section of type channel with a matrix field. I want to know how I would save the matrix content while I save the entry as well. I know I can save the entry as follows: $entry = new ...
Moin Qidwai's user avatar
5 votes
1 answer
947 views

Craft for Author Agency website?

I'm a complete noob in the Craft world but love to give it a whirl for my latest project - just wondering if it can do what I want it to, and to maybe get some starting points from you guys in the ...
Dr_Codswallop's user avatar
4 votes
5 answers
7k views

Craft 3 language switcher

Does anybody successfully implemented a language switch run Craft 3? Trying the Craft 2 variant slightly adjusted but still running into issues: Invalid site handle: nl <ul> {% set otherLocales ...
Robbie Post's user avatar
4 votes
2 answers
3k views

Save contact form data to database

I have your standard contact form. (Name, email etc.) When the user clicks "save" I want to capture what was entered via a plugin & have a CP page to show the people who have filled out the form. ...
Damon's user avatar
  • 4,706

15 30 50 per page
1
2 3 4 5
29