Invision Community 5: A video walkthrough creating a custom theme and homepage By Matt Thursday at 04:02 PM
szalik.dev Posted March 29, 2023 Posted March 29, 2023 Hello, is there a way to load a Node by column_name instead of by id like it is by default?
Solution szalik.dev Posted March 30, 2023 Author Solution Posted March 30, 2023 (edited) 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, 2023 by CodePixel Martin A. 1
Adriano Faria Posted March 30, 2023 Posted March 30, 2023 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.
szalik.dev Posted March 30, 2023 Author Posted March 30, 2023 (edited) 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, 2023 by CodePixel
Recommended Posts