scriptygoddess

01 Jan, 2004

Moods in your posts

Posted by: Jennifer In: pMachine

So for a while now I've wanted to be able to use "current mood" with my posts, kind of like LiveJournal has. Then I noticed that I wasn't using my categories, well, not for anything really worthwhile. So my solution? I've made up a way for your categories to be used for your moods.

1. These instructions are assuming you're using Pmachine, but I assume you could adapt them for whatever type of blog…

2. Make yourself a moods directory on your web server; this is where you will put your moods.js file, and all your mood .gif icons.

3. Go to your main index.php template page, or whatever page you will be showing moods (index.php, comments.php, etc.), and put the following line in your -head-:

<script language="javascript" type="text/javascript" src="http://www.mypage.com/journal/moods/moods.js"></script>

4. Go to the entry template in Pmachine, and in the place where you want the mood to show up, (I have mine right below the entry title) add this line:

<p><script language="javascript">PrintMood("%%category%%");</script><p>

5. Create a moods.js file with your editor of choice, and add these lines:

function PrintMood(ThisCat) {
function Fix(CatVal, PicVal, NumVal) { // Allows you to use variables for the array instead of numbers.
this.CatVal = CatVal
this.PicVal = PicVal
this.NumVal = NumVal
}
MoodFolder="http://www.mypage.com/journal/moods";
JournalIndex="http://www.mypage.com/journal/index.php";
MainVar = 0; // Sets up the variable that counts the array.
var MainArray = new Array() // Sets up the main array.
// MainArray[MainVar++] = new Fix("category", "picname.jpg", "category number")
MainArray[MainVar++] = new Fix("accomplished", "kity-accomplished.gif", "61")
MainArray[MainVar++] = new Fix("aggravated", "kity-aggravated.gif", "39")
MainArray[MainVar++] = new Fix("amused", "kity-amused.gif", "34")
for (loop=0; loop < MainVar ; loop++) {
Keyword = ThisCat;
PicName = MainArray[loop].PicVal;
CatNum = MainArray[loop].NumVal;
SearchResult = Keyword.indexOf(MainArray[loop].CatVal);
if (SearchResult != "-1") {
document.write('current mood: <img src="' + MoodFolder + '/' + PicName + '" style="vertical-align:middle"> '
+ '<a href="' + JournalIndex + '?id=C0_' + CatNum + '_3">' + Keyword + '</a>');
}
}
}

6. Change the MoodFolder and the JournalIndex so they are set up the way your page is.

7. Go into the Pmachine control panel and create your categories. For each category, keep track of what the created category ID number is.

8. You'll see I only have three categories listed here; you can add additional lines, for as many categories as you want. I think I have about thirty set up right now. Within the quotes, add the category name (try not to create category names with spaces), the .gif name of the mood icon you want for that mood, and the category ID number for that mood.

That's about it, you should be ready to go! If you need additional help, feel free to drop me an email… and your paypal donations to kitykity(AT)hotmail.com for this tip are welcome. 😀

No Responses to "Moods in your posts"

Comments are closed.

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements