Oxalate could be a factor to consider as well. If you reach the point where you have oxalate excess (either because you are consuming a lot of oxalate or your body is producing it), that will definitely make your urine cloudy (not sure about foamy).
I'm not aware of any great info on oxalate that really explains the root cause of a person having oxalate issues. But once you are at that point there are definitely things that can make it worse. Two peaty things that come to mind are collagen (for the hydroxyproline) and OJ (vitamin c). For me at least, both of these things cause noticeably increased cloudiness.