For those that aren’t familiar with Yahoo Finance. They provide a simple api for obtaining information (quote) on stocks. To learn the basics of how it works you can read the post Yahoo Finance Stock API, and Understanding Yahoo Finance Stock Quotes and sl1d1t1c1ohgv which outlines the various information that you can request.
However these posts simply inform you of the United States Localized url for obtaining the information. For those in other parts of the world you can use a localized url to get time and date information based on your location. This is done by prepending the country code to the url. For example Germany would prepend de to the url and would download the information at:
http://de.finance.yahoo.com/d/quotes.csv?s=DELL&f=sl1d1t1c1ohgv&e=.csv
A full list of Country Codes can be found below.
Country Codes
| Argentina |
ar |
| Australia |
au |
| Brazil |
br |
| Canada |
ca |
| France |
fr |
| Germany |
de |
| Hong Kong |
hk |
| India |
in |
| Ireland |
uk |
| Italy |
it |
| Korea |
kr |
| New Zealand |
au |
| Singapore |
sg |
| Spain |
es |
| United Kingdom |
uk |
Also as Bastian pointed out in the comments the csv file does not use the , (comma) character as the delimiter for localizations that use commas instead of the period in displaying currency. In these cases the delimiter that is used is the ; (semicolon). The full list of countries with the different delimiter is below.
Localizations with ; delimiter
| Argentina |
| Brazil |
| France |
| Germany |
| Italy |
| Spain |
localization, sl1d1t1c1ohgv, Stock Quotes, Yahoo Finance
In PHP we are provided with an integrated logging system for outputting info, warnings, and errors. This is accomplished by use of the syslog function. This function outputs the specified message at the specified priority level to the default system logger. If you want to have it output the log message to a user defined log handler then you simply need to utilize the openlog and closelog functions before and after respectively before you log a message.
Example Log Statements
syslog(LOG_ERR, "message to be logged as an error");
openlog("AppLog", LOG_PERROR, LOG_LOCAL0);
// code
syslog(LOG_WARNING, "warning priority sample log message");
// code
closelog();
Resources
error, log, notifiy, PHP, syslog, warn
WordPress has many nice built in features and helper functions for us to use in our websites. Some of the basic conditional functions like is_page, is_single, and is_home are perhaps the most versatile and useful to developers and site owners. These functions simply return true or false for if you are on a page, post, or the home page respectively. However they allow you to easily define custom sidebars and content blocks depending on where the user is on your site.
A basic example would be that you have decided that on your home page you would like to display a random post to the user. However when the user is looking at a post you want to display a post in the same category of the post being viewed. To accomplish this you can utilize the conditional tags is_single, and is_home. The logic shown below simply tests if the current page being displayed is the home page if so it outputs a random post, otherwise if it is a single page (post) it outputs a post from the same category of the current post being viewed.
<?php
// check if on home page
if (is_home()) {
$rand_posts = get_posts('numberposts=1&orderby=rand');
foreach( $rand_posts as $rpost ) :
?>
<div>
<h3 ><a href="<?php echo get_permalink( $rpost->ID ); ?>" target="_self"><?php echo get_title($rpost->ID); ?></a></h3>
<div><?php echo get_post_meta($rpost->ID, 'teaser', true); ?></a></div>
<a href="<?php echo get_permalink( $rpost->ID ); ?>" target="_self">Learn More Now »</a>
</div>
<?php
endforeach;
// test for single post
} else if (is_single()) {
// get post categories
$categories = get_the_category();
$cats = array();
foreach( $categories as $category ) {
$cats[] = $category->cat_ID
}
$rand_posts = get_posts(array( 'numberposts' => 1, 'orderby' => 'rand', 'category__in' => $cats, 'exclude' => $post->ID) );
foreach( $rand_posts as $rpost ) :
?>
<div>
<h3 ><a href="<?php echo get_permalink( $rpost->ID ); ?>" target="_self"><?php echo get_title($rpost->ID); ?></a></h3>
<div><?php echo get_post_meta($rpost->ID, 'teaser', true); ?></a></div>
<a href="<?php echo get_permalink( $rpost->ID ); ?>" target="_self">Learn More Now »</a>
</div>
<?php
endforeach;
}
?>
This is one example of how you can utilize these tags. You could use them to determine if ads should be shown or which ones, changing layouts, or any number of ways.
Resources
get_posts, get_post_meta, get_the_category, is_page, is_single, is_singular, Tips & Tricks, Wordpress
Promotions are a very common aspect of store websites. Most promotions you create will have a set amount of time they are valid for. As a responsible site administrator you may want to know how to stop the promotional page from being displayed in Google’s search results after it expires. To let you do this Google has provided the unavailable_after META tag.
unavailable_after
The unavailable_after META tag notifies google that this page is going to expire at this date and time. This allows google to remove it from it’s indexes so that it does not appear in search results after the expiration date.
<META NAME="GOOGLEBOT" CONTENT="unavailable_after: 35-Aug-2010 06:00:00 EST">
A helpful feature for any site that uses online promotions.
Resources
Google, GoogleBot, META tags, unavailable_after, Website Administration
In some instances you may have content on your website that you don’t want Google to archive. Google understands this and provides various META tags for you to use in notifying their crawler in how to handle your website’s content. Two such tags are NOSNIPPET and NOARCHIVE.
NOARCHIVE
The NOARCHIVE META tag is used to tell the Google crawler to not archive this page and its content. This wil stop their being a cached version of the page in the google search results.
<META NAME="GOOGLEBOT" CONTENT="NOARCHIVE">
NOSNIPPET
The NOSNIPPET META tag notifies the crawler that you do not want a snippet of of the pages content to be dispalyed in search results. If you specify NOSNIPPET then the crawler will also not archive the page contents so you do not need to put both META tags in your pages.
<META NAME="GOOGLEBOT" CONTENT="NOSNIPPET">
Resources:
Crawling, Google, GoogleBot, META tags, NOARCHIVE, NOSNIPPET