I try to realize this with etoolbox instead of ifthen.
What I have so far...
\documentclass{article}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\usepackage{etoolbox}
\usepackage[contents={},opacity=1,scale=1.485]{background}
\newtoggle{BgMat}
\settoggle{BgMat}{true}
\AddEverypageHook{%
\iftoggle{BgMat}{%
\ifboolexpe{\isodd{\thepage}}%
{\backgroundsetup{angle=0,position={0.9\textwidth,-
.7\textheight},%
contents={\tikz[remember picture,overlay]{ %
\coordinate (x) at (current page marginpar area.south east|-current page.south east);
\draw[draw=none,fill=magenta!20]([xshift=-\textwidth]x)rectangle(current page.north west);}}}}%
{\backgroundsetup{angle=0,position={0.9\textwidth,-
.7\textheight},%
contents={\tikz[remember picture,overlay]{ %
\coordinate (x) at (current page marginpar area.south east|-current page.south east);
\draw[draw=none,fill=orange!20](x)rectangle(current page.north east);}}}}%
\BgMaterial
}{%
}
}
\usepackage{lipsum} % dummy text
\begin{document}
\lipsum[1-8]
\clearpage
\settoggle{BgMat}{false}% deactivate colored margins
\lipsum[1-8]
\clearpage
\settoggle{BgMat}{true}% activate colored margins
\lipsum[1-8]
\end{document}


etoolboxhere at all (Well, I used it also some years ago before I started to learn about\newifetc. – Dec 31 '17 at 10:34\thepageis not necessarily a literal number (think of roman figures!), so\isoddmight fail – Dec 31 '17 at 10:37\isoddmacro inetoolbox. You meant\ifnumodd, must likely – Dec 31 '17 at 10:55