Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

get_grouped_related_keywords()

Description

Retrieves keywords and their related keywords, optionally filtered by specific keywords.

This function returns a list of keywords along with their related keywords grouped
together. It can filter the results based on the provided keyword or specific keyword
string. The related keywords are returned as a comma-separated string.

it filters the results to include only the related keywords for
this keyword.
the results to include only the related keywords for this specific
keyword.

Parameters

ColumnTypeDefaultDescription
$find string "" An optional keyword to find related keywords for. If specified,
$specific string "" An optional specific keyword to find. If specified, it filters

Return

array An array of keywords and their related keywords grouped together.

Location

include/search_functions.php lines 2813 to 2837

Definition

 
function get_grouped_related_keywords($find="",$specific="")
    {
    
debug_function_call("get_grouped_related_keywords"func_get_args());
    
$sql="";$params=array();

    if (
$find!="")
        {
        
$sql="where k1.keyword=? or k2.keyword=?";
        
$params[]="s";$params[]=$find;
        
$params[]="s";$params[]=$find;
        }
    if (
$specific!="")
        {
        
$sql="where k1.keyword=?";
        
$params[]="s";$params[]=$specific;
        }

    return 
ps_query("
        select k1.keyword,group_concat(k2.keyword order by k2.keyword separator ', ') related from keyword_related kr
            join keyword k1 on kr.keyword=k1.ref
            join keyword k2 on kr.related=k2.ref
        
$sql
        group by k1.keyword order by k1.keyword
        "
,$params,"keywords_related");
    }

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 27th November 2024 09:40 Europe/London time.