English > Development
PVD .9.9.21 Website Template Easy to Web scripts based on PK Template
koliniol:
I'm doing exactly what you said and it only produces the PVD_Movies_Import.sql that i sent in previous post.
Could it be somethig wrong with the PVD_Movies.xsl file
It looks as if it only reads up to line 15 that produces the Create Table command.
botez:
I was following along here and noticed the same issues that koliniol posted previously. I fixed it by removing the <viddb> and </viddb> tags from the exported xml file. Similarly, you could just remove those from the export script so that they aren't inserted when you export the XML file from PVD.
b_sleeth:
Thank you so much for this updated web export. After installing the update, I came across a few things
In the list_view.tpl needed to change $LANG[RATING] to $LANG[IMDBRATING]
Movie titles are not escaped when being used as "alt=" and "title=" on HTML elements.
-This is only a problem if the movie title contains a single quote.
-I solved this by adding a function to mdb_movie.inc for $MOVIE[TITLEESC] which basically consists of:
return htmlspecialchars($this->data['TITLE'], ENT_QUOTES);
-I then changed all references of "='$MOVIE[TITLE]" to "$MOVIE[TITLEESC]" in the cover*.tpl files
I have some very non-standard width x height cover sizes which do not display correctly
-This required changing a few things
--Changed various "#mdb .movies A.cover*" CSS instruction in style.css by:
---For "IMG" elements: removed width/height, changed margin to auto, and added display:block.
---For non-"IMG" instructions: Added background-color
---This resulted in the following:
--- Code: ---...
#mdb .movies A.cover_details IMG { display: block; margin: auto; padding: 0px; text-decoration: none; border: 0px; }
#mdb .movies A.cover_details { background-color: #88806B; display: block; padding: 0px; border: 4px solid #88806B; margin-right: 10px; width: 130px; height: 180px;}
...
#mdb .movies A.cover IMG { display: block; margin: auto; padding: 0px; text-decoration: none; border: 0px;}
#mdb .movies A.cover { background-color: #88806B; display: block; padding: 0px; border: 4px solid #88806B; margin-right: 10px; width: 156px; height: 216px;}
...
#mdb .movies A.cover2 IMG { display: block; margin: auto; padding: 0px; text-decoration: none; border: 0px;}
#mdb .movies A.cover2 { background-color: #88806B; display: block; padding: 0px; border: 4px solid #88806B; margin-right: 10px; width: 80px; height: 115px;}
...
#mdb .movies A.cover3 IMG { display: block; margin: auto; padding: 0px; text-decoration: none; border: 0px;}
#mdb .movies A.cover3 { background-color: #88806B; display: block; padding: 0px; border: 6px solid #88806B; margin-right: 10px; width: 315px; height: 450px;}
...
#mdb .movies A.cover_random IMG { display: block; margin: auto; padding: 0px; text-decoration: none; border: 0px;}
#mdb .movies A.cover_random { background-color: #88806B; display: block; padding: 0px; border: 3px solid #88806B; margin-right: 0px; width: 55px; height: 77px;}
...
--- End code ---
--Modified the resize.php so that if both width and height are given, they are considered as maximum width/height. Bascially, replaced
--- Code: ---if ($h == NULL) { $h = $height * ($w / $width); }
if ($w == NULL) { $w = $width * ($h / $height); }
--- End code ---
with
--- Code: ---if ( !empty($h) && !empty($w) ) {
$hSizedByTargetW = $height * ($w / $width);
$wSizedByTargetH = $width * ($h / $height);
// If resizing based on width causes the height to exceed target,
// resize by the target height.
if ( $hSizedByTargetW > $h ) {
$w = $width * ($h / $height);
// If resizing based on height causes the width to exceed target,
// resize by the target width.
} elseif ( $wSizedByTargetH > $w ) {
$h = $height * ($w / $width);
} else {
if ( abs($hSizedByTargetW - $h) < abs($wSizedByTargetH - $w) ) {
$w = $wSizedByTargetH;
} else {
$h = $hSizedByTargetW;
}
}
} else {
if ($h == NULL) { $h = $height * ($w / $width); }
if ($w == NULL) { $w = $width * ($h / $height); }
}
--- End code ---
--Added height to all invocations of the resize.php script. This was done by replacing the "&w=?" in the *.tpl files with "&w=?&h=??". This needed to be done for all 5 image widths:
---&w=130 -> &w=130&h=180
---&w=156 -> &w=156&h=216
---&w=80 -> &w=80&h=115
---&w=315 -> &w=315&h=450
---&w=55 -> &w=55&h=77
I changed the processperiod.php to be more dynamic by replacing the calculated period values with:
--- Code: ---if ( $y >= 2000 ) {
$period = substr($y, 0, -1) . (substr($y, -1) >= '5' ? '5' : '0');
$period = $period . '-' . ($period + 4);
} elseif ( $y >= 1930 ) {
$period = substr($y, 0, -1) . '0';
$period = $period . '-' . ($period + 9);
} elseif ( $y >= 1888 ) {
$period="1888-1929";
} else {
$period="Unknown";
}
--- End code ---
I also made the processperiod.php re-runable by moving the call to calculate the periods outside of the test for the column having been added to the datbase. The 2 lines moved were:
--- Code: ---$this->processPeriodForMovies();
print "<br>Period processed for all movies.";
--- End code ---
I also changed the floatbox options:
-Changed "width:443 height:300" to "width:428" in the various cover*.tpl files.
-NOTE: This requires using a new version of floatbox which auto-calculates the height. Of course, the new version of floatbox also requires a license to prevent a nag window :( . If you use the floatbox (v 3.51) as included with the downloads, the height of the box will not be correct. So, you may want to change it to something like "width:443 height:315". This will work for most movie descriptions.
b_sleeth:
One other note. I changed the .xsl to automatically create and update the PERIOD column. This means that the processperiod.php does not need to be run after you update your movie database (and if you were following along in the previous post, it also means that you do not need to modify the processperiod.php file).
The changes to the .xsl file were:
Add the PERIOD column to the table create command:
-Find: PICTURENAME TEXT
-Replace with: PICTURENAME TEXT,PERIOD VARCHAR(15)
Set PERIOD to an empty string on the insert commands:
-Find: <xsl:value-of select="');'"/>
-Replace with: <xsl:value-of select="','');'"/>
Update PERIOD after all movies have been inserted:
-Find (2 lines):
</xsl:for-each>
</xsl:template>
-Replace with (3 lines):
</xsl:for-each>
<xsl:value-of select="'UPDATE movies SET PERIOD = CASE WHEN YEAR >= 2000 THEN CONCAT(LEFT(CAST(YEAR AS CHAR(4)), 3), CASE WHEN RIGHT(CAST(YEAR AS CHAR(4)), 1) >= "5" THEN "5" ELSE "0" END, "-", LEFT(CAST(YEAR AS CHAR(4)), 3), CASE WHEN RIGHT(CAST(YEAR AS CHAR(4)), 1) >= "5" THEN "9" ELSE "4" END) WHEN YEAR >= 1930 THEN CONCAT(LEFT(CAST(YEAR AS CHAR(4)), 3), "0-", LEFT(CAST(YEAR AS CHAR(4)), 3), "9") WHEN YEAR >= 1888 THEN "1888-1929" ELSE "Unknown" END;
'"/>
</xsl:template>
Once again, thank you for sharing this excellent web export!
koliniol:
Hello
Can you share your template ?
also do you have a site where we can see the resulting pages ?
Thanks
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version