0

I am utilizing a combination of Solspace 'Calendar', 'Playa', and 'Google Maps for ExpressionEngine'. I'm having a strange issue where the dates aren't showing up correctly in my infowindows on the Google Map, but they show up fine using the same code outside of the infowindow.

So, I have a 'Location' channel, and an 'Event' channel. The Event channel is associated with the Calendar module, and uses a Playa single relationship field to relate it to a Location.

I am adding markers to the map for every 'Location', and for each marker, I'm populating the infowindow with the Location details. this includes using the Playa:Parents method to show all of the events that are at that location.

I copied the code from the Solspace Calendar demo template for a single event to show the event date, because it had all the conditionals all worked out to deal with single day or multi-day events well.

My problem is that in the infowindow, it's only showing the 'From' date, and not the 'To' part of the date string. It shows it correctly when I output it outside of the map, though. Here is the code that is outputting the date information.

    {exp:calendar:events}
    <b>From:</b> {event_first_date format="%F %j, %Y at %g:%i%a"}
    {if event_never_ends}
        (never ends)
    {if:else}
        {if "{event_first_date format='%Y%m%d%g%i%a'}" != "{event_last_date format='%Y%m%d%g%i%a'}"} <b>to:</b>
            {if "{event_first_date format="%Y%m%d"}" != "{event_last_date format="%Y%m%d"}"}
                {event_last_date format="%l, %F %j, %Y at %g:%i%a"}
            {if:else}
                {event_last_date format="%g:%i%a"}
            {/if}
        {/if}
    {/if}
    <a href="{path=find-music/event/{url_title}}">{title}</a>
{/exp:calendar:events}

But this is how it outputs, in the infowindow, and outside of the map.

(crap, I don't have enough 'reputation' to post the image here, but it's here: http://paleosun.com/misc/stackexchange-map-calendar-question.jpg)

Notice, the section below the map has the "to" date. Same code is used to output it.

I have determined that something is going wrong with the quotes in the event date formatting tags. The {if "{event_first_date format='%Y%m%d%g%i%a'}" != "{event_last_date format='%Y%m%d%g%i%a'}"} part is never resolving to 'true' like it should. In fact, If I just try to output {event_first_date format='%Y%m%d%g%i%a'} in the infowindow part, nothing show up. However, if I use double quotes and output {event_first_date format="%Y%m%d%g%i%a"} it DOES work. The problem is, I cannot use that fix in the conditional, because double quotes are already being used around the output of that tag...

Any ideas why? Or what I can do as a work-around?

Here is all of my relevant template code:

{exp:gmap:init
    id="mainmap"
    class="gmap"
    style="height:600px;width:100%; border: 1px solid green;"
    center="United States"
    zoom="4"
}

<div id="location-container">
    {exp:channel:entries
        channel="location"
        disable="member_data|pagination|category_fields"
        limit="9999"
        }

        {if loc_show_on_map == 'yes'}

            {exp:gmap:marker
                id="mainmap"
                latitude="{loc_latitude}"
                longitude="{loc_longitude}"
                geocode="false"
                clustering="true"
                infobox="true"
                show_one_window="true"
                class="ui-infobox-dark ui-infobox"
                offsetY="-45"
                offsetX="15"
                icon="{categories limit='1'}{category_image}{/categories}"
                }

                <div style="width: 400px;" class="clearfix">
                    <h3><a href="{path=find-music/location/{url_title}}">{title}</a></h3>

                    <ul>
                        {categories}
                            <li>{category_name}</li>
                        {/categories}
                    </ul>

                    {if loc_image}<img src="{loc_image}" alt="{title} image" width="200" class="right" />{/if}
                    {loc_contact_first_name} {loc_contact_last_name}<br />
                    {loc_street_address} {if loc_address_details}{loc_address_details}{/if}<br />
                    {loc_city_town}, {loc_state} {loc_zip_code}<br />


                    <ul>
                    {exp:playa:parents channel="calendar_events"}
                        <li>
                            {exp:calendar:events}
                                <b>From:</b> {event_first_date format="%F %j, %Y at %g:%i%a"}

                        <br />From:{event_first_date format='%Y%m%d%g%i%a'}
                        <br />To: {event_last_date format='%Y%m%d%g%i%a'}!
                        Yes
                                {if event_never_ends}
                                    (never ends)
                                {if:else}
                                    {if "{event_first_date format='%Y%m%d%g%i%a'}" != "{event_last_date format='%Y%m%d%g%i%a'}"} <b>to:</b>
                                        {if "{event_first_date format="%Y%m%d"}" != "{event_last_date format="%Y%m%d"}"}
                                            {event_last_date format="%l, %F %j, %Y at %g:%i%a"}
                                        {if:else}
                                            {event_last_date format="%g:%i%a"}
                                        {/if}
                                    {/if}
                                {/if}
                                <a href="{path=find-music/event/{url_title}}">{title}</a>
                            {/exp:calendar:events}
                        </li>
                    {/exp:playa:parents}
                    </ul>
                </div>

            {/exp:gmap:marker}

            {!--
                custom javascript to add attributes to the markers
                for location type and music styles, so we can filter
                based on that
            --}
            <script type="text/javascript">
                if(typeof newMarker!='undefined'){
                    newMarker.entry_id = {entry_id};
                    newMarker.music_styles = [];
                    {exp:playa:children field="loc_music_styles"}
                        newMarker.music_styles.push({entry_id});
                    {/exp:playa:children}

                    newMarker.location_types = [];
                    {categories}
                        newMarker.location_types.push({category_id});
                    {/categories}
                }
            </script>
        {/if}

        <div id="location-{entry_id}"  class="location-entry clearfix">
            <h3><a href="{path=find-music/location/{url_title}}">{title}</a></h3>
            {if loc_image}<img src="{loc_image}" alt="{title} image" width="200" class="right" />{/if}
            {loc_contact_first_name} {loc_contact_last_name}<br />
            {loc_street_address} {if loc_address_details}{loc_address_details}{/if}<br />
            {loc_city_town}, {loc_state} {loc_zip_code}<br />

            <ul>
            {exp:playa:parents channel="calendar_events"}
                <li>
                    {exp:calendar:events}
                        <b>From:</b> {event_first_date format="%F %j, %Y at %g:%i%a"}
                        {if event_never_ends}
                            (never ends)
                        {if:else}
                            {if "{event_first_date format='%Y%m%d%g%i%a'}" != "{event_last_date format='%Y%m%d%g%i%a'}"} <b>to:</b>
                                {if "{event_first_date format="%Y%m%d"}" != "{event_last_date format="%Y%m%d"}"}
                                    {event_last_date format="%l, %F %j, %Y at %g:%i%a"}
                                {if:else}
                                    {event_last_date format="%g:%i%a"}
                                {/if}
                            {/if}
                        {/if}
                        <a href="{path=find-music/event/{url_title}}">{title}</a>
                    {/exp:calendar:events}
                </li>
            {/exp:playa:parents}
            </ul>
            <hr />
        </div>
    {/exp:channel:entries}
</div> <!-- /#location-container -->
1

I am not sure of a workaround, but that is definitely a parse order issue. Given this is a very unique scenario, it would be rather difficult to duplicate without getting access to your EE install.

Email support@objectivehtml.com and I can try to help you find a workaround. I am not sure who this support requests belongs to, me (Objective HTML), P&T, or Solspace but I can try to help you. :)

