Story Viewer Website Code
I’ve been asked several times how I put my Sims Stories on my website. Basically, I use a combination of PHP and Javascript. And finally, I’ve decided to share my code with anyone who may want it!
This will most likely not be of interest to a lot of you with free-host websites that don’t offer PHP. But if you’re a bit of a nerd, here you go.
http://jaclynt.com/scripts/storyviewer/
REQUIREMENTS:
A web server with PHP 5. PHP 4 will NOT work, so make sure version 5 is what your server has.
A novice understanding of how the web works.
You need to understand that PHP files need to be on a web server and not run from your local machine.
You need to know how to get directory paths on your server—and you need to know the difference between a file structure path on your server and a URL.
You need to know how Sims 2 Stories are put together in your game.
How to associate web_xxxxxxxx.xml files with snapshot_xxxxxxxx_yyyyyyyy.jpg files and where to find them.
INSTRUCTIONS:
Download and un-zip: http://jaclynt.com/scripts/storyviewer/jaclyns_story_viewer.rar
Locate on your local hard drive, your web_xxxxxxxx.xml and all snapshot_xxxxxxxx_yyyyyyyy.jpg files associated with your story.
Upload them to a new directory on your web server.
Note the location of this new directory—both from the root of your file server and how to access it from the web (URL).
Open: index.php
(You can right click and choose open with Notepad, or download something that doesn’t suck, like Notepad++: http://notepad-plus.sourceforge.net)
Set:
$storyURLPath to the directory URL where all your snapshots are located.
$storyXMLPath is the file path (not a URL!) to your XML file.
Example:
$storyURLPath = “http://jaclynt.com/scripts/storyviewer/story/”;
$storyXMLPath = “/home/jaclynt/jaclynt.com/scripts/storyviewer/story/webentry_b32c3301.xml”;
Got pictures other than 600px wide by 450px tall? Set the size of them (all snapshots should be the same size) in index.php:
$slideWidth = 600;
$slideHeight = 450;
CUSTOMIZATION:
You may change the HTML in index.php however you like. Just keep the DIV element “storycontent” and all its children AS IS.
You may completely customize the look of the page in style.css
You may rename the file index.php to anything else you like…
NOTES:
This script should parse [b][/b] and [i][/i] bulletin-board codes, but no others.
Web links and email addresses are made clickable within your story text.
Smart quotes are accounted for.
EXTRAS:
This is an example of a story placed into the system that was NOT generated by The Sims 2 game directly.
To use this version, you would need to understand the very very basics of XML, or rather just what it is enough to copy and paste in the appropriate spots.
This version is all manual, but you never know, some might find it useful.
See the files in the folder, nongamestory.
Here, you make your own XML file. Open the file storydata.xml.
See how it plugs in the file name for the snapshot and the text associated with it (if any)? Pretty self-explanatory, I think.
BUGS?
Report them to me, you know where to find me. This script it by no means perfect or final, and just made out of light hobby. So it’s easy for me to miss things here and there.
ADVANCED:
Something further you can do to automate the process is store your list of stories in a database. I keep a list of story titles, their associate XML file name, and give it a tag and chapter number which corresponds to its directory on my server. Then I pass my php page parameters of the story title, chapter, and tag. So there’s no copy the index.php file over and over.
Instead I call a page called something like “story.php”, and pass it parameters so it may look like: story.php?title=iwokeupla&chapter=1
Then I use Apache Mod-Rewrite to mask the URL so it looks like:
http://jaclynt.com/read/iwokeupla/1/



