I want to share my solution in case someone will have a similar problem.
In reality, I only need to prepend to the beginning of the item some text if the url field is present. But the selected answer apparently didn't fit my case. This is because some of my sources don't have an author field, and therefore the solution becomes much harder/bigger. Well, that is, if the solution isn't this one:
% Solution 1
\def\prepend{prepend} % Any text goes here
\renewbibmacro{begentry}{\iffieldundef{url}{}{\prepend\addspace}}
But, for example, this one:
I've found the definition of \newbibmacro*{author} and \newbibmacro*{title} in texlive/20*/texmf-dist/tex/latex/biblatex/biblatex.def (which appeared in logs):
\newbibmacro*{author}{%
\ifboolexpr{
test \ifuseauthor
and
not test {\ifnameundef{author}}
}
{\printnames{author}%
\iffieldundef{authortype}
{}
{\setunit{\printdelim{authortypedelim}}%
\usebibmacro{authorstrg}}}
{}}
\newbibmacro*{title}{%
\ifboolexpr{
test {\iffieldundef{title}}
and
test {\iffieldundef{subtitle}}
}
{}
{\printtext[title]{%
\printfield[titlecase]{title}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{subtitle}}%
\newunit}%
\printfield{titleaddon}}
Then I redefined (and reformatted) them like this:
% Solution 2
\def\prepend{prepend} % Any text goes here
\renewbibmacro*{author}{%
\ifboolexpr{
test \ifuseauthor
and
not test {\ifnameundef{author}}
}{%
\iffieldundef{url}{}{\prepend\addspace}%
\printnames{author}%
\iffieldundef{authortype}{}{%
\setunit{\printdelim{authortypedelim}}%
\usebibmacro{authorstrg}%
}%
}{}%
}
\renewbibmacro*{title}{%
\ifboolexpr{
test {\iffieldundef{title}}
and
test {\iffieldundef{subtitle}}
}
{}
{%
\ifboolexpr{% Simple \iffieldundef{author}{}{} didn't work in some cases
test \ifuseauthor
and
not test {\ifnameundef{author}}
}{}{%
\iffieldundef{url}{}{\prepend\addspace}%
}%
\printtext[title]{%
\printfield[titlecase]{title}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{subtitle}%
}%
\newunit%
}%
\printfield{titleaddon}%
}
Now, even if author does not exist (but title does) then the \prepend text is added to the left.
@book{sometag1,
author = {author1},
title = {title1},
year = {year1},
}
@book{sometag2,
author = {author2},
title = {title2},
year = {year2},
url = {url2},
}
@book{sometag3,
author = {author3},
title = {title3},
year = {year3},
}
@book{sometag4,
title = {title4},
year = {year4},
}
@book{sometag5,
title = {title5},
year = {year5},
url = {url5},
}

appendin your example will work on a technical level, aprependfeature does not exist. But thenauthoris a name list, which is parsed according to very specific rules, which means that appending text via a sourcemap may or may not have the desired effect. – moewe Apr 06 '23 at 16:12biblatexstyles support abegentrybibmacro that is executed at the entry head. In theory you could redefine that to print some text.\renewbibmacro{begentry}{\printtext{Foo}}. – moewe Apr 06 '23 at 16:30\renewbibmacroindeed does work, thanks. But I need something that can be used inbiblatex.cfgfile (1). The condition should be checked too (2) (as in example). It would be nice to see a solution that can prepend & append text to any field, but yes, the author field just so happen to be at the beginning. Right now I just need a solution like\renewbibmacrobut which also meets above criteria (1) and (2). – Andrew15_5 Apr 06 '23 at 17:14