Add A Footer to TFT Display

An IlI9488 TFT Display has been configured on an ESP32-S3. The display has been configured with three pages. Each page displays a footer that is exactly the same for each of the three pages. Rather than include the same code at the end of each page section, I want to find a way to write that section of code once then somehow “publish it”. I tried setting up a script however I couldn’t overcome the reported errors. I think the errors were due to the script being called within the lambda: function of the display code.

I’m looking for an idea that allows me to code the “footer” once then somehow call that section of code into display code an display it at the bottom of each page. The footer code I want to include on each page is;

// ------------------------------------------------------------------------------------- LINE
it.filled_rectangle(9, 292, 460, 2, black);

// ----------------------------------------------------------------------------------- Print Current Time
if(id(ds1307_time).is_failed() == false){
// Refresh Timestamp
// Code by EnsconcE from https://community.home-assistant.io/t/esphome-show-time/348903
char str[40];
time_t currTime = id(ds1307_time).now().timestamp;
strftime(str, sizeof(str), "%I:%M%p %a %b %Oe, %Y", localtime(&currTime));
it.printf(239, 313, id(Regular_16pt), black, TextAlign::BASELINE_CENTER, "%s", str);
} else {
it.print(239, 313, id(Regular_16pt), red, TextAlign::BASELINE_CENTER, "Date And Time Unknown!");
}

// ----------------------------------------------------------------------------------- Print WiFi Strength
// Icon to be printed is generated via include file named wifi_icon.h
it.printf(430, 315, id(font_mdi_small), black, TextAlign::BASELINE_CENTER, wifi_icon(id(wifi_signal_pct).state));

Any insight you can offer would be greatly appreciated.