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.

EE tags not working inside javascript SOLVED

May 10, 2012 1:38pm

Subscribe [2]
  • #1 / May 10, 2012 1:38pm

    Eastwood Design

    605 posts

    Why can’t I use weblog tags inside my javascript code?

    My if conditions does not work.

    I have a custom field {longitude}, but if I try and use {if longitude} my browser displays {if ""} in the source code.

    Strangely {keynumber} and {title} seem to be working fine.

    [removed]
       function initialize() {
        var latlng = new google.maps.LatLng(44.64401131517608, -63.57693672180176);
        var settings = {
         zoom: 15,
         center: latlng,
         mapTypeControl: true,
         mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
         navigationControl: true,
         navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
         mapTypeId: google.maps.MapTypeId.ROADMAP};
        var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
        
       
        
    {exp:weblog:entries weblog="artists" category="19" orderby="keynumber" sort="asc" limit="99" } 
    {if longitude}
     
        var contentString55 = '<div id="content">'+
         '<div id="siteNotice">'+
         '</div>'+
         '<h1 id="firstHeading" class="firstHeading">{title}</h1>'+
         '<div id="bodyContent">'+
         'Test <br>View Details '+
         '</div>'+
         '</div>';
        var infowindow55 = new google.maps.InfoWindow({
         content: contentString{keynumber}
        });
        
        var companyImage = new google.maps.MarkerImage('/images/{keynumber}.png',
        new google.maps.Size(50,50),
         new google.maps.Point(0,0),
         new google.maps.Point(50,50)
        );
    
        var companyShadow = new google.maps.MarkerImage('images/02peninsula_shadow.png',
         new google.maps.Size(70,50),
         new google.maps.Point(0,0),
         new google.maps.Point(60, 50));
    
        var companyPos = new google.maps.LatLng({latitude}, {longitude});
    
        var companyMarker{keynumber} = new google.maps.Marker({
         position: companyPos,
         map: map,
         icon: companyImage,
         shadow: companyShadow,
         title:"{title}",
         zIndex: 3});
        
      
         //Companyu Marker Pop Up bubble
        google.maps.event.addListener(companyMarker{keynumber}, 'click', function() {
         infowindow{keynumber}.open(map,companyMarker{keynumber});
        });
    
    {/if}
    {/exp:weblog:entries}
     
       
        
        
       }
      [removed]
  • #2 / May 10, 2012 2:01pm

    Eastwood Design

    605 posts

    solved:

    $conf[‘protect_javascript’] = ‘n’;

  • #3 / May 11, 2012 11:02am

    Shane Eckert

    7174 posts

    Hi Eastwood Design,

    That’s awesome. Glad you got this figured.

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases