Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

generateNodesExport()

Description

Generates the file content when exporting nodes

Parameters

ColumnTypeDefaultDescription
$field array Array containing field information (as retrieved by get_field)
$parent null
$send_headers boolean false If true, function sends headers used for downloading content. Default is set to false

Return

mixed

Location

include/csv_export_functions.php lines 231 to 267

Definition

 
function generateNodesExport(array $field$parent null$send_headers false)
    {
    global 
$lang$FIXED_LIST_FIELD_TYPES;

    if(
=== count($field) || !isset($field['ref']) || !isset($field['type']))
        {
        
trigger_error('Field array cannot be empty. generateNodesExport() requires at least "ref" and "type" indexes!');
        }

    if(!
in_array($field['type'],$FIXED_LIST_FIELD_TYPES))
        {
        return 
false;
        }

    
$return '';
    
$nodes  get_nodes($field['ref'], $parent);

    foreach(
$nodes as $node)
        {
        
$return .= "{$node['name']}\r\n";
        }

    
log_activity("{$lang['export']} metadata field options - field {$field['ref']}"LOG_CODE_DOWNLOADED);
    
    if(
$send_headers)
        {
        
header('Content-type: application/octet-stream');
        
header("Content-disposition: attachment; filename=field{$field['ref']}_nodes_export.txt");

        echo 
$return;

        
ob_flush();
        exit();
        }

    return 
$return;
    }

This article was last updated 23rd April 2024 14:05 Europe/London time based on the source file dated 23rd February 2024 17:15 Europe/London time.