Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hey there,

So, full disclosure... I know hardly anything about javascript except how to activate it after copying and pasting found code. :cry:

On to my question... Im using leaflet.js cluster map in my website and I would like to be able to create multiple markers using repeatable regions though the admin. Right now, each marker is listed out, separated by a commas (example below). Is it possible to create multiple markers though couch? Unfortunately, I cant repeat the script call over and over.. seems like it has to stay within the tags.

Code: Select all
<script>
var markers = [
{
    "project":"<h7>test test</h7>",
    "citystate":"Raleigh, NC",
    "what":"Mixed-Use",
    "architect":"Mixed-Use",
    "url":"<a href='test' target='blank'>View Project</a>",
    "lat":35.7831950,
    "lng":-78.6453600
  }, 
  {
    "project":"<h7>test test</h7>",
    "citystate":"Raleigh, NC",
    "what":"Mixed-Use",
    "architect":"Mixed-Use",
    "url":"<a href='test' target='blank'>View Project</a>",
    "lat":35.7996630,
    "lng":-78.6455610
  }, 
];
</script>
Hey, you can use this concept :) http://docs.couchcms.com/concepts/repea ... gions.html
Define what's gonna be dynamic (lat, long, etc..) and use code sample from the docs to define repeatable region.
Then, you could use a sample snippet below (adding, of course, other expected fields).
Code: Select all
<script>
var markers = [
<cms:show_repeatable 'project_location' startcount='1'>
{
"lat": <cms:show lat />,
"lng":<cms:show lng />
}<cms:if k_count lt k_total_records >,</cms:if>
</cms:show_repeatable>
];
</script>

If you don't even want to have script in code if no markers are present, then we can change it a bit like this:
Code: Select all
<cms:show_repeatable 'project_location' startcount='1'>
<cms:if k_count = '1' >
<script>
var markers = [
</cms:if>
{
"lat": <cms:show lat />,
"lng":<cms:show lng />
}<cms:if k_count lt k_total_records >,
<cms:else />
];
</script>
</cms:if>
</cms:show_repeatable>



Unfortunately, I cant repeat the script call over and over.. seems like it has to stay within the tags.

Kindly explain it further, if it still matters.
Thanks for the quick reply.. ill give it a shot!!
Worked like a charm, thanks again!! :D
4 posts Page 1 of 1