1

Okay, so we have a section of our server portioned off to be a nested test site. However for whatever reason the below template causes an error in Joomla's php handler that it does not on the active site. What it posts when access is attempted on the test site is: Parse error: syntax error, unexpected 'var' (T_VAR) in /home/usaspo5/public_html/dev/usgnew/components/com_usg_progs/tmpls/default.php on line 4

<script id="template" type="text/html">
<% 
    var d = new Date();
    d.setHours(0,0,0,0);
    var setprorate = prorate;
    var prorate = 0;
    proDateTime = proDate+' '+proTime;
    var cDateMySQL  = new Date(Date.parse(proDateTime.replace('-','/','g')));
    if ( d > cDateMySQL) {
        prorate = 1;
    } 
    var btnOnClick = "location.href='https://usasportgroup.com/component/usg_programs/index.php?option=com_usg_programs&view=program&pid="+pid+"&site="+'<?=$_REQUEST['site']?>'+"'";
    var btnTxt = "More Info "+"|"+" Register".toUpperCase();
    var spacesClass = "available";
    var spacesTxt = "Available";
    if(spaces >= 10) 
    { 
        spacesTxt = "Available";
        spacesClass = "available"; 
    } 
    else if(spaces == 0)
    {
        spacesTxt = "Sold Out";
        spacesClass = "soldout";
        btnTxt = "More Info "+"|"+" Wait List".fontcolor("darkslategrey");          
    }
    else if(spaces <= 8 && spaces >= 1) 
    { 
        spacesTxt = "Spaces: "+spaces;
        spacesClass = "limited"; 
    }

    if(pStatus == 3)
    {
        spacesTxt = "Tentative";
        spacesClass = "tentative";
        btnTxt = "More Info "+"|"+" Notify Me".fontcolor("darkslategrey");          
    }       
    if(cat == ''){
        cat = "noimage";
    }
    if(typeof pAlert != 'undefined'){
        var programAlert;
        programAlert = pAlert.replace(/(\r\n|\n|\r)/gm,"");
    }
    if(product_refered =="Y"){
    var price ="Call";
    }
%>
    <div class="panel panel-programs">
        <div style="float:right">
        <% if(programAlert){ %>
            <button class="uk-button uk-button-danger" onclick="UIkit.modal.alert('<%=programAlert%>')">
            <span class="uk-icon-info"></span></button>
        <% } %> 
            <div class="badge badge-<%=spacesClass%>"><%=spacesTxt%></div>
            <button onclick="<%=btnOnClick%>" class="uk-button uk-button-success register"><%=btnTxt%></button>
        </div>


        <div style="float:left;width:80px">
        <img class="" src="components/com_usg_programs/assets/images/icons/<%=cat%>.png">
        <div style="clear:left;width:80px;font-size:11px;margin-left:4px"><%=sku%></div>
        </div>
        <span style="color:#262F3A"><%=program%><br>Ages: <%=ageFrom%>-<%=ageTo%></span> | <%=session_type%>
        <hr>

        <div class="uk-container" style="padding:0">
            <div class="uk-flex">
                <div class="uk-width-medium-4-10">
                    <i class="uk-icon-map-marker"></i> <%=city%>, <%=state%> <%=zip%>
                    <br />
                    <i class="uk-icon-dot-circle-o"></i> Distance: <%=distance%> Miles

                </div>
                <div class="uk-width-medium-4-10">
                    <span class="uk-icon-calendar"></span> <%=startDate%> - <%=endDate%>
                    <br />
                    <span class="uk-icon-clock-o"></span> <%=startTime%> - <%=endTime%>
                </div>

                <div class="uk-width-medium-2-10" style="font-size:90%;text-align:right">
                    <span>
                    <%  if(prorate == 1){ %>
                            <span>Program in session<br>Discounted fee</span>
                    <%  } else { %>

                        <span>Fee: $<%=price%></span>

                    <% } %>
                    </span>  

                <%  if((isGold == 0)||(product_refered=='Y')){ %>
                        <span data-uk-tooltip title="Not eligible <br />for Gold Club discount" class="uk-icon-star"></span>
                <%  } else { %>
                        <span data-uk-tooltip title="Gold Club members receive <br />10% discount on this <br />program"  style="color:gold" class="uk-icon-star"></span>
                <%  } %>        
                    <br />
                <%  if(isLatefee == 1){ %>
                        <span style="font-size:90%">After 15th May:</span> $<%=lateFee%> &nbsp;&nbsp;&nbsp;
                <%  } %>
                </div>
            </div>
        </div>                              
    </div>
</script>

2 Answers 2

1

I don't know this component com_usg_progs, but is there an addition script missing with handles a prorate? I think these lines

var setprorate = prorate;
var prorate = 0;

IMHO do not make sence, you should not re-declare same variable twice with this var prorate = 0.

You could insert the following to get rid off this problem:

if (typeof prorate !== 'undefined') {
    var setprorate = prorate;
    prorate = 0;
} else {
    var prorate = 0;
}
1
  • Yeah, the bulk of that is handled elsewhere. I'm just trying to figure out why on our test site it's not rendering while it still is on the live site.
    – user11029
    Jul 17, 2017 at 12:24
1

It turns out that our test site had asp tags turned on. This was not the case in the live site. It cause issues with our template because php was mistakenly assuming the ejs tags ie <% <%= and so on were php commands using asp designators. I guess that goes to show that you should always copy your php settings totally, lest the defaults kick in and foul things up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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