Store Locator Plus® for WordPress Forums Premier Support Conditionally Show Content on results page

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #45379
    Chris
    Participant

    I see a few forum posts about this already, but all of them are 3-4 years old, so I am hoping there is an update.

    Is it possible to conditionally show content in the results area if a field is filled in? For example, something like this:

    [slp_location ifset address2]
    Show this content if the address2 field is filled out.
    [/slp_location]

     

    There is some discussion about the ifset element here, but the syntax isn’t clear and it is not clear what you can conditionally show. Could you clarify the syntax and what fields specifically you are able to conditionally show/hide?

    #45380
    Cici
    Keymaster

    The Experience add-on allows you to change the layouts and add css

    https://docs.storelocatorplus.com/

    #45381
    Chris
    Participant

    I have the experience add on and am already changing the layouts and applying CSS. I am curious about conditionally showing content within the layout area. Please see my original post. For example, I’d like to show a phone icon next to the phone number field. I don’t want the icon to display if the store doesn’t have a phone number included. I need a way to hide the icon if the phone number field is empty. Does that make sense and is it possible?

    #45396
    Cici
    Keymaster

    yes, but I am questioning where are you pulling in the image or icon from, is it an html path?

    Since I am not sure what versions or what your plugin environment is I can only refer you to some info. The developer can look into your specific question but he will request your Plugin environment (see posting guidelines)

    What you are describing would pull from your own database or an icon set I assume that you want to link in.

    You can Refer to some detailed info (this is old documentation site so you may not recognize some of the references)
    https://wp.storelocatorplus.com/documentation/store-locator-plus/user-experience/results/results-layout/

    For instance for your conditional formatting

    ifset=”

    Will only output the specified option if the noted field contains a value.
    Example:
    [slp_location web_link wrap website]
    [slp_option label_website ifset web_link]
    [ html closing_anchor ifset web_link ]

    #45421
    Chris
    Participant

    Maybe I am implementing it in correctly, but when I add those three shortcodes to my results layout, it outputs the code inside of them regardless of if the web_link is set for the post or not. The label conditionally shows, but I was hoping to show/hide information not in a shortcode conditionally. Having gone through all of the documentation, it sounds like that isn’t possible.

    #45423
    Cici
    Keymaster

    I will ask Lance to take a look and explain. I think you are right, because the shortcodes and the element field names are based on what is in your location manager. But he might be able to give you a better answer, he is the developer.

    #45434
    Lance Cleveland
    Keymaster

    Chris – CiCi forwarded this post to me.

    There are a couple of “hackish” ways to do this , but I’m playing with some other more elegant methods and think a better way to deal with this sort of thing is needed for future releases.  Maybe I’ll add something as a new feature in the Premier Plugin for active subscribers.

    I’ll shoot a video and add a post after I play with this a bit more, but this may get you started.    I also updated the Results Layout documentation which may help you:
    https://docs.storelocatorplus.com/blog/results-layout-shortcodes-and-attributes/

    Hackish Way #1 – Per Location Marking

    – Use Extended Data Manager to add a new “phone icon” field.
    – For each location you’ll need to set that new field to the URL to your phone icon.
    – Results layout to show the icon when phone is present…
    [slp_location data.web_icon wrap=img ifset phone]
    <span class=”slp_result_address slp_result_phone”>[slp_location phone]</span>

    I do NOT like this option as you are having to add and store data for every location for a single recurring HTML element (the image URL).    Yuck.Hackish Way #2 – Commandeer An OptionHere you only have a single consistent entry for the phone icon image URL.   Problem is you are storing it in an SLP setting that you (hopefully) will never need.     For example, most people never use popup email forms.    I take over the Experience Add On’s Popup Email Title option and put my phone icon URL in there.I like this better as you have one less plugin (EDM) loading and taking up overhead and memory.  You also store a lot less data making location request payloads smaller.  You also don’t have to enter 3,973 image URLs if you have 3,973 locations.  I don’t like this because… well, it’s just wrong.  What if you need ALL of your options?  What if the way the Popup Email Title is processed or stored ever changes (it hasn’t in 3 years but you never know).   This is probably the safest option to get your layout online ASAP without waiting for some new SLP patches/features.[slp_option  popup_email_title wrap=img ifset phone]
    <span class=”slp_result_address slp_result_phone”>[slp_location phone]</span>
    There are other interesting ways to do this if you decide to hijack an option including using a CLASS NAME instead of putting the full URL in that popup email title setting.   For example, just put the word “phone_icon” in there instead and use that as part of the class for the span.    Assuming you know some basic CSS you can then set a CSS rule for span.slp_result_phone.phone_icon that renders the icon via CSS and the rule span.slp_result_phone (without the .phone_icon) does NOT render the icon.

    <span class=”slp_result_address slp_result_phone [slp_option  popup_email_title ifset phone]”>[slp_location phone]</span>Notice I dropped wrap=img from the shortcode in this case.So … some “hackish” ways to get there.    I’m thinking about other options but I don’t have a “clean and right” way to do this.  yet.

     

    #45442
    Chris
    Participant

    Thanks for the reply Lance. Unfortunately those solutions don’t sound too appealing. I think we may avoid it for now until you have something more integrated built in as a solution.

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Conditionally Show Content on results page’ is closed to new replies.