Jump to content

theglobe

Members
  • Posts

    14
  • Joined

  • Last visited

Posts posted by theglobe

  1. function test(){
    if(isset($_POST['submitBtn'])) { //form submission occured
    
        if(isset($_POST['switch-1'])){                       
            $pega = date("Y-m-d", strtotime('2017-02-02 17:02:03'));
        }else{
    		$pega = date('Ymd');
    	}
    
    } 
       return $pega;
    }
    
    //FUNCTION SHOWING THE CONFERENCES
    function get_future_conferences() {	
    	$pega2 = test();
    	
    	$args = array(
    		'numberposts' => -1,
    		'post_type'   => 'conference',
    		'post_status' => 'publish',
    		'meta_key'    => 'conference_start_date',
    		'orderby'     => 'meta_value',
    		'order'       => 'ASC',
    		'meta_query'  => array(
    			'key'     => 'conference_start_date',
    			'value'   => $pega2,
    			'compare' => '>=',
    		),
    	);
    
    	$conferences = get_posts( $args );
    
    	return $conferences;
    }

     

  2. <?php if ( $display_section ) : ?>
    
    <section class="page-section spt spb bg-light-gray cfilter-section">
    
    <div class="wrap ml0 mw-970 mlra">
    
    <div class="cfilter-inner">
    
    <?php if ( ! empty( $filter_title ) ) : ?>
    
    <div class="f18 fwb tac"><?php echo $filter_title; ?></div>
    
    <?php endif; ?>
    
    <div class="filter-select-wraps">
    
    <?php if ( $focus_select ) : ?>
    
    <?php echo $focus_select; ?>
    
    <?php endif; ?>
    
    <?php if ( $industry_select ) : ?>
    
    <?php echo $industry_select; ?>
    
    <?php endif; ?>
    
    <?php if ( $org_select ) : ?>
    
    <?php echo $org_select; ?>
    
    <?php endif; ?>
    
    <?php if ( $fifty_states_select ) : ?>
    
    <?php echo $fifty_states_select; ?>
    
    <?php endif; ?>
    
    <?php if ( $type_select ) : ?>
    
    <?php echo $type_select; ?>
    
    <?php endif; ?>
    
    <select class="conf_speakers">
    
    <option value="all">All Speakers</option>
    
    <option value="speaker-f">Fernandez</option>
    
    <option value="speaker-marcus">Marcus Levine</option>
    
    <option value="speaker-am">Andrew Michael</option>
    
    </select>
    
    <div class="checkbox">
    
    <input type="checkbox" id="top-conference" name="top-conference">
    
    <label for="top-conference">Top Conference</label>
    
    </div>
    
    <div class="filter-reset">
    
    Reset Filters
    
    </div>
    
    <form method ="POST">
    
    <label class="switch" for="switch-1">
    
    <div class="slider round"></div>
    
    <input type="checkbox" name="switch-1" id="switch-1" type="submit" >
    
    </label>
    
    <input type="submit" value="Salva" name="submitBtn">
    
    </form>
    
    </div>
    
    </div>
    
    </section>
    
    <?php
    
    endif;

     

  3. Thank you very much for your reply, and for the example. I already have the entire HTML page ready and working. My only problem now is to have the switch/toggle checking if it's on or off, and passing that to the function check all. I believe is the 'action' you were talking before.  
    So, this is my function to check if the toggle/switch is on or off: 

    function show_all () {

    if (isset($_POST['checkbox'])) {

    $pega = date("Y-m-d", strtotime('2017-02-02 17:02:03')); //if ON - $pega is supposed to get this value

    }else{

    $pega = date('Ymd'); //if OFF - $pega is supposed to get this value

    }

    return $pega;

    }

    This is the function that is receiving the value for $pega:

     

    function get_future_conferences() {

    $pega2 = show_all();

    $args = array(

    'numberposts' => -1,

    'post_type' => 'conference',

    'post_status' => 'publish',

    'meta_key' => 'conference_start_date',

    'orderby' => 'meta_value',

    'order' => 'ASC',

    'meta_query' => array(

    'key' => 'conference_start_date',

    'value' => $pega2,

    'compare' => '>=',

    ),

    );

     

    $conferences = get_posts( $args );

     

    return $conferences;

    }

    //the problem is that the function show_all is not getting that the 'checkbox' is ON. The 'value' on $args is getting only the else from the function show_all. 

  4. thank you mac_gyver, and you were right. i changed, but now it's only getting the value of else ($pega = date('Ymd');

    code changed: 

    function get_future_conferences() {

    $pega2 = show_all();

    $args = array(

    'numberposts' => -1,

    'post_type' => 'conference',

    'post_status' => 'publish',

    'meta_key' => 'conference_start_date',

    'orderby' => 'meta_value',

    'order' => 'ASC',

    'meta_query' => array(

    'key' => 'conference_start_date',

    'value' => $pega2,

    'compare' => '>=',

    ),

    );

    $conferences = get_posts( $args );

    return $conferences;

    }

     

     

  5. I currently have a filter set it up for my conferences list, everything is working perfect. I want to add a toggle/switch that when is on, it shows all the conferences (even the past ones). Right now is only showing the ones starting from today ('value' => date ('Ymd'),). I was thinking to create a function that checks if the switch is on or off and it depends on the answer it give the 'value' a different value. But I've tried everything and it's not working, maybe I am doing something wrong. 

    Ps.: I am using date("Y-m-d", strtotime('2017-02-02 17:02:03')); to show the past conferences. If I add that to the 'value' manually it shows the past ones perfectly. 

    Screen Shot 2021-12-20 at 9.03.43 AM.png

  6. foreach ($newdata as $key => $value){

    if(!is_array($value)){

    if($value == " " || $value == 'N/A'){

    unset($newdata[$key]);

    }

    }else {

    if($key == " " || $key == 'N/A'){

    unset($newdata[$key]);

    }

    }

    }

    i changed and took ddata, now it deleted the [DOB] since it was NULL, but it didnt remove [middle] that is inside [name]

  7. There are still elements in the array with blank spaces. Not sure if i am missing something here

    <?php $ch= curl_init('https://coderbyte.com/api/challenges/json/json-cleaning');

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

    curl_setopt($ch, CURLOPT_HEADER, 0);

    $data = curl_exec($ch);

    $newdata = json_decode($data,true);

    foreach ($newdata as $key => $value) {

    if(is_array($value)) {

    foreach ($value as $about => $ddata) {

    if($ddata == "" || $ddata == 'N/A' || $ddata == '-' ) {

    unset($value[$about]); } } }

    else{ if($value == "" || $value == 'N/A' || $value == '-' ) {

    unset($newdata[$key]); } } }

    var_dump($newdata);

    curl_close($ch); ?>

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.