| improve this answer | |
  • Justin, I think I can help PaleoSun, but I don't understand enough about your addon. Please, may I put the content of gmap:marker inside an embed? – Robson Sobral Jul 24 '13 at 16:35
0

I never used GoogleMpas for EECMS, but let's try something.

I already had some problems to solve because of nested exp:channel:entries and exp:channel:events.

So, let's first move them to an embed, but trying to reduce the number of times the modules are parsed and improve the performance.

{embed="events/.mapmarkers" event_ids="{exp:playa:parents channel='calendar_events' backspace='1'}{entry_id}|{/exp:playa:parents}"}

The default format of the variables of exp:channel:events is already YYYYMMDD. So you don't need to format some of your conditionals.

{if "{event_first_date}" != "{event_last_date}"}

Other conditionals, can have the double and single quotation marks replaced and the '%a' can be removed if you use '%H'.

{if '{event_first_date format="%Y%m%d%H%i"}' != '{event_last_date format="%Y%m%d%H%i"}' }

Your embed will look like this:

{if embed:event_ids !== ""}
    <ul>
    {exp:calendar:events parse="inward" event_id="{embed:event_ids}"}
        <li>
        <b>From:</b> {event_first_date format="%F %j, %Y at %g:%i%a"}

        <br />From:{event_first_date format='%Y%m%d%g%i%a'}
        <br />To: {event_last_date format='%Y%m%d%g%i%a'}!
        Yes
            {if event_never_ends}
                (never ends)
            {if:else}
                {if '{event_first_date format="%Y%m%d%H%i"}' != '{event_last_date format="%Y%m%d%H%i"}' } <b>to:</b>
                    {if "{event_first_date}" != "{event_last_date}"}
                        {event_last_date format="%l, %F %j, %Y at %g:%i%a"}
                    {if:else}
                        {event_last_date format="%g:%i%a"}
                    {/if}
                {/if}
            {/if}
            <a href="{path=find-music/event/{url_title}}">{title}</a>
        </li>
    {/exp:calendar:events}
    </ul>
{/if}

Because you're calling this twice on your template, I strongly suggest you to use stash to save the content of the embed.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.