Hybrid mesoporous systems containing a gate-like ensemble functionalised with imidazolium groups and a dye are used for the selective colorimetric sensing of long-chain carboxylates.