Results 1 to 1 of 1

Thread: Get Address - Custom Function

  1. #1
    Community Partner scarstens's Avatar
    Join Date
    Apr 2010
    Location
    Cave Creek, AZ USA
    Posts
    912
    Thanks
    2
    Thanked 129 Times in 86 Posts

    Get Address - Custom Function

    Replied to your question via Forum.

    In order to "minimize" the changes to core files, I've begun building functions that print what I want and how I want it. Here is an example (and I always protect my functions file on upgrade, not to mention zip/backup the entire site in case I loose anything while trying to upgrade):

    ADD THE FOLLOWING LINES TO YOUR FUNCTIONS.PHP FILE IN THE PROPER BOTTOM SECTION
    Code:
    function cp_make_address_block ($smID, $smIDType, $smGetType) {
    	//gets the address based on the postID
        if($smIDType == 'listing') {
            $make_address = "";
            $make_address = get_post_meta($smID, 'cp_street', true) . '
    '; 
            $make_address .=  get_post_meta($smID, 'cp_city', true) . ',' . get_post_meta($smID, 'cp_state', true) . '' . get_post_meta($smID, 'cp_zipcode', true);
            $make_address = trim($make_address, ',');
        }
        return $make_address;
    }
    Now anywhere I want to place the address of the listing, I simply call this function:
    Code:
    <?php echo cp_make_address_block ($post->ID, 'listing', 'addressblock') ?>
    You could paste the address of the listing all over the place. But primarily so far I have used this to paste the address block in the Poster tab when viewing an ad.

    You can probably see it looks like you could pass it several different variables. I'm getting it ready for the mod where we add the "address" field to the author, and we may for example only want to get the State (like you have in your homepage featured area). Soon I'll upgrade the function so that you can get the address of the author or the listing ad address, and then you can only get parts of the address, like the state, here is an example of what a future code might look like to call the "Author's" "State"

    Code:
    <?php echo cp_make_address_block ($post->ID, 'author', 'state') ?>
    Obviously I'm getting this code ready for use with our "author address auto-completing the fields in the submit ad page". This is just version 1 of this function. Let me know what you think and come back often for updates. I'll post new versions here.
    ~ Seth Carstens, Sethmatics Inc.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Regarding Your Twit Message - New CP Design or More Function
    By gariben in forum ClassiPress General Discussion
    Replies: 0
    Last Post: July 14th, 2009, 04:35 PM
  2. How to Activate Stats Function?
    By thewebsiteman in forum ClassiPress General Discussion
    Replies: 1
    Last Post: July 1st, 2009, 10:02 PM