[Tex/LaTex] How to reset frame number in beamer correctly when using parts

beamersectioning

I used some code found here on stackexchange (I don't quite remember where exactly) and structured the beamer-lecture using parts. The problem I encountered is, that the frame number won't reset properly.

At the bottom of the frames there is the total frame number printed. When having different frame number in each part, only the biggest number of all parts is printed, not the total frame number of the individual part.

See the MWE below. Maybe you'll need to download the Aalborg Beamer Theme from this site here.

I hope, that I tinkered the MWE right. As a additional problem, which isn't that serious but only for some additional comfort for quick access to the other parts: Is there a way to display all parts in the sidebar with a link to the first frame?

P.S.: As you can see, I tried resetting the totalframenumber-counter at the beginning of each part as I reset the framenumber. That doesn't work.

P.P.S.: As for the 'make it more minimal'-part; I deleted most of the stuff, hopefully that is enough.

\documentclass[
    10pt,
    ngerman,
    aspectratio=1610,
    ]{beamer}

\usetheme[
    hideothersubsections
]{Aalborg}

% % % % % % % % % % %
% LANGUAGE
% % % % % % % % % % %
\usepackage{polyglossia}
\setmainlanguage[babelshorthands=true]{german}

\addto\captionsngerman{%
    \renewcommand{\partname}{Abschnitt}%
}

% % % % % % % % % % %
% COLORS
% % % % % % % % % % %
\definecolor{AALightBlue}{RGB}{194,193,204}
\definecolor{AADarkBlue}{RGB}{33,26,82}
\definecolor{AAGreyBlue}{RGB}{84,97,110}

% % % % % % % % % % %
% NUPART
% % % % % % % % % % %

\makeatletter
\AtBeginPart{%
    \addtocontents{toc}{\protect\beamer@partintoc{\the\c@part}{\beamer@partnameshort}{\the\c@page}}%
    \setcounter{framenumber}{0}
%   \setcounter{totalframenumber}{0}
}
%% number, shortname, page.
\providecommand\beamer@partintoc[3]{%
    \ifnum\c@tocdepth=-1\relax
    % requesting onlyparts.
    \makebox[6em]{Abschnitt #1:} \textcolor{AADarkBlue}{\hyperlink{#2}{#2}}
    \par
    \fi
}
\define@key{beamertoc}{onlyparts}[]{%
    \c@tocdepth=-1\relax
}
\makeatother%

\newcommand{\nameofthepart}{}
\newcommand{\nupart}[1]{%
    \part{#1}%
    \renewcommand{\nameofthepart}{#1}%
    \frame{\partpage \hypertarget{\nameofthepart}{}}%
}

\newcommand{\nextpart}[1]{
    {
%       \aauwavesbg
        \begin{frame}[plain,noframenumbering]
            \titlepage
        \end{frame}}
        \nupart{#1}

        \begin{frame}{Agenda}{}
            {\footnotesize\tableofcontents}
        \end{frame}
    }

\newcommand{\ftitle}{\frametitle{\secname}\framesubtitle{\subsecname}}

% % % % % % % % % % %
% META-DATA
% % % % % % % % % % %

\title[\LaTeX-Kurs]{\LaTeX-Kurs}

\author{A. Person}

\institute{%
    A. Person\\
    Town}

\begin{document}

\begin{frame}[plain,noframenumbering]{Themeneinteilung}
    \tableofcontents[onlyparts]
\end{frame}

% Neuer Teil
\nextpart{Einführung}
\section{Einführung}
\subsection{Was ist \TeX{}?}

\begin{frame}\ftitle

    text

\end{frame}

\subsection{Vorteile von \LaTeX{}}
\begin{frame}\ftitle

    text

\end{frame}
%%%%%%%%%%%%%%%%

% Neuer Teil
\nextpart{Grundlagen}
\section{Grundlagen}
\subsection{Befehle}

\begin{frame}\ftitle

    text

\end{frame}


\subsection{Erstes Dokument}
\begin{frame}\ftitle

    text

\end{frame}

\subsection{Dokumentklassen}
\begin{frame}\ftitle

    text

\end{frame}

\subsection{Pakete einbinden}
\begin{frame}\ftitle

    text

\end{frame}
%%%%%%%%%%%%%%%%%

\end{document}

Best Answer

The following answer makes use of https://tex.stackexchange.com/a/73346/36296 and https://tex.stackexchange.com/a/244024/36296

The idea of the following answer is not to reset the total frame number, but to calculate the length of the current part.

\documentclass{beamer}

\usepackage{etoolbox}
\makeatletter
\newcount\beamer@partstartframe
\beamer@partstartframe=1
\apptocmd{\beamer@part}{\addtocontents{nav}{\protect\headcommand{%
    \protect\beamer@partframes{\the\beamer@partstartframe}{\the\c@framenumber}}}}{}{}
\apptocmd{\beamer@part}{\beamer@partstartframe=\c@framenumber\advance\beamer@partstartframe by1\relax}{}{}
\AtEndDocument{\immediate\write\@auxout{\string\@writefile{nav}%
    {\noexpand\headcommand{\noexpand\beamer@partframes{\the\beamer@partstartframe}{\the\c@framenumber}}}}}{}{}
\def\beamer@startframeofpart{1}
\def\beamer@endframeofpart{1}
\def\beamer@partframes#1#2{%
    \ifnum\c@framenumber<#1%
    \else%
    \ifnum\c@framenumber>#2%
    \else%
    \gdef\beamer@startframeofpart{#1}%
    \gdef\beamer@endframeofpart{#2}%
    \fi%
    \fi%
}
\newcommand\insertpartstartframe{\beamer@startframeofpart}
\newcommand\insertpartendframe{\beamer@endframeofpart}
\makeatother

\usepackage{tikz}
\usetikzlibrary{calc}

\def\inserttotalpartframenumber{%
    \pgfmathparse{(\insertpartendframe-\insertpartstartframe+1)}%
    \pgfmathprintnumber[fixed,precision=2]{\pgfmathresult}%
}

\def\insertpartframenumber{%
    \pgfmathparse{(\insertframenumber-\insertpartstartframe+1)}%
    \pgfmathprintnumber[fixed,precision=2]{\pgfmathresult}%
}

\setbeamertemplate{footline}{\insertpartframenumber/\inserttotalpartframenumber}

\begin{document}

\begin{frame}
    \tableofcontents
\end{frame}

\part{Einfuhrung}

\frame{1a}
\frame{2a}

\part{Grundlagen}

\frame{1b}
\frame{2b}
\frame{3b \pause blub}

\end{document}