Community Forums › Forums › Archived Forums › General Discussion › Agentpress – don't display empty property detail fields
Tagged: Agentpress
- This topic has 14 replies, 3 voices, and was last updated 10 years ago by
khcreativemedia.
-
AuthorPosts
-
February 23, 2015 at 9:34 pm #141974
khcreativemedia
MemberI want to have the property listing page not display the property detail (such as City) if that field is left blank in the admin. Can anyone give me a suggestion on how to do this?
Thank you,
http://rese.khcreativemedia.com/?listing=triangle-plaza-shopping-center
KeithFebruary 24, 2015 at 4:10 pm #142081Brad Dalton
ParticipantHello Keith
You would need to modify the code so the markup and text doesn't print when empty.
This would require modification of the PHP code.
I assume you're referring to the archive-listing.php page rather than the single listing page or are i mistaken?
Either way, the answer will be pretty much the same.
February 24, 2015 at 8:24 pm #142129khcreativemedia
MemberThanks Brad,
Right, the PHP needs to be modified. The problem is I don't know PHP enough to figure it out. I've spend a couple hours trying to learn but haven't succeeded yet. Can anyone offer any coding assistance?
Thanks,
KeithFebruary 24, 2015 at 8:25 pm #142130Brad Dalton
ParticipantYou would need to hire a Genesis Developer as its requires the modification of the AgentPress Listings plugin or creation of a custom single-listings.php template
February 24, 2015 at 8:27 pm #142131khcreativemedia
MemberIt's for a single page. Here is an example page: http://rese.khcreativemedia.com/?listing=arab-town-plaza
Would like to not show "Retail Sales" and "Traffic Counts".
Thanks.
February 24, 2015 at 8:41 pm #142133Brad Dalton
ParticipantYou might get away with hiding those 2 fields using CSS.
Inspect each element to find the class and use display: none
But that would also hide any that are populated.
February 24, 2015 at 8:47 pm #142134khcreativemedia
MemberYes, I need to avoid using css as this will vary between listings.
Keith
February 24, 2015 at 9:07 pm #142139Brad Dalton
ParticipantLooks like you have also filtered the property details.
Can you provide the code you used to do that please.
February 24, 2015 at 9:09 pm #142140khcreativemedia
MemberSure. I have the following in the functions file:
//* Filter the property details array add_filter( 'agentpress_property_details', 'agentpress_property_details_filter' ); function agentpress_property_details_filter( $details ) { $details['col1'] = array( __( 'Population:', 'agentpress-listings' ) => '_listing_population', __( 'Average Household Income:', 'agentpress-listings' ) => '_listing_average_household_income', __( 'City:', 'agentpress-listings' ) => '_listing_city', __( 'State:', 'agentpress-listings' ) => '_listing_state', __( 'ZIP:', 'agentpress-listings' ) => '_listing_zip', __( 'Growth Rate:', 'agentpress-listings' ) => '_listing_growth_rate', __( 'Retail Sales:', 'agentpress-listings' ) => '_listing_retail_sales', __( 'Traffic Counts:', 'agentpress-listings' ) => '_listing_traffic_counts', __( 'Space Available:', 'agentpress-listings' ) => '_listing_space_available' ); return $details; }
February 25, 2015 at 3:11 am #142167coralseait
MemberBasically mod that function so that it checks for isset or isempty and build your output array based on that. I don't have access to an agent press install right now to test for you and I have to run, but you'll want to check each value and if isset() add the member to your $details array using something like array_push() or array_merge()
I can expand on your function if you need more help later.
February 25, 2015 at 7:37 am #142197khcreativemedia
MemberThanks coralseait. Sounds exactly like what I was thinking, but I don't know how to write it in code. If you have time to help explain it with my code, I would greatly appreciate it. Sorry, learning curve.
Keith
February 25, 2015 at 5:05 pm #142289Brad Dalton
ParticipantI would use something like this:
if ( isset( $_listing_growth_rate['_listing_growth_rate'] ) && ! empty( $_listing_growth_rate['_listing_growth_rate'] ) ) {
February 25, 2015 at 6:02 pm #142293khcreativemedia
MemberSo I would add each of the options (like _listing_growth_rate) to this and then where exactly would this code go in the code I displayed in the post above. Again, such a newbie, sorry.
February 25, 2015 at 6:05 pm #142295Brad Dalton
ParticipantThat's all i've worked out so far.
More time would need to be spent writing and testing the code.
March 29, 2015 at 6:04 pm #146038khcreativemedia
MemberCircling back to this, as I have yet to figure out how to do it. Project is wrapping up now and this is one of the last items on my "To-Do" list.
If anyone could lend a hand, I would greatly appreciate it. Brad was a great help, but I'm not sure where to put his code or how to finish it.
Thanks,
Keith -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.