Wordpress and flash?

July 03rd, 2009 | Author: Sunny

ok. First I want to say: This may not work, just my idea how Wordpress and flash work together.

Since WordPress uses Database, you can actually retrieve your Blog from the database. What you need to do is write a script to retrieve those data and display it as XML or whatever data format you like. Then your flash movie should read XML (or other data format) and display it.

This purpose only good for read only.. since we are not modifying the database.. so I guess this should work well. If you want to do more advance stuff, then the best way is first to see how the database tables related to each other, then do an appropriate updates for each modification.

If you have a better idea, please let me know…


WordPress Theme – My header.php

March 24th, 2009 | Author: Sunny

This is code for my header.php:


<?php
  /**
  * @package WordPress
  * @subpackage mySmallProgramTheme
  */
  ?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>

<head profile="http://gmpg.org/xfn/11">
  <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />

<title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
  <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
  <link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" />
  <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
  <link rel="shortcut icon" href="<?php get_bloginfo('url') ?>/wp-content/themes/mysmallprogramtheme/image/favicon.png" type="image/png" />

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  <?php if (is_singular() ) wp_enqueue_script('comment-reply');
  ?>
  </head>
  <body>
  <div id="page">
  <div id="header">

  <div id="headerimage">
  <a href="<?php echo get_option('home'); ?>" ><h1><?php bloginfo('name'); ?></h1></a>
  <div class="description"><?php bloginfo('description'); ?></div>
  </div>

First, I have setup some header information with bloginfo() in the Header tag. You may just take a look how I did that because you mostly will put the same header as mine.

After the Header Tag, I defined a Wrapper layer “page”


<div id="page">

This is the wrapper for all contents in my blog. In this wrapper, usually you will define four different parts(or layers).

1. Header
2. Content
3. Footer
4. Sidebar

And for this example, this file is called header.php, so I will define our “Header” layer here. Next 5 lines, I have defined my “Header”:


 <div id="header">

  <div id="headerimage">
  <a href="<?php echo get_option('home'); ?>" ><h1><?php bloginfo('name'); ?></h1></a>
  <div class="description"><?php bloginfo('description'); ?></div>
  </div>

In the header layer, I have defined another wrapper called “headerimage”. This is because I want to wrap my Blog title and description in my header layer.

Later on, I will show you how I created index.php for my content layer. footer.php for my footer layer, and sidebar.php for my sidebar layer.

One more thing I forgot to mention, in header section, there is a php code:


 <?php if (is_singular() ) wp_enqueue_script('comment-reply');
  ?>

is_singular() will check if this page is a single post (only one post on the page, and actually there is a template file called single.php that you may also define it yourself or by WordPress default template. single.php is liked index.php which I will call my header, sidebar, and footer files here except it only displays one post per page). In my case, I only want to include javascript for replying a comment when someone land on single.php, or else the code should not be included.

So, it looks pretty simple right? However, don’t forget the code above has no decoration, so you will have to define your own CSS style for each layer and wrapper, or otherwise you will only see plain text on your header.


body {
	font-size: 62.5%; /* Resets 1em to 10px */
	font-family: Arial, Helvetica, sans-serif;
	background: #ffffff;
	color: #333;
	text-align: center;

}

#page {
	border: none;
	background:url(image/layoutbg.png) repeat-y bottom center;

}

#header {
	background: url(image/headerpic.jpg) no-repeat top center;
}

#headerimage {
	width: 830px;
	height: 195px;
}

#header h1 {
	font-size:36px;
	text-align: center;
	color: #903;
}

#header a, #header a:visited {
	text-decoration: none;
	color: #903;
}

#header a:hover {
	text-decoration:underline;
}

#headerimage .description {
	font-size:14px;
	text-align: center;
	color: #666;
	font-family:Georgia, "Times New Roman", Times, serif;
	font-style:italic;
}

body {
	margin: 0px 0 20px 0;
	padding: 0;
}

#page {
	margin: 0px auto;
	padding: 0;
	width: 830px;
}

#header {
	margin: 0 0 0 0px;
	padding:0;
	height:195px;
	width: 830px;
}

#headerimage {
	margin: 0;
}

#header h1 {
	margin: 0;
	padding:70px 0px 0px 0;
}

#headerimage .description {
	margin: 0;
	padding:1px 15px 0 0;
}


Please forgive my mess. :) I defined them twice because I kinda modified from the default WordPress Theme which it separates the style of structure and coloring in two parts. You may just group them in one depends on what you like.


WordPress Theme – Highlight Plugin

March 12th, 2009 | Author: Sunny

When I was trying to post some PHP coding, I found it is not easy to decorate it.. for example, you want the code to be aligned, so that it is user friendly (easy to read). Then you need to handle space for each line. Also, you may want to highlight some keywords. There will be a lot of work, and some programming languages look really similar, but if you want to decorate them, you may have to do it one by one, and it could suck out most of your time.

Fortunately, WordPress has a plugin that helps you to do all the works for you. It is called Highlight, and you can download it and use it as WordPress plugin or just code it within your HTML file. You only need to assign some CSS style such as color for keywords. This is very nice because usually I like to program everything myself, but this really saves me a lot of time. (On the other hand, many things on the web are really useful).

For example,


<?php
if (is_home()) {
	echo bloginfo('name');
} elseif (is_404()) {
	echo '404 Not Found';
} else {
	echo wp_title('');
}
?>

and my CSS Style (which applies the highlight for the code above and below for showcase):


code {
	color: #000099;
	font: normal "Courier New", Courier, monospace;
	white-space: nowrap;
	padding: 0 2px;
}
pre code {
	display: block;
	clear: both;
	background: #FDF;
	color: #333;
	border: solid 1px #ccc;
	overflow: auto;
	line-height: 140%;
	white-space: pre;
	width: 470px;
	text-align:left;
}
code .comment {
	color: #888;
}
code .class, code .rules {
	color: #ff00ff;
	font-size: 100%;
}
code .value,  code .title, code .string {
	color: #0000FF;
}
code .tag {
	color: #000099;
}
code .keyword {
	color: #000099;
}
.html .attribute {
	color: #006600;
}

All I have done is just put all my code within <pre><code></code></pre> and it will decorate my code with my CSS style. Isn’t it really easy? yea, you can compare my old posts which I just use <p> and style it, and which still doesn’t look good.

One more thing, if you do not want to use it as plugin, you can just put these two lines of code on your web page (The WordPress plugin will automatically add these two lines to your WordPress blog) :


<script type="text/javascript" src="highlight.pack.js"></script>
    <script type="text/javascript">
      hljs.initHighlightingOnLoad();
    </script>

It is pretty easy, right?

For more information about Highlight, you can visit this Link:
http://softwaremaniacs.org/soft/highlight/en/