From 8829bafaa683836e0ae16ead818b50ded9ec94f9 Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Sun, 21 Jun 2026 10:01:03 +0100 Subject: Append KLID in brackets to component title where available Add klid correlated subquery to both load() and getList(), then append it in getTitleFromHash(). Enrich title in the getList() foreach so list pages see the updated value without calling getTitleFromHash() themselves. Co-Authored-By: Claude Sonnet 4.6 --- includes/classes/StockComponent.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/includes/classes/StockComponent.php b/includes/classes/StockComponent.php index 01093c9..a214c2f 100755 --- a/includes/classes/StockComponent.php +++ b/includes/classes/StockComponent.php @@ -74,9 +74,11 @@ class StockComponent extends StockBase { $this->getServicesSql( 'content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars ); + $X = BIT_DB_PREFIX; $sql = "SELECT lc.* $selectSql , uue.`login` AS `modifier_user`, uue.`real_name` AS `modifier_real_name` , uuc.`login` AS `creator_user`, uuc.`real_name` AS `creator_real_name` + , (SELECT FIRST 1 x.`xkey` FROM `{$X}liberty_xref` x WHERE x.`content_id` = lc.`content_id` AND x.`item` = 'KLID') AS `klid` FROM `".BIT_DB_PREFIX."liberty_content` lc LEFT JOIN `".BIT_DB_PREFIX."users_users` uue ON (uue.`user_id` = lc.`modifier_user_id`) LEFT JOIN `".BIT_DB_PREFIX."users_users` uuc ON (uuc.`user_id` = lc.`user_id`) $joinSql @@ -214,6 +216,9 @@ class StockComponent extends StockBase { $this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars ); + $X = BIT_DB_PREFIX; + $selectSql .= ", (SELECT FIRST 1 x.`xkey` FROM `{$X}liberty_xref` x WHERE x.`content_id` = lc.`content_id` AND x.`item` = 'KLID') AS `klid`"; + $orderby = !empty( $pListHash['sort_mode'] ) ? " ORDER BY ".$this->mDb->convertSortmode( $pListHash['sort_mode'] ) : ''; @@ -239,6 +244,7 @@ class StockComponent extends StockBase { if( $rows = $this->mDb->query( $query, $bindVars, $pListHash['max_records'], $pListHash['offset'] ) ) { foreach( $rows as $row ) { $row['display_url'] = static::getDisplayUrlFromHash( $row ); + $row['title'] = static::getTitleFromHash( $row ); $ret[$row['hash_key']] = $row; } } @@ -313,6 +319,9 @@ class StockComponent extends StockBase { $ret .= ' '.$pHash['content_id']; } } + if( !empty( $pHash['klid'] ) ) { + $ret .= ' ('.$pHash['klid'].')'; + } return $ret; } return 'empty_component'; -- cgit v1.3