3

In admin/content there is the "status" filter which by default gives us:

any
published
not published
promoted
not promoted
sticky
not sticky

I can see that these map directly to the node table in the database:

mysql> select nid, status, promote, sticky from node;
+-----+--------+---------+--------+
| nid | status | promote | sticky |
+-----+--------+---------+--------+
|   1 |      0 |       0 |      0 |
+-----+--------+---------+--------+

Is there a way to add a 4th boolean column? For example important so in the filter I get important and not important and also in the Publishing options of node/1/edit I also get a checkbox "Important node".

I've seen the http://drupal.org/project/flag project but I want something simpler which will apply this information on the node table. Is it possible?

3
  • 1
    Use CCK to add new field.
    – niksmac
    Commented May 3, 2012 at 16:14
  • 3
    "apply this information on the node" definitely sounds like CCK, but the Flag module was created (and is heavily used) for situations just like the one you're describing. Commented May 3, 2012 at 16:20
  • OK but is it possible to add this as a new column on the node table? Would this be a very "hacky" way to solve this?
    – cherouvim
    Commented May 4, 2012 at 5:16

2 Answers 2

4
+50

I think the Custom Publishing Options module is exactly designed for your needs.

This module allows you to create custom publishing options for nodes. It allows you to add to the default options of Publish, Promote to Front Page, and Sticky. It also ingrates with views to allow you add as a field, sort and filter by, your custom options.

It now allows each of the different options to be shown only on selected node types, as well as integration with Rules/Actions, and permissions for each option type.

1
  • Module is good, just option to synch translations of nodes is missing. So it is not so useful if having i18n sites.
    – Blissful
    Commented Mar 16, 2015 at 10:47
4

Flag would probably be the most 'Drupal' way to do it without writing your own module, which incidentally would be the only way to modify the node table without a significant manual hack. Although I'm pretty sure you wouldn't want to do that as it might affect the way that other parts of Drupal work.

5
  • +1 for Flag. You definitely DON'T WANT to hack core tables. If you really want to do your own code, creat another table and link it to the node table with a FK and/or code.
    – Countzero
    Commented May 8, 2012 at 10:26
  • 3
    @Countzero There's no need to hack core tables, you can update them in a structured way that Drupal will respect. See drupal.stackexchange.com/a/30381
    – Clive
    Commented May 8, 2012 at 12:12
  • OK, you're right and I learned something. Still, I think it's better to avoid messing with core tables if you can avoid it.
    – Countzero
    Commented May 11, 2012 at 14:37
  • @Countzero: Why? It just appends a column on installation and drops it on uninstall. How can this be dangerous?
    – cherouvim
    Commented May 18, 2012 at 13:41
  • 1
    I wouldn't say it's dangerous, just it is a bad habit. Perhaps I'm only a bit too sensitive about data integrity. It's more about good practice (as I intend it) than pure technical reasons.
    – Countzero
    Commented May 21, 2012 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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