Instead of page, story etc let's have a module with which you can add simple body only nodes. At least moshe and I frequently copy story.module to have a new simple module. For example, event needs this. For permissions it's great to have multiple node types. So I downloaded a copy of content.module from CCK, pressed delete a lot, copied hook_form from story and then rename the stuff to simplenode.module. Then I reviewed the thing but it was really not much, so credit goes to JonBob and jvandyk.

MySQL is:

CREATE TABLE node_type (
  type_name varchar(31) NOT NULL default '',
  label varchar(255) NOT NULL default '',
  description mediumtext NOT NULL,
  help mediumtext NOT NULL,
  PRIMARY KEY  (type_name)
) TYPE=MyISAM;

Comments

chx’s picture

StatusFileSize
new8.81 KB

To save a couple hundred bytes of code and also a lot in DB I removed hard caching of node types. It's surely needed for CCK, not for us.

kbahey’s picture

+1.

This is something needed a lot and will save a lot of code duplication, and tricks like two stub event sumodules.

since CCK will not make it to 4.7, this is the way to go.

Cvbge’s picture

Please change the file name extension, as now it's hard to download.

Maybe we could make type_name longer? 64 or even 128 seems practical (hell, it's VARCHAR, there should be no difference between 31 and 255).

I've skimmed sql part of module, you do INSERT INTO {node_type} (type_name, label, description) VALUES ('%s', '%s', '%s'), what about help column? It's NOT NULL, has no DEFAULT and you don't provide any value for it.

The SELECT * FROM {node_type} nt WHERE 1 ORDER BY nt.type_name ASC won't work in postgres, you need to change WHERE 1 to for example WHERE 1=1. Why do you need WHERE anyway?

eaton’s picture

+1 I'm very much in favor of it. Already using it in a site I'm mocking up.

chx’s picture

StatusFileSize
new8.84 KB
jvandyk’s picture

Cvbge, no need to make type_name longer. We just changed this to go from 8 to 32 chars.

Maybe you're thinking of the label field, which is already 255.

Please keep this as compatible as possible with CCK. Download CCK from CVS, add a new content type and see how it works.

chx’s picture

StatusFileSize
new8.85 KB
Cvbge’s picture

@#6:
I was thinking about type_name (as posted in the first issue post). I assume that it's displayed somewhere on the page. If it is shown to normal user, one who browses the web page, it contains/can contain informative content. As such, I think we should not limit the admin to 31 characters.
If it is not shown to users, then 31 characters is probably enough.

jvandyk’s picture

type_name is the internal name. It is used in urls like node/add/foo where type_name is foo. The foo content type also has a friendly name called label. Note the second column in the table. The label is used when displaying to the user.

chx’s picture

StatusFileSize
new8.59 KB

Upon Dries word, this module is called content. I have fiddled with field names and such to be more in line with current node.module.

chx’s picture

StatusFileSize
new8.57 KB

Also, Dries said that he'd like to see "create $type content" instad of 'create '. $type .' content'. Who am I disagree with easier to read and shorter code?

kbahey’s picture

But isn't the name "content" going to be used by the CCK module?

chx’s picture

I think I told Dries that CCK is already called content....

m3avrck’s picture

Getting this error:

user error: Unknown column 'nt.type' in 'order clause'
query: SELECT * FROM node_type nt ORDER BY nt.type ASC 

Seems line 266 should be type_name and not type. Or is the SQL create wrong?

m3avrck’s picture

Also getting this error which is related:

user error: Unknown column 'type' in 'field list'
query: INSERT INTO node_type (type, name, description, help) VALUES ('story_asdfad', 'new_story', '', '')

Line 185. What is the correct SQL create code? Or is the module code wrong? Please clarify!

m3avrck’s picture

Also, the settings is a bit confusing because Drupal already has Settings > Content-Types ... and now there is Content > Content-Types ... confusing as to what the difference is for each. Also, should the settings for this module go under Settings or be part of the main Administer menu?

chx’s picture

CREATE TABLE node_type (
  type varchar(31) NOT NULL default '',
  name varchar(255) NOT NULL default '',
  description mediumtext NOT NULL,
  help mediumtext NOT NULL,
  PRIMARY KEY (type_name)
) TYPE=MyISAM;

We can talk about the menu placement when it's in. That's something that can tweaked after the freeze.

m3avrck’s picture

error in that SQL, should the primary key be (type,name) I'm assuming?

CREATE TABLE node_type (
  type varchar(31) NOT NULL default '',
  name varchar(255) NOT NULL default '',
  description mediumtext NOT NULL,
  help mediumtext NOT NULL,
  PRIMARY KEY (type,name)
) TYPE=MyISAM;
m3avrck’s picture

I've tried this module but having some problems. I've created a content type but when I goto Create Content, I don't see this new type listed. Also, on the content page, shouldn't this be listed in the drop downs for "show content as..." since this is a new type as well?

jose reyero’s picture

A big +1 for this new module.

chx, why dont you extend it a little bit, with some blocks (latest, active for each type) and custom pages (listing by type), so it could be a core replacement for blog, story and page ?? -- and maybe for forum, with some other small extensions..

We could provide this extended module and some pre-configured node types for that.

However, I think we better let this in into core, and then study that possible replacements, case by case.....

moshe weitzman’s picture

Status: Needs review » Needs work

good idea, but is now old

gábor hojtsy’s picture

Some points now that this topic is hot again (IMHO):

  • Content type creation and settings should be on the same menu page. Currently content types are at "admin-settings-content types". The simple module should also be forwards compatible with CCK (devs know this, just taking notes for those, who are not aware :). Forwards compatibility means menu placement and functionality (CCK should extend this simple functionality, not replace it).
  • Please add no "view" stuff into this module, as Jose suggested. Lets keep node types and blog, forum, book, etc. presentation separate. The goal is to be able to add different node types to a blog, etc. So node types and presentation types should be separated.
  • If this is added, book, story, page, forum and blog node types could be removed, and even poll, if it can be made a node extension feature, so you can directly poll on a picture or an event for example. The upgrade path is clear. If your node table has one of these nodes, then the node type can be added to the DB upon updating.
chx’s picture

Status: Needs work » Needs review
StatusFileSize
new15.92 KB

OK, here we come. DB structure:
CREATE TABLE page_type (
type_name varchar(32) NOT NULL default '',
label varchar(255) NOT NULL default '',
description mediumtext NOT NULL,
`help` mediumtext NOT NULL,
title_label varchar(255) NOT NULL default '',
body_label varchar(255) NOT NULL default '',
PRIMARY KEY (type_name)
);

of course, a proper upgrade patch will follow when this is ironed out. For now, this is for new websites only.

chx’s picture

StatusFileSize
new16.02 KB
dries’s picture

Tested the patch. Seems to work but we'll want to work out some usability glitches.

  1. The term page type is mixed with content type. I vote for 'content type'.
  2. After you added a content type, you should end up on the overview page.
  3. Try to provide a better description of the various fields. For example, the difference between 'description' and 'help text' isn't really clear and got me confused for a second. Can we think of better terminology?
  4. Not sure about the "duplicate" functionality. I can see this being useful for CCK's content types, but not in this case. Creating a new content type (with this patch) takes 30 seconds. The duplicate functionality is somewhat crufty, and not something we offer elsewhere.
dries’s picture

  1. It is possible to create content types with the exact same name.
  2. I ended up with 'content-review' and 'content-review_0'. Looks like inconsistent use of dash and underscore. I prefer a dash.
chx’s picture

Dries, thanks for the review. Add another content-review and you will get content-review_1 . I will talk w/ JonBob about naming this content module and providing hooks for his fields.

gábor hojtsy’s picture

Indeed, page type is misleading, either content type should be renamed to something, or this should also be under the content type name (which concept is extended with addon possibilities by CCK, when installed). Content types with the same name should not be allowed. My review on the interface later.

drumm’s picture

I would really like to see this built into node.module.

That will make UI development easier since there is already a content types screen there.

chx’s picture

Status: Needs review » Closed (won't fix)

The issue is continued in http://drupal.org/node/62340 . This is the #30 comment and we are now very pretty far from where I originally wanted to be.