creating base php for getting the global gallery in the correct order