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/




Oh goodness gracious me.
You are a goddess. I LOVE THIS! I even bookmarked the script’s page at del.icio.us (HEE! First reflex action. *nerd*). I seriously love you for this! And I’m sure so does everyone else. =D
I don’t know if I’ll be able to use this on full-fledged chapters of my story (I’m seriously set back by the fear of hogging space and bandwidth off my hostess), but it would do good for mini-crack or mini-stories I would plan to put on. Thank you so much for your effort! This is too cool for words!
I’m a sad girl, though. I have no clue about Apache Mod-Rewrite. I’m a pathetic being who copy-pastes those generated WordPress codes they provide you to paste in your .htaccess with no clue how they work. xP
Again, thank you sooo sooo sooo sosososossoo much for this! Too awesome.
Thank you soooo much for this Jaclyn! I really wish I could do this on my site but, unfortunately piczo doesn’t support PHP. I will defiantly book mark this though for future reference if I do get my own hosted web site. Thanks again Jaclyn! Your such an awesome person!^_^
-Celeste
Jaclyn you are my hero ^_^. Sadly i’m gonna have to wait until I can get my own space to install this since, like Punki I’m afraid of using to much of Spethy’s space #_#
this is amazing jaclyn. simply amazing.
and i WILL find great use to this, since i’m uploading my newest series to my website only. just perfect. and my webhost does support PHP, soo woop woop! haha. you made my week — okay more like month.
you might get a whiny PM from me though, cause i expect myself to first explode my website first, html splattered everywhere, then finally get it and fix the code. haha. ^__^