Maginot/viewnews.cgi different output w/ same style (SOLVED)

All new Coranto Addons, updates and patches to addons, will be released here...also, get support for addons within!

Moderators: Spunkmeyer, Dale Ray, SrNupsen, Bluetooth, Jackanape

Maginot/viewnews.cgi different output w/ same style (SOLVED)

Postby Dale Ray » Tue May 06, 2008 2:17 pm

EDIT: Removed links to example pages as they are no longer available and added an explanation of the problem instead.

Problem: Viewing a news item about softball game results with viewnews.cgi displayed the line score (that is a table with a row for each team and the runs scored in each inning by that team in a cell, total runs, hits and errors are displayed at the end of the row), but a Maginot static profile did not display the line score.

I was wondering why the line score is displaying in the viewnews.cgi output and not displaying in the Maginot output. See the next post for my solution.

I am using Maginot to create static pages for each game so that I can delete last year's schedule and enter next year's schedule.

I use the following style for both:
Code: Select all
<PerlCode>
# initialize variables
$thisOpp = "";
$titleTag = "";
#if Opponent is not determined yet use the subject or the schedule note instead
if ($CustomField_opponent ne "TBA" && $CustomField_opponent ne ""){
$thisOpp = $CustomField_opponent;
} elsif ($CustomField_opponent eq "TBA" && $Subject eq "" && $CustomField_schedNote eq "") {
$thisOpp = "To be announced";
} elsif ($Subject ne "") {
$thisOpp = $Subject;
} elsif ($CustomField_schedNote ne "") {
$thisOpp = $CustomField_schedNote;
}
# add appropriate text for home/away games if needed
if ($CustomField_site eq "Away") {
$titleTag = "CCSJ at ".$thisOpp." on ".$Month_Name." ".$Day.", ".$Year;
} elsif  ($CustomField_site eq "Home" || $CustomField_site eq "Neutral") {
$titleTag = "CCSJ vs ".$thisOpp." on ".$Month_Name." ".$Day.", ".$Year;
} else {
$titleTag = $thisOpp;
}
# process the score by innings entry
if ($CustomField_oppRunsByInning ne "" && $CustomField_ourRunsByInning ne "") {
    # split the score by innings entries into indexed arrays
    @oppScoreByInning = split(";",$CustomField_oppRunsByInning);
    @ourScoreByInning = split(";",$CustomField_ourRunsByInning);

    # process the opp array
    $n = 0;
    $oppRow = "";
    while (defined($oppScoreByInning[$n])) {
      #get the opp total runs for the game
       $oppRuns = $oppRuns + $oppScoreByInning[$n];
      #build the opp line for the score by inning box
       $oppRow = "$oppRow"."<td class=\"scores\">".$oppScoreByInning[$n]."</td>";
       $n++;      
    }
$oppRow = "<tr class=\"scores\"><td class=\"team-name\"><strong>".$CustomField_opponent."</strong></td>".$oppRow."<td class=\"scores\">$oppRuns</td><td class=\"scores\">$CustomField_oppHits</td><td class=\"scores\">$CustomField_oppErrors</td></tr>";


    # process our array
    $n = 0;
    $ourRow = "";
    $headerRow = "<tr class=\"scores\"><th class=\"scores\"></th>";
    while (defined($ourScoreByInning[$n])) {
       $ourRuns = $ourRuns + $ourScoreByInning[$n];
       $ourRow = $ourRow."<td class=\"scores\">".$ourScoreByInning[$n]."</td>";
       $n++;
        $headerRow = $headerRow."<th class=\"scores\">$n</th>";
    }
$ourRow = "<tr class=\"scores\"><td class=\"team-name\"><strong>CCSJ</strong></td>".$ourRow."<td class=\"scores\">$ourRuns</td><td class=\"scores\">$CustomField_ourHits</td><td class=\"scores\">$CustomField_ourErrors</td></tr>";
    $innings = $n;
$headerRow = $headerRow."<th class=\"scores\">R</th><th class=\"scores\">H</th><th class=\"scores\">E</th></tr>";

    # put the score table into correct order for home/away games

    if (($CustomField_site eq "Away" && $CustomField_homeTeam
== 0) || ($CustomField_site eq "Neutral" && $CustomField_homeTeam
== 0)) {
    $scoreTable = $headerRow."\n".$ourRow."\n".$oppRow;
    } else {
    $scoreTable = $headerRow."\n".$oppRow."\n".$ourRow;
    }
}

