Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted March 29, 20231 yr Hello, is there a way to load a Node by column_name instead of by id like it is by default?
March 30, 20231 yr Author Solution Update: yes it's possible by doing this: #1: Add this to your Node class: /** * @brief [ActiveRecord] Database ID Fields * @note If using this, declare a static $multitonMap = array(); in the child class to prevent duplicate loading queries */ protected static $databaseIdFields = array('column_name'); #2: then load node row by custom column like so \IPS\yourapp\class\class::load($id, 'column_name'); Edited March 30, 20231 yr by CodePixel
March 30, 20231 yr You shouldn’t replace the ID by the “name”. You should allow both: array( ‘id’, 'column_name'); and call the node using the name, like; ……load( ‘bla bla bla’, ‘column_name’ ); That’s the same case when you load a member by name or email.
March 30, 20231 yr Author Just now, Adriano Faria said: You shouldn’t replace the ID by the “name”. You should allow both: array( ‘id’, 'column_name'); and call the node using the name, like; ……load( ‘bla bla bla’, ‘column_name’ ); That’s the same case when you load a member by name or email. That's good to know, not needed in my case but still, thank you! Edited March 30, 20231 yr by CodePixel