Viewing 6 replies - 16 through 21 (of 21 total)
  • Plugin Author ben.moody

    (@benmoody)

    Try this, replace this code:

    function calculateAge($dob, $date=null) {
    $dob = strtotime($dob);
    $date = $date ? strtotime($date) : time();
    // Calculate the age
    $age = date(‘Y’, $date)-date(‘Y’, $dob);
    // Correct age for leap year
    return (date(‘md’, date(‘U’, $dob)) > date(‘md’, date(‘U’, $date)))
    ? $age-1 : $age;
    }
    //Choix du formulaire
    $form_id = 1;
    $search_criteria = array(
    ‘status’ => ‘active’,
    ‘field_filters’ => array(
    ‘mode’ => ‘any’,
    array(
    ‘key’ => ‘payment_status’,
    ‘value’ => ‘Paid’
    ),
    array(
    ‘key’ => ’22’,
    ‘operator’ => ‘=’,
    ‘value’ => ‘NOW()’
    )
    )
    );

    $my_param = $_GET[‘urlparams’];
    $perPage = 10;
    $total_count= GFAPI::count_entries( $form_id, $search_criteria );

    // Nombre total de page
    $nbPage = ceil($total_count/$perPage);
    if (isset($my_param) && $my_param>0 && $my_param ‘date_created’, ‘direction’ => ‘DESC’ );
    $paging = array( ‘offset’ => (($sPage-1)*$perPage) , ‘page_size’ => $perPage );
    $entries = GFAPI::get_entries( $form_id, $search_criteria, $sorting, $paging, $total_count );
    echo ”;
    foreach($entries as $entry) {
    echo ”;
    echo ” . rgar( $entry,’6.3′) . ‘ ‘ . rgar( $entry,’6.6′) .’ (Age:’.calculateAge(rgar( $entry,’4′),rgar( $entry,’12’)).’)’;
    echo ”;

    //Echo out file urls
    get_entry_files( $entry );

    echo ”;
    echo ‘ Place of Birth:’ ;
    echo ” . rgar( $entry,’11’) . ‘ ‘;
    echo ”;
    echo ‘ Place of Death:’;
    echo ‘ ‘ . rgar( $entry,’13’) . ‘ ‘;
    echo ”;
    echo ‘ Date of death:’;
    echo ” . rgar( $entry,’12’) . ‘ ‘;
    echo ”;
    }

    echo ”;

    if(!empty($my_param) AND intval($my_param)>0 AND intval($my_param)1){
    // echo “Première page “;
    $precedent=$sPage-1;
    echo ” > “;
    // echo “Dernière page “;
    }

    function get_entry_files( $entry ) {

    //Vars
    $uploader_field_number = 36;
    $file_array = array();
    $file_urls = array();

    //Check for uploader field
    if( isset($entry[ $uploader_field_number ]) ) {

    $file_array = maybe_unserialize( $entry[ $uploader_field_number ] );

    //Loop file array and cache url for each file
    foreach( $file_array as $file_id ) {

    $file_urls[] = wp_get_attachment_url( $file_id );

    }

    }

    //output urls
    foreach( $file_urls as $url ) {

    echo $url;

    }

    }

    Thread Starter Sgracia

    (@sgracia)

    Plugin Author ben.moody

    (@benmoody)

    Cool.

    Replace this function again and it will output the images for you:

    function get_entry_files( $entry ) {

    //Vars
    $uploader_field_number = 36;
    $file_array = array();
    $images = array();

    //Check for uploader field
    if( isset($entry[ $uploader_field_number ]) ) {

    $file_array = maybe_unserialize( $entry[ $uploader_field_number ] );

    //Loop file array and cache url for each file
    foreach( $file_array as $file_id ) {

    $images[] = wp_get_attachment_image( $file_id, ‘full’ );

    }

    }

    //output urls
    foreach( $images as $image ) {

    echo $image;

    }

    }

    Thread Starter Sgracia

    (@sgracia)

    why this ? in the html source
    <img class=”avisImages” src=”. get_entry_files( $entry) .”>

    Thread Starter Sgracia

    (@sgracia)

    oopss forget it it’s works i’m too tired xd

    Ty very much for your time !!!

    And is there a way to have easy the first image ?

    or i break the foreach

    Thread Starter Sgracia

    (@sgracia)

    Warning: Invalid argument supplied for foreach() in /home/inrunews/public_html/wp-content/plugins/global-content-blocks/global-content-blocks.php(322) : eval()’d code on line 112

    after the images i have this error

    Good night and ty

Viewing 6 replies - 16 through 21 (of 21 total)
  • The topic ‘Font end entry’ is closed to new replies.