Invision Power Board 4.2 relational

115 Views Asked by At

Im currently trying to get a relational field from ipb but don't know how. Im currently utilizing the pages application and have a field that uses a Database relation. This is the current function that gets the relational fields:

public function getReciprocalItems()
{
    /* Check to see if any fields are linking to this database in this easy to use method wot I writted myself */
    if ( \IPS\cms\Databases::hasReciprocalLinking( static::database()->_id ) )
    {
        $return = array();
        /* Oh that's just lovely then. Lets be a good fellow and fetch the items then! */
        foreach( \IPS\Db::i()->select( '*', 'cms_database_fields_reciprocal_map', array( 'map_foreign_database_id=? and map_foreign_item_id=?', static::database()->_id, $this->primary_id_field ) ) as $record )
        {
            try
            {
                $recordClass = 'IPS\cms\Records' . $record['map_origin_database_id'];
                $return[ $record['map_field_id'] ][] = $recordClass::load( $record['map_origin_item_id'] );
            }
            catch ( \Exception $ex ) { }
        }

        /* Has something gone all kinds of wonky? */
        if ( ! count( $return ) )
        {
            return FALSE;
        }

        return $return;
    }

    return FALSE;
}

the code ipb uses for display is kind of like twig

0

There are 0 best solutions below