How might I use a tag to override the default content type of 'story' and rename it?

Comments

vaish’s picture

You could do one of the following:

1. Change human readable name and description while leaving machine readable name as it is.

    <content>
      <type>story</type>
      <name>New name for Story content type</name>
      <description>Put your content type description here.</description>
    </content>

2. delete story content type and create new one according to your liking


    <content delete="1">
      <type>story</type>
    </content>
   
   <content>
     new content type definition goes here
   </content>

Patterns are relying on machine readable name of content type to uniquely identify targeted content type so it is not possible to change it (the same applies to Drupal in general).

I hope this helps.

senpai’s picture

Will Patterns also honor something like <content delete=TRUE> ? It seems more user friendly. This is supposed to be for the average bear, after all.

/me goes off and tries it.

vaish’s picture

<content delete="TRUE"> works fine. (Note that you forgot double quotes around TRUE).

We are working on getting more support for similar user-friendly stuff (yes/no, enable/disable, etc).

senpai’s picture

Status: Active » Fixed

Ahhh Hah! It was the lack of quotes that did it. Or didn't do it, as my case might be. Thanks for the info. I wonder if I should start a Handbook Page for the Patterns module to document stuff like this?

vaish’s picture

Status: Fixed » Active

While looking at your drupal camp pattern I noticed the following comment which I felt needs some clarification:

Remember that once a content type exists in the db, Patterns will not edit or alter it. To make changes to your content type, you must first delete it using <delete></delete>, then re-create it.

This is actually not correct. Patterns are absolutely capable of modifying existing content types. You can edit and change all the settings, add or delete fields and groups, edit display settings. The ONLY thing that you can't change is machine readable name of existing content type as I explained above.

So there is no need to delete content type and recreate just specify existing content type name as 'type' and enter you new settings. Patterns will always first look for existing content type and update it but if content type is not found, new one will be created.

When updating the content type you need to define tags only for the settings you actually want to change. All other settings will be preserved.

vaish’s picture

Double quotes for attributes is part of XML syntax, so I would say this comes under writing valid XML and patterns module enforcing that by doing validation check before listing or importing patterns.

Patterns documentation is also underway and we'll be publishing some stuff soon. I'm taking note of all your feedback and questions and making sure that gets mentioned in documentation as well.

senpai’s picture

Regarding #5, yeah, I figured that out as I was toying around with it, and have corrected my inline documentation, which I will eventually reflect on the http://drupal.org/node/346509 doc page.

<actions>
<!-- CONTENT TYPES -->
<!-- If a content type's "type" exists in the db, Patterns will edit or alter it to
     conform to your newly revised Pattern. To replace a default content type
     such as the 'story' type, you must first delete it using <delete></delete>,
     then re-create it with a new <content></content>. -->
    <content delete="TRUE"><!-- First, delete the existing 'story' type. -->
      <type>story</type>
    </content>
    <content><!-- Create a content type for Announcements that replaces 'story'. -->
      <name>Announcement</name>
      <type>announcement</type>
      ...
    </content>
</actions>
ChrisBryant’s picture

Senpai, I emailed you with a link to the in progress documentation so that you can work from and build on top of that so there isn't duplication of efforts. As soon as things settle down with the D6 release, we can post all of that in the Drupal handbook.

Thanks for getting the doc page started!

senpai’s picture

Sweet, Thanks. I'm reading up on it now.

senpai’s picture

Status: Active » Fixed

Fixored.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.