From stimuli-responsive polymorphic organic dye crystals to photoluminescent cationic open-framework metal phosphate.