What are all the niyama (restrictions) before, during and after visiting temples ? Regarding cleanliness, dress, prostration, pradakshan etc.
Some niyama that I know, from traditional elders and from Varaha Purana - apachaar to be avoided :
Clean (madi/vishuppu/aachar) - Bathe. Don't touch bed where you slept, and if you do, bathe again. Don't attend nature's call, and if you do, wash your (organ), feet, hands, and mouth. Don't eat, and if you do, wash your mouth, hands and feet. Don't touch other people who didn't follow above rules or women during menses and if you do, bathe.
Dress - Traditional. Dhoti/Kacch for men, Sari/Madisaar for women. Clean (washed & dried) cloth. Don't wear 2nd-time clothes - that were worn and removed and not cleaned again.
Asoucha - Anybody - Don't go during janana/marana 10 days. Women - don't go during menses, can go after head-bathing on 5th day.
Symbols - Wear tilak - chandan, vibuthi, kumkum.
Hair - Tied in shikha (men) or braid (women). Don't go with untied hair.
Offering - Take fresh flowers, fruits, coconut, tulsi. Wash them. Don't smell or taste them.
Leave Footwear outside
Don't prostrate anyone else other than Bhagavan.
Don't allow anyone else to prostrate you. Don't give or take blessing. Don't praise or denigrate others. Don't praise yourself.
Don't research about type or cost of murti jewels, alankaar etc.
Don't talk wordly chit-chat,cell-phone/text/browsing. No camera photo of Bhagavan, or selfies :)
Give generously. Don't exchange money from priest's plate or Hundi, like putting ₹10 and taking ₹5 (that 5 was offered by someone else)
Don't go apradakshina circle around shrines. Go Pradakshina (from east-south i.e clockwise as seen from top). Don't just pass-through the temple without pranaam to deity, like taking evening walk exercise.
Don't do self-pradakshina (turn-around in one-spot) in front of bhagavan. Don't do 1-handed salute or wave or 'Hi'. Don't extend feet towards Him. Don't turn your back towards Him (walk tilted sideways or backwards). Do both-handed namaskar/anjali.
Don't lie down, or sleep (while sitting also), or eat anything other than Prasad. Even Prasad, eat cleanly, or take little 1-mouthful inside temple, and remaining back at home.
Don't public scene by talking loud, fight, shout, cry, nasty language etc.
Obviously don't attend nature calls, spit, chew-nails, clean-nose, pull-hair etc.
Chant sholkas or mantra or bhajan. Attend religious discourses (upanyasa, pravachana). Attend utsava, vahana, temple festivities.
Give alms to poor outside.
Don't bathe or wash feet when return home. Temples are pure, so there is no uncleanliness. Washing is sign of disrespect.
Offer prasad to family/neighbors who couldn't go. And request them to partake it after becoming clean themselves.
Recall the vigraha murti image mentally, and discuss sad-vishaya with family.
NOTE 1 - if we follow all these rules, but don't have Bhakti, it's pointless :). If we have Bhakti, then we'll automatically follow them because that's what Bhagavan wants from us. If we are in-between (little devotion, little skeptic), then we can treat these rules as minor inconveniences in the pursuit of a higher goal.
NOTE 2 - Why go to temple at all ? To pray or worship