Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video 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 211 to 242

Definition

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

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

    
$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 November 2020 16:35 Europe/London time based on the source file dated 17th November 2020 11:00 Europe/London time.