Re: How do I create a custom article type? [repost]

Chris Dudley <[email protected]> Mon, 12 May 2003 14:38:22 +0100
Newsgroups gmane.comp.cms.xaraya.knowledge-base
Organization Xaraya News Server
Message-ID <[email protected]>
 
From: [email protected] (mikespub)
 
In article <b9hgmj$eur$1-FogMEOs31dotat4ziPANHlKoq+OfwspIAL8bYrjMMd8@public.gmane.org>, "Doug Daulton"
<[email protected]> wrote:
>any takers
>
I'm not on IRC often, but here's a little run-down to get you started :)
  
1) think about what kind of fields you'll be needing for your new article type
  
2) go to Articles -> Publication Types and see how the different publication
types make use of the available article fields.
  
Some highlights :
- news : "standard" set of fields and formats
- docs : use file upload to fill in the body, don't use author, date or status
- reviews : use URL and Image formats
- faqs : allow submitter to fill in notes (input is checked)
- pictures : several fields with the same format
- weblinks : notes are formatted as static text to show some imported data
  as read-only. New items won't be able to use this field.
Some potential traps in the field selection :
- title is mandatory (whatever its meaning is)
- bodyfile can only be used for file upload to the database
- authorid, pubdate and status fields cannot be used for other purposes
  
So basically, you have 4 fields you can give a particular meaning to,
plus an optional author, date and status. If you need anything more,
you'll have to use DD for those.
  
Of course, you'll also have hooks like hitcount, ratings, comments etc.
available, and if you want to add some functionality that might be of
use to other modules, you might e.g. make that available via a new
hook module rather than as a simple extra DD field.
  
3) once you know what fields you want to use and how, create the new
   publication type, give it a short lower-case "Type" (used in short URLs)
  and a "Description" (shown in the user interface), and adapt the different
  field definitions like you decided before.
  
--> the publication type is defined (at least as far as articles is
    concerned), so now we'll go to the next step : configuring it :-)
  
4) think about how you want to show your articles to your users, and what
   kind of navigation you'll want to give them
  
5) go to Articles -> Modify Config and see how the different publication
   types are configured in terms of overview and display. Create some
   dummy entries if necessary, and compare the settings with the
   results you see when viewing articles or displaying one.
   And remember that future admins will be able to change those
   according to their wishes...
  
6) in Articles -> Modify Config -> your new publication type, assign one or
   more base categories, and change the default start view to one of those
   categories if that's what you want
  
7) still in the same place, click on Dynamic Data Fields "modify" to add
   any DD fields you might want to use. You'll be taken to a new window
   where you can specify a label and property type for your new field.
  
Tip : to start with, choose some short descriptive label - because its
lower-case equivalent will become the property name you'll be using
in your templates. Afterwards, you can change the label to something
more "user-friendly" if you want.
  
Experiment with the property types by changing them in that window
and seeing how the Add Article screen changes in the original window,
but leave the other options (Default, Data Source, Validation, Status)
as is for now.
  
--> the publication type is configured, so now it's time to create
    templates for it
  
8) when you add a new article and try a preview (or display it as a
   user), you'll see a warning message telling that you don't have a
   template for this publication type yet.
   Basically, you need to create a user-display-<pubtype>.xd and
   a user-summary-<pubtype>.xd template for your new <pubtype>.
  
   The easiest way is probably to copy those of another pubtype
   that is close to what you want to do. You'll find a variable for
   each of the articles fields, plus some special ones like $redirect
   when you have an URL field, or $profile when you have an author.
                                                                                
   Also, you'll find the variables mentioned in Articles -> Modify Config,
   like $counter, $categories, $comments etc. for the user-summary-*
   template, and some of those for the user-display-* template as well.
                                                                                
   Make sure to include them in the templates even if you don't intend
   to use them today - otherwise the settings in Articles -> Modify Config
   won't do you much good :-)
  
   You'll also have variables corresponding to the DD fields you added,
   so if you created a DD property called "Hello" (= with property name
   "hello"), you can use $hello in your template.
   For the user-summary-* template, you won't get variables for the DD
   fields that you gave the status "Display Only" instead of "Active".
  
--> you're ready to start using all this
  
9) if you want, you can define special privileges concerning this new
   publication type. For that, go to Privileges -> Add Privilege -> give
   some descriptive name like "SubmitMyNewPubType", choose module
   "articles" and component "Article", and click on the link "specify
   instances". You'll be taken to another screen where you can select
   the publication type (and possibly a particular category or author),
   and give it some relevant access level.
   Once the privilege is created, assign it to the role(s) you want, via
   Roles -> View Groups -> etc.
  
TODO: DD privileges
  
If you want to use dropdown lists for your DD properties, see
http://www.xaraya.com/newsgroups/article.php?id=68&group=xaraya.knowledge-base
  
Have fun,
                                                                                
Mike.
P.S.: read the admin overview of articles too