# compare the runs by inning totals to the total entered on the input page
# to prevent mistakes
if ( ($CustomField_ourScore ne "" && $ourRuns == $CustomField_ourScore) && ($CustomField_oppScore ne "" && $oppRuns == $CustomField_oppScore) ) {
   $showLineScore = 1;
   } else {
   $showLineScore = 0;
}
</PerlCode>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>CCSJ Softball Game Details</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../_style/style.css">
</head>
<body>
<!-- body table -->
<table width="85%" align="center">
<tr>
<td class="padding">
    <table width="100%" class="box_border">
        <tr>
            <td class="soft_header center">
            <img src="../_pics/logo.gif" width="97" height="61" alt="">
            </td>
            <td class="box_header">
            <img src="../_pics/logo_4.gif" width="629" height="101" alt="">
            </td>
        </tr>
    <tr>
        <td class="soft_header center" colspan="2">
        <h5><Field: titleTag></h5>
        </td>
        </tr>
        <tr>
        <td colspan="2" class="detail">
<p><Field: Date><If: Field: CustomField_timeOptions eq "Normal"> at <Field: Hour>:<Field: Minute><If: Field: AMPM eq "PM"> p.m.<If: Else> a.m.</If><If: Field: CustomField_tz ne "CST"> <Field: CustomField_tz></If></If><br>
<If: Field: CustomField_playingField><p>Played at <Field: CustomField_playingField><br></if>
<If: Field: CustomField_schedNote><Field: CustomField_schedNote><br></If>
<If: Field: CustomField_blurb><Field: CustomField_blurb><br></If></p>
<If: Field: showLineScore><table class="scores">
<Field: scoreTable>
</table></If>

<p><Field: Text></p>

<If: Field: CustomField_BoxScore><p><a href="<Field: CustomField_BoxScore>">Box Score and Play-by-Play</a></p></If>
<If: Field: CustomField_last_revised><hr /><p>Last Revised: <Field: CustomField_last_revised></p></If>

<!-- End Style Section -->
</td>
</tr>
</table>
</td>
<!-- end main body -->
</tr>
</table>
</body>
</html>
Last edited by Dale Ray on Wed May 07, 2008 3:40 am, edited 1 time in total.
Dale Ray
User avatar
Dale Ray
 
Posts: 1004
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana

Postby Dale Ray » Wed May 07, 2008 3:33 am

Maginot exposed poor coding on my part that viewnews.cgi did not.

I have two entry fields for runs on the X MultiSubmit page for entering game data. This is on purpose. I have a field for the total runs, which I can use to quickly update the results. This is nice when I am updating from my cell phone - two quick fields and the site has the score and our record updated.

I enter the score by innings in another field separated by semi-colons. The code in the style checks to see if the total of the runs by innings and the total entered are equal as an error check and won't display the line score if they are not.

Code: Select all
# compare the runs by inning totals to the total entered on the input page
# to prevent mistakes
if ( ($CustomField_ourScore ne "" && $ourRuns == $CustomField_ourScore) && ($CustomField_oppScore ne "" && $oppRuns == $CustomField_oppScore) ) {
   $showLineScore = 1;
   } else {
   $showLineScore = 0;
}

and later
Code: Select all
<If: Field: showLineScore><table class="scores">
<Field: scoreTable>
</table></If>

In the style posted above I was not resetting the variables that hold the total of the runs by inning, so they did not equal the total entered. So the style did what it was supposed to - not display the line score.

Here is the fix:
Code: Select all
    # process our array
    $n = 0;
    $ourRow = "";
    [color=red]$ourRuns = 0;[/color]

and
Code: Select all
    # process the opp array
    $n = 0;
    $oppRow = "";
    [color=red]$oppRuns = 0;[/color]

I added a line of code that initializes the variables that hold the totals to zero before the array is processed.

This did not show up using viewnews because viewnews.cgi only processes one item at a time, so you do not need to worry about the carry over of values. Using Maginot multiple items are processed so the total keeps growing.
Dale Ray
User avatar
Dale Ray
 
Posts: 1004
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana


Return to Addon Release and Support

Who is online

Users browsing this forum: No registered users and 3 guests

cron