i have a document with a template master a page where there is a rectangle colored with the page numbering, if I apply it to the document sometimes it goes under some images, how can i tell indesign to put the rectangle with page numbering always on topo of everithing in the pages?
Add a new layer at the top of the stack and move the number there.
I'm not sure exactly what you meant, but it may be a matter of using layers and giving them a stacking order. If this comment doesn't address the issue, please post a screenshot.
For any given layer, all master page objects are behind all document page objects. If you need a master object in front you must have at least two layers and put that master object on a higher layer than whatever was blocking it.
Does that help?