How can the liver and gallblader function in digestion?

Only liver functions. The ability to digest food depends of GI enzymes most of which are produced by the pancreas and then activated by bile produced by the liver. Rather than have bile constantly spilling into the GI tract, The GB acts as a reservoir. When food enters the stomach and reaches the SB digestion occurs with bile activated pancreatin, the bile having been stored in the gallbladder which then empties.