1

This seems like it should be simple to find, but where does Craft store the status of entries (lightswitch for enabled/disabled)? It doesn't seem to be a column in the entries table, and I can't figure out how the other tables are linked to the entry number.

Background: In a plug-in, I'm trying to filter a query to exclude only those that are disabled.

2

For reference, the status of all elements is stored in the "elements" table, the column is "enabled" and the valid values are 1 and 0. Entry, Category, Matrix, Asset and all other elements will have their id as a foreign key linked to this table

| improve this answer | |
  • Ah, OK, so it looks like the id in the "entries" table is the same as the id in the "elements" table. That leaves me with: $cal->occurrences = (new Query()) ->select('*') ->from("myTable") ->leftJoin('craft_elements', 'myTable.event_id = craft_elements.id') ->Where("craft_elements.enabled = '1'") ->andWhere(...)->all(); which works perfectly. Thank you! – kr37 Aug 19 '19 at 20:24
2

Is this Craft 2 or Craft 3?

There are a few of ways to get entries but basically you could do something like (Craft 3)

use craft\elements\Entry;

$entries = Entry::find()->status(null)->all();

To find all disabled entries.

| improve this answer | |
  • Thank you. Craft 3. I was hoping for something I could use in a query->leftjoin('craft_entries', 'otherTable.entry_id = craft_entries.id') sort of thing, but I suppose this info will work with a for loop to clear out the disabled ones. – kr37 Aug 19 '19 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.