Description
Theme a field of type 'noderef'If it's a multiple link then display the results as an unordered list, otherwise display a single item. For a multiple link we have to avoid 'None' which has a value of 0, and is not a valid post ID.
Usage
bw_theme_field_noderef( $key, $value, $field );Parameters
- $key
- ( string ) required – the field name
- $value
- ( mixed ) required – the ID of the post either directly or as $value[0] or an array of posts
- $field
- ( array ) required – the information about the field
Returns
voidTO DO
Also support comma separated display format.Source
File name: oik-fields/includes/oik-fields.incLines:
1 to 31 of 31
function bw_theme_field_noderef( $key, $value, $field ) { bw_trace2(); $started = false; //bw_backtrace(); $multiple = bw_array_get( $field['#args'], "#multiple", false ); if ( $multiple ) { if ( is_array( $value ) && count( $value ) ) { foreach ( $value as $key => $v0 ) { if ( $v0 ) { if ( !$started ) { sul(); $started = true; } stag( "li" ); $title = get_the_title( $v0 ); alink( null, get_permalink( $v0 ), $title ); etag( "li"); } } if ( $started ) { eul(); } } } else { $v0 = bw_array_get( $value, 0, $value ); if ( $v0 ) { $title = get_the_title( $v0 ); alink( null, get_permalink( $v0 ), $title ); } } }View on GitHub
Called by
Invoked by
Calls
1 to 7 of 7
- alink() – Create a link
- bw_array_get() – Return the array[index] or array->index (for an object) or a default value if not set
- bw_trace2() – Trace $value to the trace log file if tracing is active
- etag() – Output an end tag
- eul() – End an unordered list
- stag() – Output an HTML opening tag
- sul() – Start an unordered list
