ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Help with number sequence

June 24, 2012 2:05pm

Subscribe [2]
  • #1 / Jun 24, 2012 2:05pm

    Can anyone help me find a solution here? I’m trying to generate a sequential list of entries grouped by category.

    I’m using this code to generate a marker array:

    {exp:channel:category_archive channel="membership_directory" style="linear" show_empty="no"}
      {categories}
          {exp:channel:entries channel="membership_directory" category="{category_id}”}
                  markers[{count}] = SetMarker({count}, {entry_id}, {latitude}, {longitude}, ‘{title}’, ‘cat{category_id}’, ‘blank’); 
          {/exp:channel:entries}
      {/categories}
    {/exp:channel:category_archive}

    As you can see from the results here, I can get the array working fine, with the exception of the number sequence. The count starts over as each new category begins. Since I can’t have more than one marker with the same SetMarker number, I need the sequence to continue, regardless of when the next category begins.

    Is there a better way to structure this, or an alternate counting method I can use?

    Thanks,
    Porter.

  • #2 / Jun 27, 2012 12:49pm

    aelvan

    33 posts

    I don’t think there’s a simple solution to this within EE. Unless you can use the entry_id as the marker id?

    markers.push(SetMarker({entry_id}, {entry_id}, {latitude}, {longitude}, ‘{title}’, ‘cat{category_id}’, ‘blank’));

    But I think it can be solved easily by rethinking the javascript. I’d instead build a markers_data array in the EE loop, and then generate the markers array by iterating over the first array. Something like this:

    var markers_data = [];
    {exp:channel:category_archive channel=“membership_directory” style=“linear” show_empty=“no”}
      {categories}
          {exp:channel:entries channel=“membership_directory” category=”{category_id}”}
                  markers_data.push([ {entry_id}, {latitude}, {longitude}, ‘{title}’, ‘cat{category_id}’, ‘blank’ ]);
          {/exp:channel:entries}
      {/categories}
    {/exp:channel:category_archive}
    
    var markers = []
    for (var i=0; i<markers_data.length; i++) {
       markers<i> = SetMarker(i, markers_data[0], markers_data[1], markers_data[2], markers_data[3], markers_data[4], markers_data[5])
    }

    I’d of course use an object in the push(), but you get the idea.. 😊

     

  • #3 / Jun 27, 2012 1:12pm

    No, entry id’s are not an option. Wish they were.

    But I see where your javascript solution is going. Let me give it a whirl.

    Thanks aelvan!
    Porter.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases