A method for preparing a nanocomposite solid material comprising nanoparticles of a hexacyanometallate or octocyanometallate of an alkali metal and of a transition metal, having the formula [Alk + x]M n+ [M' m] z- where Alk is an alkali metal, x is 1 or 2, M is a transition metal, n is 2 or 3, M' is a transition metal, m is 6 or 8, z is 3 or 4, attached to at least one surface of a porous inorganic solid support, wherein the nanoparticles are attached by adsorption to said at least one surface of the porous inorganic solid support, comprising the following successive steps: a) a porous inorganic solid support is provided; b) at least one surface of the porous inorganic solid support is made basic by contacting said at least one surface with a basic solution, under stirring, until the pH of this basic solution in contact with said at least one surface is stabilised, and remains stable, at a basic value, greater than 7, for a duration of 10 minutes; contacting being performed at a temperature of 15°C to 30°C, without heating, and at atmospheric pressure, without applying pressure, and it being understood that, to determine whether said at least one surface is a basic surface, said at least one surface of the inorganic solid support is contacted with a colour indicator specific to the basic pH range and then the colour of said at least one surface obtained following this contacting is observed; c) the solid support at least one surface of which has been made basic is contacted with a solution, preferably an aqueous solution, containing the M n+ ion, and then the solid support obtained is washed once or several times with water and then optionally dried; d) the solid support obtained at the end of step c) is contacted with a solution containing a [M' m] z- salt, for example a salt of the formula [Alk z] [M' m], and a salt of an alkali metal Alk, and then the solid support thus obtained is washed once or several times with water, and then optionally dried; preferably, the solution comprising a [M' m] z- salt, for example a salt of the formula [Alk z] [M' m], and a salt of an alkali metal Alk, is an aqueous solution; e) steps c) to d) are optionally repeated; preferably steps c) and d) are repeated from 1 to 10 times, still preferably from 1 to 4 times; f) if steps c) and d) are the last steps of the method, then during step c), the solid support obtained is washed once or several times with water, and during step d), the solid support thus obtained is washed once or several times and then dried. a) a porous inorganic solid support is provided; b) at least one surface of the porous inorganic solid support is made basic by contacting said at least one surface with a basic solution, under stirring, until the pH of this basic solution in contact with said at least one surface is stabilised, and remains stable, at a basic value, greater than 7, for a duration of 10 minutes; contacting being performed at a temperature of 15°C to 30°C, without heating, and at atmospheric pressure, without applying pressure, and it being understood that, to determine whether said at least one surface is a basic surface, said at least one surface of the inorganic solid support is contacted with a colour indicator specific to the basic pH range and then the colour of said at least one surface obtained following this contacting is observed; c) the solid support at least one surface of which has been made basic is contacted with a solution, preferably an aqueous solution, containing the M n+ ion, and then the solid support obtained is washed once or several times with water and then optionally dried; d) the solid support obtained at the end of step c) is contacted with a solution containing a [M' m] z- salt, for example a salt of the formula [Alk z] [M' m], and a salt of an alkali metal Alk, and then the solid support thus obtained is washed once or several times with water, and then optionally dried; preferably, the solution comprising a [M' m] z- salt, for example a salt of the formula [Alk z] [M' m], and a salt of an alkali metal Alk, is an aqueous solution; e) steps c) to d) are optionally repeated; preferably steps c) and d) are repeated from 1 to 10 times, still preferably from 1 to 4 times; f) if steps c) and d) are the last steps of the method, then during step c), the solid support obtained is washed once or several times with water, and during step d), the solid support thus obtained is washed once or several times and then dried.