Tip #2: Adding IFilm Video To Your SideBar – The Easy Way

      No Photo Available

    I’ve been a big fan of the IFilm.com website since I first ran across it, and wanted a way to add it to the sidebar. Of course, I had a few goals in mind:

    1. It has to be easy. I don’t want to be messing around with code every time I want to add a trailer to the site.
    2. It has to be foolproof. I don’t want to have to worry about typos.
    3. There should be a message if there is no video, rather than just a blank.

    With those rules in mind, I came up with the following 2 step process…

Thank you for visiting Critiqal! Be sure to sign up for our RSS feed!

I’ve been a big fan of the IFilm.com website since I first ran across it, and wanted a way to add it to the sidebar. Of course, I had a few goals in mind:

  1. It has to be easy. I don’t want to be messing around with code every time I want to add a trailer to the site.
  2. It has to be foolproof. I don’t want to have to worry about typos.
  3. There should be a message if there is no video, rather than just a blank.

With those rules in mind, I came up with the following 2 step process.

Step 1

Add the following code to the Sidebar that displays when viewing a single post:

<div>
<?php $video = get_post_custom_values($key = 'video'); ?>
<?php if ($video =='') { ?>
<p style="text-align:center;"><strong>Video Not Available</strong></p>
<?php } else if ($video !== '') { ?>
<embed type="application/x-shockwave-flash" width="290" height="242" src="http://www.spike.com/efp" quality="high" bgcolor="000000" name="efp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="flvbaseclip=<?php echo $video[0]; ?>&" >
</embed>
<?php } ?>
</div>

Step 2

Now, when you want to add an IFilm video to a post, go to www.ifilm.com www.spike.com and search for the trailer you want. When you find it, the web page address should have a number in it (example: The Forbidden Kingdom trailer is located at http://www.spike.com/video/2931976/subchannel/movies). Simply copy and paste that number (in this case, 2931976) into a custom field named video on your post, and you’re all set.

The Explanation

Basically, what the sidebar code is doing is searching the current post to see if there is a custom field named video and if there is, adding the number in that field (from Step 2) so the video will display (currently in a 290px W x 242px H square).If there isn’t a custom field named video, it says “Video Not Available”.

Single Sidebar?

If you have never altered your sidebar, and it displays exactly the same on every page, add the following code above and below the code in Step 1:

<?php if(is_single()) { ?>
…(code from Step 1)…
<?php } ?>

Tweaking The Code

If you’re looking to change the above code somewhat, there aren’t a whole lot of areas you need to look at.

  • Changing the height and dimension of the video: alter width="290" height="242" to whatever will fit in your sidebar.
  • Change the custom field name to something other than video: alter ($key == 'video') to whatever the name of your custom field is.
  • Change the “Video Not Available” message that displays when there is no video: alter <p style="text-align:center;"><strong>Video Not Available</strong></p> to whatever you like.

That’s it! In the 2 easy steps above, you have added the ability to show iFilm videos in the sidebar of your post. And, with one easy step (Step 2), you can add one video to every post you want – and you won’t have to worry about typos, or wasting a whole lot of time to do it!

UPDATE: ifilm.com has now become www.spike.com. I’ve updated the information above in an effort to future-proof the code a bit, even though currently ifilm.com links still work.

Popularity: 3%

Popularity: 3%

     
Related posts:
  1. Our Favorite WordPress Plugins (in no particular order)
  2. Tip #3: Adding Your Own Videos To Sidebar
  3. Tip#1: Recent Updates in WordPress Sidebar
  4. PHPLD and WordPress – update!
  5. The Base Href
1 Comment
  1. [...] looking for. After a few hours of search engine surfing, I found the perfect solution for my needs. The Minds Chew Toy had a great script to pull hi-quality movie trailers from IFILM (SPIKE.COM). Through the use of [...]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>