<?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>Jes.Gs v2.0 &#187; PHP</title>
	<atom:link href="http://www.jes.gs/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jes.gs</link>
	<description>The Portfolio and Blog of Minneapolis Web Designer Jessica C. Green</description>
	<lastBuildDate>Sat, 21 Jan 2012 19:56:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Image Editor: Featured Image field in Quick Editor</title>
		<link>http://www.jes.gs/php/image-editor-featured-image-field-in-quick-editor/</link>
		<comments>http://www.jes.gs/php/image-editor-featured-image-field-in-quick-editor/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 19:56:25 +0000</pubDate>
		<dc:creator>Jess G.</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.jes.gs/?p=750</guid>
		<description><![CDATA[On that note, why not add a Featured Image field to the Quick Editor? I bet there&#8217;s a plugin for that.]]></description>
			<content:encoded><![CDATA[<p>On that note, why not add a Featured Image field to the Quick Editor?</p>
<p>I bet there&#8217;s a plugin for that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jes.gs/php/image-editor-featured-image-field-in-quick-editor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Feature Request: Extend the Image Editor</title>
		<link>http://www.jes.gs/php/wordpress-feature-request-extend-the-image-editor/</link>
		<comments>http://www.jes.gs/php/wordpress-feature-request-extend-the-image-editor/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 19:37:09 +0000</pubDate>
		<dc:creator>Jess G.</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.jes.gs/?p=745</guid>
		<description><![CDATA[Let's extend the Image Editor!]]></description>
			<content:encoded><![CDATA[<p>One feature I would like to see in either 3.4 or 3.5: additional hooks that allow a developer to extend the Image Editor.</p>
<p>The Image Editor was introduced in WordPress 2.9, and was a pretty awesome feature. It still is, but I have one complaint: it&#8217;s not extendable. At least not in any way that I&#8217;ve been able to find from reviewing the source code. It&#8217;s actually a shame, really. It&#8217;s like the Image Editor was just dropped in and forgotten. A part of that complaint, is that unlike the Scissors plugin (which — from I remember reading at the time — the Image Editor was based on) which allows you to edit <em>any</em> of the available thumbnail sizes, the Image Editor gives you an all-or-nothing option.</p>
<p>Being able to tweak each thumbnail individually is an important feature and it&#8217;s too bad that it was left out. Sure, I could use Scissors but I really don&#8217;t like Scissors&#8217; interface. There is already a <a title="External link: Extend media editor cropping and image size availability" href="http://wordpress.org/extend/ideas/topic/extend-media-editor-cropping-and-image-size-availability" target="_blank">post on WordPress.org&#8217;s Extend/Ideas forum on this very subject</a>, though it was last updated about 4 months ago.</p>
<p>That being said, with development on 3.4 currently starting, it might be worthwhile to see if modifications to the Image Editor can be made to allow it to be extended. The next question would be what parts can be extended, and what can&#8217;t be extended. Hey, all it takes are a few well-placed hooks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jes.gs/php/wordpress-feature-request-extend-the-image-editor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress: Using page_css_class</title>
		<link>http://www.jes.gs/php/wordpress-page-css-class/</link>
		<comments>http://www.jes.gs/php/wordpress-page-css-class/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 04:30:58 +0000</pubDate>
		<dc:creator>Jess G.</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Recommended]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Wordpress Resources]]></category>

		<guid isPermaLink="false">http://dumpster-fairy.com/?p=575</guid>
		<description><![CDATA[How to use WordPress hooks to change the pagenav class from page-item-# to page-item-pagename.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m pretty sure that I&#8217;m not the only person who is somewhat annoyed by the way WordPress handles the page-item classes for Page lists. Particularly if you&#8217;re like me and you use WordPress as a CMS. It would be a lot easier to deal with <code>page-item-pagename</code> than <code>page-item-1</code>. For one, <code>page-item-pagename</code> is easier to remember. Well, I bet you didn&#8217;t know that you can change that! Yep, that&#8217;s right. You can, and it&#8217;s all because of a relatively unknown hook that was introduced in WordPress 2.8 called <code>page_css_class</code>, and here is very quick and dirty way of changing the page item classes to match the pagename and <em>not</em> the page ID.</p>
<ol>
<li>Open or create a functions.php file in your theme directory.</li>
<li>Then paste the code below into your functions.php file:</li>
</ol>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page_css_class'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'custom_page_css_class'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009933; font-style: italic;">/**
 *	custom_page_css_class()
 *	Hooks into page_css_class and modifies the page item class so that
 *	it uses the name of the page instead of the id.
 *
 *	@global int $id.		The ID of the page being viewed. Needed to set current_page_item.
 *	@param array $class.	The page css class being modified, passed as an array from Walker_Page
 *	@param object $page.	The page object passed from Walker_Page
 *	@return array			Returns the new page css class.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> custom_page_css_class<span style="color: #009900;">&#40;</span><span style="color: #000088;">$class</span><span style="color: #339933;">,</span> <span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$id</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span>
		<span style="color: #666666; font-style: italic;">/* checks if the page ID matches the current page and if it does,
		    adds the current_page_item class
		*/</span>
		<span style="color: #000088;">$t</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'page_item'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'page-item-'</span><span style="color: #339933;">.</span><span style="color: #000088;">$page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_name</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'current_page_item'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">else</span>
		<span style="color: #000088;">$t</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'page_item'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'page-item-'</span><span style="color: #339933;">.</span><span style="color: #000088;">$page</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$t</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>There you go! Yes, it&#8217;s that easy.</p>
<p>What the example does is it duplicates what&#8217;s happening in the WordPress source code but instead of using $page->ID, it&#8217;s using $page->post_name. It assembles the classes into an array and then returns it to be echo-ed out when the pagenav is generated. Note that $class isn&#8217;t used but it is necessary to have it as one of the parameters because WordPress passes it to the hook by default and we need the $page object in order to make the example work.</p>
<p>Happy coding!</p>
<ul>
<li><a href="http://adambrown.info/p/wp_hooks/hook/page_css_class" rel="external">WordPress hook directory page_css_class</a></li>
<li><a href="http://svn.automattic.com/wordpress/tags/2.9/wp-includes/classes.php" rel="external">WordPress Classes.php Source Reference</a></li>
<li><a href="http://wordpress.org/support/topic/243523" rel="external">WordPress Support: Add Link with Class to Page Menu</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.jes.gs/php/wordpress-page-css-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing ThickBox in WordPress 2.8</title>
		<link>http://www.jes.gs/htmlcss/how-to-fix-thickbox-in-wordpress-2-8/</link>
		<comments>http://www.jes.gs/htmlcss/how-to-fix-thickbox-in-wordpress-2-8/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 20:45:49 +0000</pubDate>
		<dc:creator>Jess G.</dc:creator>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Recommended]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[fixes]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://dumpster-fairy.com/?p=324</guid>
		<description><![CDATA[How to restore ThickBox functionality in Wordpress 2.8 and higher.]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using ThickBox then you&#8217;ve probably noticed that ThickBox is technically broken in WordPress 2.8. After trial-and-error, I&#8217;ve tracked down the problems and this is what&#8217;s happening and here is how to fix it.</p>
<p><ins datetime="2010-02-27T05:35:41+00:00" style="font-size:  medium; text-decoration: none; line-height: 1em; "><em><strong>Edit</strong>: February 27th, 2009. Finally had to time to check but the missing ThickBox CSS is still a problem in WordPress 2.9. My guess is that it might not be an actual bug but a feature to accommodate designers creating their own custom ThickBox designs.</em></ins></p>
<h3>WordPress 2.8 requires themes to have <strong>wp_footer()</strong></h3>
<p>WP 2.8 introduced a new option when using wp_enqueue_script() to load JavaScript files. It allows you the option of having the scripts load in the footer, which is why WordPress themes now require wp_footer() to work properly. However, that wasn&#8217;t my problem since I&#8217;d always added wp_head(), wp_meta() and wp_footer() as a matter of course when designing themes. So if the absence or presence of wp_footer() wasn&#8217;t the problem, then what was really going on?</p>
<h3>What&#8217;s with ThickBox anyway?</h3>
<p>Now, for the problem with ThickBox. So we know that it <em>is</em> being loaded, just in the footer. What I <em>have</em> found is that WordPress is <em>not</em> loading all of the files that ThickBox needs to work. jQuery <em>is</em> being loaded, so that can be ruled out. What <em>isn&#8217;t</em> being loaded is the CSS file that ThickBox needs to format its popup window. Also, another part of the problem is the ThickBox.js file itself has the paths to the images it needs set to relative paths.</p>
<h3>How we fix it</h3>
<p>Starting off, if you haven&#8217;t added the code to load ThickBox, go ahead and add <code>wp_enqueue_script( 'jquery' )</code> and <code>wp_enqueue_script( 'thickbox' )</code> to your header. Now what we do is we add <strong>wp_enqueue_style(&#8216;thickbox&#8217;)</strong> to our &lt;head&gt; section. I&#8217;ve seen people asking for wp_enqueue_css and &#8220;lamenting&#8221; the fact there isn&#8217;t such a function but there actually <em>is</em>, it is <strong><a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_style">wp_enqueue_style()</a></strong>. The second part requires adding to an existing functions.php file or creating a functions.php if it doesn&#8217;t exist with your current theme. In your functions.php file, copy and paste this code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_footer'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'load_tb_fix'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> load_tb_fix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;script type=&quot;text/javascript&quot;&gt;tb_pathToImage = &quot;'</span> <span style="color: #339933;">.</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'siteurl'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-includes/js/thickbox/loadingAnimation.gif&quot;;tb_closeImage = &quot;'</span> <span style="color: #339933;">.</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'siteurl'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-includes/js/thickbox/tb-close.png&quot;;&lt;/script&gt;'</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This fixes those first few lines of the ThickBox.js file that calls the images that ThickBox uses, and it is inserted in the footer <em>after</em> the call that inserts the reference to ThickBox.js.</p>
<p>So now, ThickBox functionality should be restored. Quick recap:</p>
<ol>
<li>Add the code below to your &lt;head&gt; section:

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
wp_enqueue_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'jquery'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
wp_enqueue_style<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'thickbox'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
wp_enqueue_script<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'thickbox'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

</li>
<li>Then add this code to your functions.php file:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_footer'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'load_tb_fix'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> load_tb_fix<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;script type=&quot;text/javascript&quot;&gt;tb_pathToImage = &quot;'</span> <span style="color: #339933;">.</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'siteurl'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-includes/js/thickbox/loadingAnimation.gif&quot;;tb_closeImage = &quot;'</span> <span style="color: #339933;">.</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'siteurl'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-includes/js/thickbox/tb-close.png&quot;;&lt;/script&gt;'</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

</li>
</ol>
<h3>Conclusion</h3>
<p>Had do some research to figure out what was going on besides just looking at my own source code. The first reference to this issue I found was at this link: <em><a href="http://kovshenin.com/archives/thickbox-and-jquery-in-wordpress-2-8/">ThickBox and jQuery in WordPress 2.8</a></em>, then I figured out how to fix the ThickBox dependency image loading issues by looking at the code for the NextGen Gallery plugin.</p>
<p>Good luck! And enjoy your restored ThickBox functionality <img src='http://www.jes.gs/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.jes.gs/htmlcss/how-to-fix-thickbox-in-wordpress-2-8/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>WordPress Plugin: YaECP</title>
		<link>http://www.jes.gs/htmlcss/wordpress-plugin-yaecp/</link>
		<comments>http://www.jes.gs/htmlcss/wordpress-plugin-yaecp/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 01:50:21 +0000</pubDate>
		<dc:creator>Jess G.</dc:creator>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[Updates]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Wordpress Resources]]></category>
		<category><![CDATA[yaecp]]></category>

		<guid isPermaLink="false">http://dumpster-fairy.com/?p=300</guid>
		<description><![CDATA[Which stands for &#8220;Yet Another Exclude-Cats Plugin.&#8221; Fairly easy to use, just follow these basic steps: Just unzip into your WordPress plugins directory Open the WordPress plugins page Activate the ]]></description>
			<content:encoded><![CDATA[<p>Which stands for &#8220;Yet Another Exclude-Cats Plugin.&#8221; Fairly easy to use, just follow these basic steps:</p>
<ol>
<li>Just unzip into your WordPress plugins directory</li>
<li>Open the WordPress plugins page</li>
<li>Activate the YaECP plugin</li>
<li>Look for the new page called &#8220;Exclude Categories&#8221; in the Posts section.</li>
<li>Finally, select which categories you wish to exclude from the front page.</li>
</ol>
<p>I whipped this plugin up on the spur-of-the-moment to deal with some issues that I found in the beta version of <a href="http://manga-press.silent-shadow.net">Manga+Press 2.5</a> having to do with it&#8217;s new exclude comic categories from the front page option. Apparently, if you want to exclude another category as well as the comic category, you can&#8217;t call <code>query_posts()</code> again because it will reset the <a href="http://manga-press.silent-shadow.net">Manga+Press</a> query.</p>
<p>The plugin was tested on WordPress 2.8 so I&#8217;m not so sure how it&#8217;ll work with versions older than 2.8. I am also not so sure how the plugin will work with specialized themes that have multiple loops, such as magazine-style WordPress themes. Either way, hope someone gets some use out of it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jes.gs/htmlcss/wordpress-plugin-yaecp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP and XML: LightGallery</title>
		<link>http://www.jes.gs/general/php-and-xml-lightgallery/</link>
		<comments>http://www.jes.gs/general/php-and-xml-lightgallery/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 03:47:00 +0000</pubDate>
		<dc:creator>Jess G.</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://dumpster-fairy.com/?p=247</guid>
		<description><![CDATA[Light-weight Image Gallery script powered by PHP and XML.]]></description>
			<content:encoded><![CDATA[<p>LightGallery is a new light-weight gallery script that I wrote as an answer to &#8220;weightier&#8221; scripts like Gallery and Coppermine. LightGallery does not require MySQL to run; however it <em>does</em> require <strong>PHP 5</strong> and the <strong>GD library</strong>.<span id="more-247"></span> A short example of LightGallery in action can be seen <a href="http://dumpster-fairy.com/gallery/">here</a>. You can also download the script <a href="http://www.jes.gs/wp-content/uploads/2009/03/gallery.zip">here</a>.</p>
<p>How to use LightGallery? First off, start by inserting this code at the top of any page you&#8217;d like to display your gallery:</p>
<p>Followed by:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/path/to/my/images/folder'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$thmb_size</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'thumb-height thumb-width'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$gallery</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Gallery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">,</span> <span style="color: #000088;">$thmb_size</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$gallery</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Output</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><code>$path</code> is obviously the full path pointing to the directory where your images reside. Replace <strong>thumb-height</strong> and <strong>thumb-width</strong> with the desired height and width of your thumbnail. The beauty of LightGallery is that it is one PHP Class that can be used as many times as need be. If you need to create a new gallery, all you have to do is create a new directory, upload your images to that directory and create a new Gallery object with <code>$path</code> set to that path.</p>
<p><strong>Some limitations include</strong>:<br />
The gallery directory has to be one level below the root directory where <code>gallery.php</code> resides. Another limitation is that LightGallery uses jQuery and ThickBox and ThickBox is hard-coded into LightGallery, though I plan to change that at a later date.</p>
<p><strong>Tips</strong>:<br />
If you want your thumbnails to display tool-tips and have captions in ThickBox, edit the <code>album.xml</code> file that is created in the directory where your images reside. Specifically edit the  and  tags so that they contain your desired title and description. Another planned edition to LightGallery is a single-user backend to allow easy editing of titles, descriptions and possibly deletion of images.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jes.gs/general/php-and-xml-lightgallery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP and XML: A Quick Introduction</title>
		<link>http://www.jes.gs/htmlcss/php-and-xml-a-quick-introduction/</link>
		<comments>http://www.jes.gs/htmlcss/php-and-xml-a-quick-introduction/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 18:00:45 +0000</pubDate>
		<dc:creator>Jess G.</dc:creator>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[web dev]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://dumpster-fairy.com/?p=236</guid>
		<description><![CDATA[A quick and dirty intro to using PHP to manipulate XML.]]></description>
			<content:encoded><![CDATA[<p>A quick and dirty intro to using PHP to manipulate XML. Very useful to know since there are probably situations where MySQL might be unavailable or just impractical and XML can make a great replacement, especially in small/light-weight applications.<br />
<span id="more-236"></span><br />
The first place we start is by looking at PHP&#8217;s <a href="http://us3.php.net/manual/en/book.dom.php">DOM extension</a>; read through the Introduction and Installation/Configuration sections before continuing.<br />
Now we&#8217;ll access the <a href="http://us3.php.net/manual/en/class.domdocument.php">DOMDocument</a> class. Starting out, this will probably be the class that gets used the most but as things progress, you&#8217;ll find yourself making use of the other classes available.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$xmldoc</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DOMDocument<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// create a new DOMDocument object.</span></pre></div></div>

<p>Yep, it&#8217;s that simple. Now here comes the fun part. This scenario is going to assume that we&#8217;re just creating a new XML object.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$xmldoc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">formatOutput</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Nicely formats output with indentation and extra space.</span>
&nbsp;
<span style="color: #000088;">$root</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xmldoc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'xml'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//create a root element for your XML output</span>
<span style="color: #000088;">$xmldoc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$root</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Now, we're going to create a few child elements to go with it</span>
<span style="color: #000088;">$child1</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xmldoc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'child_one'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Child One'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$root</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$child1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$child2</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xmldoc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'child_two'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Child Two'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$root</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$child2</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$xmldoc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveXML</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//output to screen...</span></pre></div></div>

<p>Pretty simple and straightforward. Now, if we want to save to a file, we do this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$xmldoc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my-xml-file.xml'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>If we want to open and write to a file:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$xmldoc</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DOMDocument<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// create a new DOMDocument object.</span>
<span style="color: #000088;">$xmldoc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my-xml-file.xml'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$xmldoc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">formatOutput</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$root</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xmldoc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">documentElement</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Conviently allows direct access to the root element.</span>
&nbsp;
<span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xmldoc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'another_one'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'another child'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$root</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$b</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$xmldoc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my-xml-file.xml'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Very quick and straightforward. I hope this helps anyone who was wondering how to use XML and PHP together.</p>
<p>For more information see:</p>
<ul>
<li><a href="http://us3.php.net/manual/en/refs.xml.php">PHP Manual: XML Manipulation</a></li>
<li><a href="http://www.kirupa.com/web/index.htm (scroll down for PHP section)">Kirupa.com: PHP and XML</a></li>
<li><a href="http://www.ibm.com/developerworks/library/x-xmlphp1.html">IBM.com: XML for PHP Developers, Part 1 (three-part series)</a></li>
<li><a href="http://www.dynamicdrive.com/forums/showthread.php?t=14165">DynamicDrive Forums: Read and Write XML with PHP</a> (forum-post, this is what got me started)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.jes.gs/htmlcss/php-and-xml-a-quick-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

