<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>larryaronson.com &#187; websites</title>
	<atom:link href="http://larryaronson.com/tag/websites/feed/" rel="self" type="application/rss+xml" />
	<link>http://larryaronson.com</link>
	<description>Systems Psychoanalyst</description>
	<lastBuildDate>Thu, 10 May 2012 20:31:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Add Author Photo — My First WordPress Filter</title>
		<link>http://larryaronson.com/2009/add-author-photo-%e2%80%94-my-first-wordpress-filter/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://larryaronson.com/2009/add-author-photo-%e2%80%94-my-first-wordpress-filter/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 18:18:20 +0000</pubDate>
		<dc:creator>Larry Aronson</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[authors]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[filters]]></category>
		<category><![CDATA[hooks]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[lawyer]]></category>
		<category><![CDATA[photos]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Smashing Magazine]]></category>
		<category><![CDATA[websites]]></category>

		<guid isPermaLink="false">http://larryaronson.com/?p=802</guid>
		<description><![CDATA[My client wanted to have their authors' photos appear with their published articles. In this article, I describe how I wrote a Wordpress filter – my first – to prepend an image to the content on the home and single post pages.]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-871" style="padding-left: 0" title="your_photo_here" src="http://larryaronson.com/wp-content/uploads/your_photo_here.jpg" alt="your_photo_here" width="80" height="82" />The request was simple enough. I had just built a <a title="Air Safety And Law" href="http://airsafetyandlaw.com" target="_blank">WordPress blog for a law firm</a> and now they wanted to have their thumbnail photos in the articles they write. I had done this for <a title="Digital HHR" href="http://digitalhhr.com" target="_blank">another website</a> (also a law firm) a year ago, modifying each of the theme&#8217;s templates that displayed posts but, when I went back and looked at that code, I thought, &#8220;Too messy, there&#8217;s got to be a better way.&#8221;</p>
<p>A plug-in search turned up nothing. No surprise—Wordpress does not support user profile pictures natively. There&#8217;s no field in the database for an user&#8217;s image file name. Then I remembered reading an<a title="10 Useful WordPress Hooks" href="http://www.smashingmagazine.com/2009/08/18/10-useful-wordpress-hook-hacks/" target="_blank"> article in Smashing Magazine about filters</a> a couple of months ago. They had an example where a subscribe request was appended to the end of each post&#8217;s content. Maybe that technique would work to prepend a photo.</p>
<p>In WordPress, a filter is like a plug-in except for two important distinctions: It&#8217;s not packaged for distribution and it&#8217;s associated with the theme. That is, you can&#8217;t manage the filter from the dashboard&#8217;s plug-in manager and, if you change themes, it disappears. That was all right for my purposes. The clients were quite happy with the theme we&#8217;d chosen – <a href="http://wpthemes.info/misty-look/" target="_blank">Mistylook, by Sadish Bala</a> – and I could provide instructions on how to remove the filter from the theme&#8217;s functions file should they ever want to &#8220;deactivate&#8221; the feature.</p>
<p>I got the images from the client for the four lawyer/authors—a wallet-sized image and a thumbnail for each. The larger image would appear on the author&#8217;s profile page and the thumbnails would be placed at the beginning of their posts, floated left of the text. For the larger image, I modified the author&#8217;s template (<span style="font-family: andale mono,times;">author.php</span>) as I had with the previous website. For the thumbnails, I would use the filter approach since post content is accessed in several templates and I wanted a unified solution. For the sake of brevity, I&#8217;ll skip the part about the author template mods in this article. If you&#8217;re interested in that piece, leave a comment and I&#8217;ll write another article.</p>
<p>I created a new directory, <span style="font-family: andale mono,times;">/wp-content/authors</span> for the larger images and a sub-directory, <span style="font-family: andale mono,times;">/wp-content/authors/thumbs</span> for the smaller versions. In each, I renamed the images files to match the corresponding login usernames. If, for example, there was a user with the login username of &#8216;bobama&#8217;, then the two images files would be: <span style="font-family: andale mono,times;">/wp-content/authors/bobama.jpg</span> and  <span style="font-family: andale mono,times;">/wp-content/authors/thumbs/bobama.jpg</span> . I did this with an ftp program but you can use the dashboard&#8217;s Media manager, in which case, the image files will be somewhere in your <span style="font-family: andale mono,times;">/wp-content/uploads</span> directory with your other media files. All of the other work described in this article can be done through the dashboard&#8217;s theme editor by an admin user but I highly recommend using a good code editor with color syntax highlighting. <a href="http://bbedit.com/" target="_blank">BBEdit</a> is my favorite.</p>
<p>A WordPress filter goes into the theme&#8217;s functions file (<span style="font-family: andale mono,times;">functions.php</span>) and consists of two parts: A function definition and a call to add that function to a named WordPress &#8220;hook&#8221;. I called my function: <span style="font-family: andale mono,times;">add_author_photo() </span> and  added it to the &#8216;the_content&#8217; hook. You can think of this hook as the point in the page building process when WordPress gets the page or post content from the database and starts to get it in shape for the web page it&#8217;s building. WordPress passes the content to the function as a string and expects it back in return. Roughly, the outline of the process looks like this:</p>
<pre>&lt;?php
     function add_author_photo($content) {
         ...
         return $content;
     }</pre>
<pre>     add_filter('the_content', 'add_author_photo');
?&gt;
</pre>
<p>Note how the entire filter is enclosed in a PHP container. This is important!  Now, all we need to do is fill in the &#8220;dots&#8221;.</p>
<p>First, we need to make sure that our function does its work in the right place since it will be called anytime WordPress fetches the content from the database. We want the thumbnail photo to appear in posts on the home page and on single post pages, but not on static pages (which are, in a sense, &#8220;authorless&#8221;) nor on the archive and search result pages and especially not in RSS feeds. The following if statement does what we want:</p>
<pre style="padding-left: 30px;">if (is_home() || is_single()) {
    ...
}
</pre>
<p>Next, the code needs to check that the image file we want for the current post author actually exists. The client may add more authors and contributors before their photos are available and we don&#8217;t want an ugly, empty missing-image square to appear where a nice photo is expected. This is a bit tricky. There&#8217;s a PHP function,<span style="font-family: andale mono,times;"> file_exists()</span>, for checking whether a file exists or not but it takes, as its argument, the full Unix path to the file, as opposed to a URL fragment. WordPress provides a function for doing this: <span style="font-family: andale mono,times;">get_theme_root()</span> which returns a string that, depending on your hosting company&#8217;s site configuration, might look like this:</p>
<p style="padding-left: 30px;"><tt> </tt><span style="font-family: andale mono,times;">/var/web/clients/abc.com/htdocs/wp-content/themes</span></p>
<p>Since my &#8216;authors&#8217; directory is at the same level in <span style="font-family: andale mono,times;">/wp-content</span> as the themes directory, all I have to do is replace the &#8216;themes&#8217; part in the string above with &#8216;authors/thumbs/&#8217; and append the image&#8217;s file name. The following two lines of code will assign the username to a variable and do the replacement using  PHP&#8217;s  <span style="font-family: andale mono,times;">str_replace()</span> function.</p>
<pre style="padding-left: 30px;">$author_uname = get_the_author_meta('user_login');
$author_photo = str_replace(
                    'themes',
                    'authors/thumbs/' . $author_uname . '.jpg',
                    get_theme_root() );</pre>
<p>We can check whether the file exists with another if statement:</p>
<pre style="padding-left: 30px;">if (file_exists($author_photo)) {
    ...
}
</pre>
<p>Now we are ready to add the  image tag to the beginning of the post content. I&#8217;ll add a CSS class, &#8216;authorImage&#8217;, to the image tag which I&#8217;ll use to make the image float left and set appropriate margins and padding (see below.) I&#8217;ll also enclose the image in an anchor tag that links the image to the author&#8217;s profile page. I&#8217;ve laid this out here in several lines for readability. The dot at the end of each line is the PHP concatenation operator.</p>
<pre style="padding-left: 30px;">$image_src = '/wp-content/authors/thumbs/' .
             $author_uname . '.jpg';

$content =  '&lt;a href="/author/' .
            $author_uname .
            '"&gt;&lt;img class="authorImage" src="' .
            $image_src .
            '" alt="' .
            get_the_author() .
            '" /&gt;&lt;/a&gt;' .
            $content;</pre>
<p>Here&#8217;s a screenshot of the final code I pasted into the theme&#8217;s functions file. Because I&#8217;m a nice guy, I added  /* comments */ to explain what was going on. Click on the image to open a text division with the actual code you can copy.</p>
<p>[RAW]</p>
<p><img class="alignnone size-full wp-image-850" title="Click for text version" onclick="$('#imageText').slideDown();" src="http://larryaronson.com/wp-content/uploads/add_author_photo.jpg" alt="Click for text version" width="490" height="249" /></p>
<div id="imageText" style="border: 1px solid #666666; padding: 0.5em; display: none; width: 490px; font-size: 0.85em;">
<pre>&lt;?php
/*  Add authors' photos to posts on the home and single-post pages.
     Copyright 2009 Larry Aronson.

     For a post author identified by username, if the image file:
	/wp-content/authors/thumbs/username.jpg
     exists, it will be prepended to the content, floating left
     of the text and linked to the author's profile page		*/

function add_author_photo($content) {
  if(is_home() || is_single()) {
    $author_uname = get_the_author_meta('user_login');
    $author_photo = str_replace('themes',
         'authors/thumbs/' . $author_uname . '.jpg',
         get_theme_root());
    if (file_exists($author_photo)) {
	 $image_src = '/wp-content/authors/thumbs/' . $author_uname . '.jpg';
	 $content = '&lt;a href="/author/' . $author_uname .
             '"&gt;&lt;img class="authorImage" src="' .
	     $image_src . '" alt="' . get_the_author() . '" /&gt;&lt;/a&gt;' .
             $content;
     }
  }
  return $content;
}

/* remove the following line to deactivate the add photo feature */
add_filter('the_content', 'add_author_photo');
?&gt;
</pre>
<p><a onclick="$('#imageText').slideUp();" href="javascript: void(0);#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed">click here to hide code.</a></p>
</div>
<p>[/RAW]</p>
<p>The final version took a bit of debugging to fix some stupid typing errors but it worked as I wanted it to. A look at the source code for the home page shows the generated image tag and link:</p>
<pre style="padding-left: 30px;">&lt;a href="/author/larryaronson"&gt;&lt;img class="authorImage"
   src="/wp-content/authors/thumbs/larryaronson.jpg"
   alt="Larry Aronson" /&gt;&lt;/a&gt;
</pre>
<p>All that remained was adding some simple CSS to the style sheet to float the image to the left of the post text. The rules shown below does that and sets appropriate margins.  The images already incorporated a border so I removed the border set elsewhere in the CSS and removed the drop shadow background that Mistylook adds to images as a matter of taste.</p>
<pre style="padding-left: 30px;">img.authorImage {
   float: left;
   margin: 0 1em 0 0;
   border: 0;
   padding: 0;
   background-image: none;
 }</pre>
<p>That&#8217;s it. I hope you found this article useful. Suggestions for improvements are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://larryaronson.com/2009/add-author-photo-%e2%80%94-my-first-wordpress-filter/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Why Knowing HTML Matters</title>
		<link>http://larryaronson.com/2009/why-knowing-html-matters/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://larryaronson.com/2009/why-knowing-html-matters/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 19:57:37 +0000</pubDate>
		<dc:creator>Larry Aronson</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[robots]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[websites]]></category>

		<guid isPermaLink="false">http://larryaronson.com/?p=672</guid>
		<description><![CDATA[Thinking of starting a Website to publish your thoughts or promote your business? While you can create "a site in just minutes – No HTML necessary!", knowing the basics of the Web's markup language and how it provides information to search robots about your site, influencing your site's ranking, will give you an edge in building your online business.]]></description>
			<content:encoded><![CDATA[<p>Thinking of starting a Website to publish your thoughts, promote your business, provide a service, or connect with friends? &#8220;It&#8217;s easy,&#8221; uh-huh, &#8220;It&#8217;s free; No HTML necessary!&#8221; Yeah, right.</p>
<p>Well&#8230;, yes, that is right. Easy because services exists that create usable websites using templates and wizards friendly enough  for the Internet illiterate.  And free – or at least it&#8217;s free in the sense of approaching zero initial software cost. But, in order for your website to grow, you&#8217;re going to need that technical knowledge, HTML, to keep your content publishing costs under control.</p>
<p>How amazing it is that we can create and globally distribute content, on zillions of Web pages, to inform and entertain ourselves without moving physical stuff anywhere! The Web page is irrevocably becoming the World&#8217;s most common form of communication. It&#8217;s the lowest cost replacement for articles, pamphlets, brochures, manuals, directories, flyers, commercials, letters, announcements—almost any kind of document you can think of. The Web does this instantly, adding interactivity, links and searching as a bonus!!</p>
<p>But here&#8217;s the problem: By doing so much for so many, the Web has become irreducibly complex. It&#8217;s also rapidly evolving. The learning curve never gets any less steep and climbing it is <span style="text-decoration: underline;">not</span> easy. There just is so much to know about and we all know that even just knowing about what to know ain&#8217;t easy.</p>
<h3>Content Is Kingdom</h3>
<p><a href="http://larryaronson.com/wp-content/uploads/Keys.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="alignleft size-full wp-image-695" title="Keys to the Kingdom" src="http://larryaronson.com/wp-content/uploads/Keys.jpg" alt="Keys to the Kingdom" width="119" height="146" /></a>For many small website owners, creating and maintaining their own content is paramount. So Web editing tools are the keys to the content kingdom. There are two choices: using a wysiwyg editor on a local PC, downloading and uploading files; or using a Web-based editor to edit content directly on a webserver. The former approch allows you to create Web pages rich in structure and interactivity. The latter is easier by far and can be done anywhere you browse the Web. Unfortunately Web-based wysiwyg editors are rather puny and often frustrating to use when the content has any structure or is already marked up with HTML from another source like Microsoft Word. Knowing HTML helps you avoid many of problems and resolve others before they frustrate, no matter which editing method is used.</p>
<p>When <a href="http://en.wikipedia.org/wiki/Tim_berners-lee" target="_blank">Tim Berners-Lee</a> invented the Web about twenty years ago, he thought that most HTML would be written by software programs. How did that work out? You might ask. Not very well, actually. One of the Web&#8217;s great strengths – a dictate that browsers must gracefully tolerate crappy code – is also a weakness. The early browsers; Mosaic, Netscape, AOL and Internet Explorer, went to war competing for market share by introducing new elements into the HTML language. The people writing wysiwyg editors couldn&#8217;t keep up with the rapid pace of HTML development, delivering mediocre products that generated bad code, while competition among Web designers to create unique and compelling pages encouraged  advanced HTML techniques beyond the capabilities of the wysiwyg editors.</p>
<h3>The Rise Of The Robots</h3>
<p>It&#8217;s 2009 and although they look much like their counterparts of a dozen years ago, Web pages are coded quite differently in this century. For one thing, good cross-browser support for <a href="http://www.w3.org/Style/CSS/" target="_blank">Cascading Style Sheets</a> (CSS) make it possible to code Web pages with far less HTML markup. Also, a large proportion of Web pages are dynamically generated using HTML templates. These templates are bits of code that may be reused millions of times a day so there&#8217;s high value in using the cleanest, leanest HTML markup possible.</p>
<p><a href="http://larryaronson.com/wp-content/uploads/robbyvb9web.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img class="alignright size-thumbnail wp-image-690" title="Robots" src="http://larryaronson.com/wp-content/uploads/robbyvb9web-146x150.jpg" alt="Robots" width="146" height="150" /></a>By far the biggest change is the rise of search technologies and the role that today&#8217;s search platforms: <a href="http://www.google.com" target="_blank">Google</a>, <a href="http://www.yahoo.com" target="_blank">Yahoo</a>, <a href="http://www.bing.com/" target="_blank">Bing</a> and others, play in our experience of the Web. A modern Website seeks to increase its find-ability and raise its search engine ranking. These requirements has spawned a new business practice called Search Engine Optimization (SEO). Companies providing SEO services specialize in writing HTML that&#8217;s very easy for the search engines&#8217; automated scripts (the robots) to understand.</p>
<p>This is Web 2.0, where websites continually exchange information with other websites and where what other websites &#8220;know&#8221; and &#8220;think&#8221; about your website can be as important as your site&#8217;s content. Knowing the basics of HTML, how it works to add semantic information to page elements and how that information is gathered and used by robots  will give you an edge in meeting your online goals.</p>
]]></content:encoded>
			<wfw:commentRss>http://larryaronson.com/2009/why-knowing-html-matters/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Websites For Artists</title>
		<link>http://larryaronson.com/2007/websites-for-artists/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://larryaronson.com/2007/websites-for-artists/#comments</comments>
		<pubDate>Wed, 12 Dec 2007 19:14:31 +0000</pubDate>
		<dc:creator>Larry Aronson</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[art]]></category>
		<category><![CDATA[clients]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[friends]]></category>
		<category><![CDATA[photographs]]></category>
		<category><![CDATA[Web 1.0]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[websites]]></category>

		<guid isPermaLink="false">http://larryaronson.com/2007/websites-for-artists/</guid>
		<description><![CDATA[Here are some of the sites I&#8217;ve designed and built for clients in the commercial and fine arts. I offer them as examples of the simple, static, Web 1.0 sites, done very quickly for friends a few years ago. Today it&#8217;s much easier and more effective to establish an online presence using Web 2.0 tools [...]]]></description>
			<content:encoded><![CDATA[<p>Here are some of the sites I&#8217;ve designed and built for clients in the commercial and fine arts.  I offer them as examples of the simple, static, Web 1.0 sites, done very quickly for friends a few years ago. Today it&#8217;s much easier and more effective to establish an online presence using Web 2.0 tools and social media services.</p>
<p class="item"><a title="Suzearts" href="http://www.suze-arts.com/photoshow.html" target="_blank"><img src="http://larryaronson.com/wp-content/uploads/suze-arts.jpg" border="0" alt="Suzearts" hspace="8" width="200" align="right" /></a><strong><a title="Suzearts" href="http://www.suze-arts.com/photoshow.html" target="_blank">Suzearts</a></strong> is the online showcase for my best friend, Susan Thornton, who creates wonderful images from the land and sky scapes of New Mexico and Fire Island. We put this simple site together in an afternoon several years ago for the New York Licensing show. Today, you can do a lot more to showcase art and music by using services such as <a title="Flickr" href="http://www.flickr.com/" target="_blank">flickr</a> and <a title="photobucket" href="http://photobucket.com/" target="_blank">photobucket</a>, to organize and tag your art, and social media services like <a title="facebook" href="http://facebook.com/" target="_blank">Facebook</a> and <a title="twitter" href="http://twitter.com/" target="_blank">Twitter</a> to promote your work across a web of networks, groups and friends.</p>
<p class="item"><strong><a title="Mick Kolodgy Fine Art" href="http://mickkolodgy.com/" target="_blank">Mick Kolodgy Fine Art</a></strong><br />
<strong><a title="Mick Kolodgy Fine Art" href="http://mickkolodgy.com/" target="_blank"></a></strong> <a title="Mick Kolodgy Fine Art" href="http://larryaronson.com/wp-content/uploads/mickkolodgy_small.jpg#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed"><img src="http://larryaronson.com/wp-content/uploads/mickkolodgy_small.jpg" alt="Mick Kolodgy Fine Art" /></a><br />
is an online gallery of his paintings. I developed the horizontal gallery design with rollover menus at both ends and tied it all together with a compact image caching and navigation scheme written in Javascript. This was fun to build but I can&#8217;t advise artists that having your own showcase site is the best way to leverage the Web anymore. There are many web services companies that want and need your content; provide a wide range of options for organizing, displaying and selling it; can boost your search engine juices and connect you to networks, groups and forums of people interested in what you do.</p>
]]></content:encoded>
			<wfw:commentRss>http://larryaronson.com/2007/websites-for-artists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

