You should read the section about pgfkeys
in the TikZ & PGF manual. .expand once
as well as .expanded
can solve the problem here, since you want to obtain the same as title={}
when the expansion of \thistitle
is empty (.expand once
is in my opinion a better choice than .expanded
here, since it doesn't expand more than necessary).
\documentclass{article}
\usepackage{tcolorbox}
\begin{document}
\newcommand{\thistitle}{One title}
\begin{tcolorbox}[title/.expand once = \thistitle]
Bla, bla, bla....
\end{tcolorbox}
\renewcommand{\thistitle}{}
\begin{tcolorbox}[title/.expand once = \thistitle]
Bla, bla, bla....
\end{tcolorbox}
\begin{tcolorbox}[title = {}]
Bla, bla, bla....
\end{tcolorbox}
\end{document}

Here is another way using etoolbox
and a custom mytitle
key. It works differently from the previous technique in that it never feeds any expansion of \thistitle
to title
. The title
key is either called with \thistitle
, or not called at all.
\documentclass{article}
\usepackage{tcolorbox}
\usepackage{etoolbox}
\tcbset{mytitle/.code={%
\expandafter\ifstrempty\expandafter{\thistitle}
{}
{\pgfkeysalso{title=\thistitle}}%
}}
\begin{document}
\newcommand{\thistitle}{One title}
\begin{tcolorbox}[mytitle = \thistitle]
Bla, bla, bla....
\end{tcolorbox}
\renewcommand{\thistitle}{}
\begin{tcolorbox}[mytitle = \thistitle]
Bla, bla, bla....
\end{tcolorbox}
\begin{tcolorbox}[mytitle = {}]
Bla, bla, bla....
\end{tcolorbox}
\end{document}
Same output as above.
IfNoValueTF={\thistitle}{true}{false}
(tcolorbox manual, p. 448), but I don't get it at this moment.