Support has been upgraded!
The Support Forum is closed. Not to worry! Providing the top quality support you expect and we're known for will continue! We're not ending support, just changing where you submit requests. This will provide you with the best experience possible.
Premium Support
Have you purchased an addon for Connections such as one of our premium templates or extensions with a valid license and you need help?
Please open a Support Ticket in your user account.
Free Support
Are you using the free Connections plugin? Don't worry, you are still very important to us! We are still providing you with the same high quality support that we're known for.
Please open a new support topic in the WordPress support forums for Connections.
Tagged: 0.7.9.3, category, fields, getAddressBlock, getCategoryBlock(), slim plus
- This topic has 15 replies, 5 voices, and was last updated 8 years, 4 months ago by
Steven Zahm.
-
AuthorPosts
-
02/11/2014 at 2:34 pm #279839
Eric Bobrow
ParticipantHi Steven –
My client wants to display some additional info in the simple Slim Plus listing, showing something like:
John Hamel, LCSW
Provider, San Francisco, USAThen when the simple list item is clicked, it would open up to show the entire entry.
I was able to follow the instructions for editing the card.php file using this forum topic:
http://connections-pro.com/support/topic/adding-title-to-main-address-list/This allowed me to add the Title to the card, so I understand and can work with the PHP file without a problem.
Please let me know what modifications to the code will give me the City and Country information. I imagine this will be simple, just requiring knowledge of the field names.
For the word “Provider” in the example above, this is one of the two main Category choices for this database of professionals involved in social services. People are either “providers” or “researchers”, and their entry will have one or the other category checked.
So for this particular task, I’ll need to use some conditional code to test whether an entry has the Provider category checked, and if so, put in the text “Provider”; if it has Researcher checked, then I would put in “Researcher”.
I would very much appreciate your help with this coding. I don’t know what field value to look at with regards to specific categories (how to look up the category string) nor how to code the actual test in PHP (e.g. the PHP code version of the following statement: “if category includes Provider, then echo “Provider” else if category includes Researcher then echo “Researcher” endif).
Thanks in advance for your help. I appreciate that this takes time to provide this support. I will spread the word about Connections to everyone I know (and I know a lot of people involved in web development) since your tools are well-crafted and your support is awesome!
Eric
02/11/2014 at 8:49 pm #279854Steven Zahm
Keymaster@ Eric
Hmmmm, This is a bit more difficult…
I’ll start with the address. To output the city and country use this:
$entry->getAddressBlock( array( 'format' => '%city%, %country%' ) );
The category, may this will work:
$entry->getCategoryBlock( array( 'label' => '','separator' => '', 'before' => '<span>', 'after' => '</span>' ) );
This does assume the entry is no assigned to any other categories other than the one you want displayed. So there is no if/else logic needed.
Hope that helps.
-
This reply was modified 9 years, 10 months ago by
Steven Zahm.
02/11/2014 at 9:46 pm #279858Eric Bobrow
ParticipantSteven –
That worked great!
Initially all the info was broken up into separate lines, but I used CSS to get all my info displayed inline rather than block.
There’s are two remaining problems, which you’ll see if you visit the site:
http://www.battererintervention.org/membership/To explain:
1) All entries use a category to specify their world region (e.g. North America, Europe, Australia, etc.) in addition to the categories mentioned above of Researcher and/or Provider. This category info will allow searching for people in Europe, for example, rather than only being able to search by country.
Is there a way I can eliminate listing the region categories in the slim listing, while still showing the Researcher / Provider info?
2) Some people may have more than one location specified.
Is there a way to only show one location?
To show you why this matters, here is what we’re seeing for one of the listings that has two locations; it also illustrates the unnecessary listing of the world region category:
John Hamel LCSW San Rafael, USA Walnut Creek, USA North America, Provider
You can see that it’s showing San Rafael as well as Walnut Creek (two cities) plus it says North America in addition to the USA country info.
I can live with showing the two locations, perhaps, but would really prefer not to display the North America or Europe category info since in this context we are showing the country.
Thanks again for your help!!
Eric
02/12/2014 at 8:23 am #279899Steven Zahm
Keymaster@ Eric
To Pull a specifc category out of the group, somthing like this should do the trick:
foreach ( $entry->getCategory() as $category ) { if ( $category->name == 'Provider' || $category->name == 'Researcher' ) $profession = $category->name; }
Now you can use
$profession
instead of thegetCategoryBlock()
function.Probably the best way to limit the location is to use the
Preferred
option when entering the addresses. The with a minor tweak to thegetAddressBlock()
function arguments you can limit the result to just thePreferred
address.$entry->getAddressBlock( array( 'format' => '%city%, %country%', 'preferred' => true ) );
If you have a moment, I would truly appreciate a review as they really do make a difference. Many thanks in advance!
http://wordpress.org/support/view/plugin-reviews/connections02/12/2014 at 11:34 am #279911Eric Bobrow
ParticipantHi Steven –
This is awesome, thanks!
Two follow-up questions:
1) It turns out that some people are both Provider and Researcher. How would the code need to be changed to list them both with a comma in between:
John Hamel LCSW (San Rafael, USA) Provider, Researcher
[I have already figured out how to put in the parentheses around the address for clarity, by replacing the empty quotes ‘ ‘ separator with the appropriate separators ‘ (‘ or ‘) ‘.]
2) If someone puts in one or more addresses but DOESN’T check the Preferred box, your tweaked function call looks like it would not show any address. Is there a way to still show an address (it could be the first or the last one)?
I will post a glowing review later today, for sure!
Eric
-
This reply was modified 9 years, 10 months ago by
Eric Bobrow. Reason: clarity
02/13/2014 at 10:31 am #279985Steven Zahm
Keymaster@ Eric
Of the top of my head, I think this would work to show both:
foreach ( $entry->getCategory() as $category ) { if ( $category->name == 'Provider' || $category->name == 'Researcher' ) $profession[] = $category->name; }
Then to show them:
implode( ', ', $profession )
The code to only display a single address, let say just the first would be a bit more complex…
This would replace the getAddressBlock()
$address = $entry->getAddresses(); if ( isset( $address[0] ) ) { echo '( '; if ( ! empty( $address[0]->city ) ) echo $address[0]->city; if ( ! empty( $address[0]->country ) ) echo ', ' , $address[0]->country; echo ' )'; }
This is off the top of my head … I think it’ll work.
02/13/2014 at 1:52 pm #279996Eric Bobrow
ParticipantSteven –
You are totally awesome – both of these changes worked like a charm.
I just posted an enthusiastic review for you.
I would give you more than 5 stars if I could!
Eric02/14/2014 at 9:20 pm #280092Steven Zahm
Keymaster@ Eric
Great to hear! Many thanks for your review!
10/15/2014 at 10:22 am #307105Dave Tillotson
ParticipantHi Steven,
Along similar lines, I’m hoping to add either photo or logo to the listings. I’m able to add categories and phone numbers by adding appropriate code to card.php but no luck doing same for logo or image. Any help greatly appreciated.
Thanks,
Dave
10/15/2014 at 11:09 am #307112Steven Zahm
Keymaster@ Dave
re: I’m hoping to add either photo or logo to the listings.
Ok, I am a little confused, the Slim Plus template already shows the the photo, by default, so there is nothing to change or add. -
This reply was modified 9 years, 10 months ago by
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.