1

I'm displaying a list of facilities by state in a sidebar using the category_archive tags(template code below)...

  • Iowa

    • facility
    • facility
    • facility
  • Missouri

    • facility
    • facility
    • facility

if I add a {count}, it resets for each group of facilities (1-3, then 1-3 again). I have map pointers for each location on a google map added with the Google Maps plugin. I'm trying to do some stuff with Javascript that needs to be able to relate the facility in the list with the corresponding map point. The Google Maps plugin puts each facility pointer in an array by the index number, but the numbers go in order, so I can't relate them to the facilities listed in the sidebar, because I can't figure out how to get a running count of all locations listed. Any ideas? and please let me know if I need to clarify something...

  • 2
    Would it work to relate your list to your map with the category ID rather than with the list ordinal? – AllInOne May 12 '14 at 16:54
0

I had this exact same issue once before as well, I think the tag you are looking for is

{absolute_count}
| improve this answer | |
  • looks like this still resets the count for every category. The guy I use for JS work managed to work something out to solve my issue, although I'm sure someone else might want an #eecms based answer for this in the future. – Mike Lohrman May 14 '14 at 18:30
  • Mike, if you could post your answer with the "Answer your own question" button below, and mark that as the answer it will help the site out tonnes! thanks :) – Blatant Jun 9 '15 at 14:36
0

Do you need your running count in javascript or PHP?

If you wanted to just be able to map the facility to the google map marker you could do something like this inJavascript (I'm assuming you want to link an anchor to a marker pointer in the JS array) :

<!-- Before we start, initialise a counter & relationship array in JS -->
<script type="text/javascript">
    var c = 0;
    var facility2Marker = new Array();
</script>

<!-- print out the menu and apply markers -->
{exp:channel:categories}
    {category_name}
    {exp:channel:entries channel="{catagory_url_title}"}
        <a class="showMarker" href="#" data-facility="{url_title}">{title}</a>
        <script type="text/javascript">

            //add linkage
            facility2Marker["{url_title}"] = c;

            //Code Here to add Maps Marker
            new google.maps.Marker({
                position: myLatlng,
                map: map,
                title: '{title}'
            });

            //move the counter on
            c++;

        </script>
    {/exp:channel:entries}
{/exp:channel:categories}

<!-- set up the click event -->
<script type="text/javascript">
    //assuming your using JQuery here
    $('.showMarker').click(e){
        e.preventDefault();
        //get the index from the linkage
        var MarkerIndex = facility2Marker[$(this_.data("facility")];
        //do something with the marker
        markerArray[MarkerIndex].DoSummin();
    }
</script>

Please do note, I just typed this into the editor, so it's not Copy Paste of working code! E & OE, Please excuse syntax or spelling mistakes, it''s just to give you the idea...

| improve this answer | |
0

Mike,

We ran into a very similar problem and ended up utilizing the "PVL Increment" plugin: https://github.com/pvledoux/Pvl_increment

It allows you to create custom variables that are then incremented at a point you determine. We declared our variables in the main template page and incremented them inside embeds used to display product information.

Glad you found a solution, but for people that might not have the same resources available as you do, this might be a viable solution.

| 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.