custom snippet – needs a few tweaks

This topic contains 5 replies, has 4 voices, and was last updated by  Paolo 6 years, 5 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #404389

    m forbes
    Full Member
    Post count: 338

    Hi, I have had this snippet running for a while, it was provided years ago on this forum. I love it! It shows all cpt’s on Add Listing page, except Add Event which shows on a different page.

    I just added a new cpt, gd_announcements, which I need as an option on the Add Event page (it is showing on Add Listing page now). I need a cpt without addresses. I look over the snippet and and “think” I can adjust it, and then chicken out :). I have researched, and am confused about single quotes used in most coding, in regards to, if ($current_posttype!=”gd_events”), where this one uses double quotes.

    I was able to get help in the past, for which I appreciate. You may want me to post this in Jobs, since it is customization… If so, let me know.

    
    
    /** Add Listing w all CPTs minus events */
    add_action('geodir_before_detail_fields', 'geodir_add_listing_before_detail_fields', 0);
    
    function geodir_add_listing_before_detail_fields(){
    	
    	global $post; 
    	
    	$current_posttype = geodir_get_current_posttype();
    	
    	$geodir_allow_posttype = get_option('geodir_allow_posttype_frontend');
    	
    	$post_types = geodir_get_posttypes('object');
    	
    	$addlisting_links = '';
    	
    	if ($current_posttype!="gd_events") {
    	
    
    //test if the key is in the array
    //	if (in_array("gd_event", $geodir_allow_posttype)) {
    //			    echo "trovato evento";
    //
    //$filtraevento = array( 1 );
    //
    //
    //			}
    
    //remove the position 1 (gd events from the new array)
    			$filtraevento = array( 7 );
    			
    			$filtrato = array_diff_key( $geodir_allow_posttype, array_flip( $filtraevento ) );
    
    	foreach($post_types as $key => $postobj){
    		if(is_array($filtrato) && in_array($key, $filtrato) && count($filtrato) > 1){
    		
    			$name = $postobj->labels->singular_name;
    					$checked = '';
    			if($current_posttype == $key) 
    				$checked = 'checked="checked"';
    			
    			$add_link = geodir_get_addlisting_link( $key );
    			$addlisting_links .= '<div style="display:block;line-height:30px; margin-right:14px; float:left;">';
    			$addlisting_links .= '<input type="radio" '.$checked.' value="'.$add_link.'" title="'.ucfirst($name).'" name="geodir_select_add_listing[]"  onchange="javascript:window.location=this.value;" >'.ucfirst($name);
    			$addlisting_links .= '</div>';
    			
    		}
    		
    	}	
    	
    	
    	if($addlisting_links != '')	{
    					if($current_posttype != "gd_event") { 
    		 ?>
    		<h5><?php _e('Select Listing Type', GEODIRECTORY_TEXTDOMAIN); ?></h5>
    		
    		<div class="geodir_form_row clearfix">
    			<div id="geodir_showposttypes" class="geodir_showposttypes">
    			<?php echo $addlisting_links;?>
    			</div>
    		</div> <?php
    		
    	}
     	
    }
    }
    }

    Thank you.

    #404465

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    This would be a customisation, we already gave you an example of how the hook works, which you can pass on to any developer.

    Thanks,

    Stiofan

    #404640

    m forbes
    Full Member
    Post count: 338

    yes, but I am language challenged… even verbal languages :). thank you

    #405258

    m forbes
    Full Member
    Post count: 338

    I have shown this snippet to two local “developers”, neither can help me. I have posted to jobs here on the forum, I have reached out to two online resources. I have tried several adjustments to the code myself, white screen every time. Can anyone recommend a developer for me to contact?

    thanks

    #405283

    Alex Rollin
    Moderator
    Post count: 27815
    This reply has been marked as private.
    #405404

    Paolo
    Site Admin
    Post count: 31206

    You can also check here: https://geodirectoryexperts.com/

    Web n Ware could be your man.

    Thanks

Viewing 6 posts - 1 through 6 (of 6 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket