\documentclass[american]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}
\begin{filecontents}{freeform-apa.dbx}
\ProvidesFile{freeform-apa.dbx}[2020/10/23 v0.1 freeform for biblatex-apa v9.14 (2020/08/28)]
\DeclareDatamodelEntrytypes{
presentation,
constitution,
legmaterial,
legadminmaterial,
nameonly,
freeform}
\DeclareDatamodelFields[type=list, datatype=name]{
groupauthor,
narrator,
execproducer,
execdirector,
with}
\DeclareDatamodelFields[type=list, datatype=literal]{
citation}
\DeclareDatamodelFields[type=field, datatype=literal]{
bibliography,
cite,
firstcite,
source,
article,
section,
amendment,
appentry}
\DeclareDatamodelEntryfields{
with,
groupauthor,
narrator,
execproducer,
execdirector}
% APA Court cases
\DeclareDatamodelEntryfields[jurisdiction]{
organization
citation}
% Legislative material
\DeclareDatamodelEntryfields[legmaterial]{
source}
% Admin and Executive material
\DeclareDatamodelEntryfields[legadminmaterial]{
citation,
source}
% Constitution/charters
\DeclareDatamodelEntryfields[constitution]{
article,
section,
amendment}
\DeclareDatamodelEntryfields[software]{
appentry}
\DeclareDatamodelEntryfields[report]{
addendum,
author,
authortype,
chapter,
doi,
eprint,
eprintclass,
eprinttype,
institution,
isrn,
language,
location,
note,
number,
pages,
pagetotal,
pubstate,
subtitle,
title,
titleaddon,
type,
version}
\DeclareDatamodelEntryfields[presentation]{
addendum,
author,
booksubtitle,
booktitle,
booktitleaddon,
chapter,
doi,
editor,
editortype,
eprint,
eprintclass,
eprinttype,
eventday,
eventendday,
eventendhour,
eventendminute,
eventendmonth,
eventendseason,
eventendsecond,
eventendtimezone,
eventendyear,
eventhour,
eventminute,
eventmonth,
eventseason,
eventsecond,
eventtimezone,
eventyear,
eventtitle,
eventtitleaddon,
isbn,
language,
location,
mainsubtitle,
maintitle,
maintitleaddon,
note,
number,
organization,
pages,
part,
publisher,
pubstate,
series,
subtitle,
title,
titleaddon,
venue,
volume,
volumes}
\DeclareDatamodelEntryfields[freeform]{
bibliography,
cite,
firstcite,
sortkey}
\DeclareDatamodelConstraints[book,inbook,article,report]{
\constraint[type=mandatory]{
\constraintfieldsor{
\constraintfield{author}
\constraintfield{groupauthor}
}
\constraintfield{title}
}
}
\end{filecontents}
\usepackage[backend=biber, style=apa, datamodel=freeform-apa]{biblatex}
\DeclareBibliographyDriver{freeform}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\printfield{bibliography}%
\setunit{\addspace}\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{pageref}%
\usebibmacro{annotation}%
\usebibmacro{finentry}}
\letbibmacro{cite:standard}{cite}
\letbibmacro{textcite:standard}{textcite}
\renewbibmacro*{cite}{%
\ifentrytype{freeform}
{\ifboolexpr{ not test {\ifciteseen}
and not test {\iffieldundef{firstcite}}}
{\printfield{firstcite}}
{\printfield{cite}}%
\setunit{\multicitedelim}}
{\usebibmacro{cite:standard}}}
\renewbibmacro*{textcite}{%
\ifentrytype{freeform}
{\ifboolexpr{ not test {\ifciteseen}
and not test {\iffieldundef{firstcite}}}
{\printfield{firstcite}}
{\printfield{cite}}}
{\usebibmacro{textcite:standard}}}
\DeclareSourcemap{
\maps[datatype=bibtex,overwrite=false]{
\map{
\pertype{freeform}
\step[fieldsource=bibliography, final]
\step[fieldset=sortkey, origfieldval]
\step[fieldset=cite, origfieldval]
}
}
}
\begin{filecontents}{\jobname.bib}
@freeform{cfr,
bibliography = {Charter of Fundamental Rights of the European Union},
}
@freeform{foo,
cite = {Foo},
bibliography = {Foobar},
}
@freeform{goo,
firstcite = {Gfoo},
cite = {Goo},
bibliography = {Goobar},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\begin{document}
\autocite{sigfridsson,cfr,foo}
\autocite{goo}
\autocite{goo}
\printbibliography
\end{document}
miscfor legal material since all the other entry types were eitheronline,bookorarticle, so no side effects. If and only if it's not too difficult, could you please point me to a guidance on how to define a custom entry type, for example - in my case -legal? – Oliver Oct 23 '20 at 09:54