<?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>cotsweb.com Blog &#187; Content Management</title>
	<atom:link href="http://www.cotsweb.com/blog/category/web-design/content-management/feed" rel="self" type="application/rss+xml" />
	<link>http://www.cotsweb.com/blog</link>
	<description>Web design, Website development and life in the Cotswolds</description>
	<lastBuildDate>Mon, 23 Jan 2012 13:40:45 +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>Zen Cart copying product_type_layout for a new product_type</title>
		<link>http://www.cotsweb.com/blog/zen-cart-copying-product_type_layout-for-a-new-product_type-155.html</link>
		<comments>http://www.cotsweb.com/blog/zen-cart-copying-product_type_layout-for-a-new-product_type-155.html#comments</comments>
		<pubDate>Wed, 24 Nov 2010 12:16:15 +0000</pubDate>
		<dc:creator>cotsweb</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[eCommerce]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Shopping Cart]]></category>
		<category><![CDATA[Zen Cart]]></category>

		<guid isPermaLink="false">http://www.cotsweb.com/blog/?p=155</guid>
		<description><![CDATA[I have been working on a new site for Global Art Prints.  The site is an online shop selling Limited Edition prints, mainly by British artists.   I have customised a Zen Cart eCommerce installation to suit the new shop.  As part of the process I have needed to add a new product type, Product [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working on a new site for <a title="Limited Edition fine art prints" href="http://www.globalartprints.co.uk">Global Art Prints</a>.  The site is an online shop selling Limited Edition prints, mainly by British artists.   I have customised a <a title="Zen Cart eCommerce and Shopping Cart software" href="http://www.zen-cart.com/">Zen Cart eCommerce</a> installation to suit the new shop.  As part of the process I have needed to add a new product type, Product &#8211; Print, I need fields like colour and size that aren&#8217;t included in the Product &#8211; General type.</p>
<p>For the All product listing and New product listing pages the product_type_layout file determines which fields appear on the screen.  The simplest thing is to duplicate the existing product_type_layout entries for product_type = &#8217;1&#8242;  (Product &#8211; General), the copy can then be used as a base for the display of the new product_type.</p>
<p>So to save somebody some work I offer this mySQL statement which copies all the product_type_layout records for Product &#8211; General and creates a new version for Product &#8211; Print;<br />
<pre><pre>INSERT INTO product_type_layout 
&nbsp;&nbsp;(configuration_title,
&nbsp;&nbsp; configuration_key,
&nbsp;&nbsp; configuration_value, 
&nbsp;&nbsp; configuration_description,
&nbsp;&nbsp; product_type_id,
&nbsp;&nbsp; sort_order,
&nbsp;&nbsp; last_modified,
&nbsp;&nbsp; date_added,
&nbsp;&nbsp; use_function,
&nbsp;&nbsp; set_function)
SELECT
&nbsp;&nbsp; configuration_title, 
&nbsp;&nbsp; REPLACE(configuration_key,&#039;PRODUCT_&#039;,&#039;PRODUCT_PRINT_&#039;),&nbsp;&nbsp; 
&nbsp;&nbsp; configuration_value, 
&nbsp;&nbsp; configuration_description,
&nbsp;&nbsp; &#039;6&#039;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp; sort_order,
&nbsp;&nbsp; now(),
&nbsp;&nbsp; now(),
&nbsp;&nbsp; use_function,
&nbsp;&nbsp; set_function 
FROM product_type_layout
&nbsp;&nbsp;WHERE product_type_id = &#039;1&#039;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</pre></pre><br />
The new records are a copy of the existing Product &#8211; General records except;</p>
<ul>
<li>configuration_id isn&#8217;t explicitly set, this will be handled by mySQL&#8217;s auto_increment.</li>
<li>The configuration_key text PRODUCT_ is replaced by PRODUCT_PRINT &#8211; we can&#8217;t have duplicate configuration_key values.</li>
<li>The new product_type_id = &#8217;6&#8242; which is the value for my new Product &#8211; Print type.</li>
<li>The last_modified and date_added fields are set to the current date/time.</li>
</ul>
<p>I ran this enquiry using phpMyAdmin in my test environment but I used the Tools/Install SQL Patches option in Zen Cart&#8217;s admin area to apply the same change to the live site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cotsweb.com/blog/zen-cart-copying-product_type_layout-for-a-new-product_type-155.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing the sort order in mySQL to give a rolling month</title>
		<link>http://www.cotsweb.com/blog/changing-the-sort-order-in-mysql-to-give-a-rolling-month-138.html</link>
		<comments>http://www.cotsweb.com/blog/changing-the-sort-order-in-mysql-to-give-a-rolling-month-138.html#comments</comments>
		<pubDate>Fri, 02 Apr 2010 11:45:44 +0000</pubDate>
		<dc:creator>cotsweb</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[webdesign]]></category>
		<category><![CDATA[website design]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.cotsweb.com/blog/?p=138</guid>
		<description><![CDATA[I have been working on a new website for Sophie&#8217;s Baked Delights of Bourton-on-the-Water, Sophie creates the yummiest home-baked cakes (a sample was one of the perks of this particular job) and wanted a website to market her delicious wares. One of the pages displays the monthly menu for Sophie&#8217;s Baked Delights Club, a cake [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working on a new website for <a title="Sophie's home-baked delights in Bourton on the Water" href="http://www.sophiesbakeddelights.co.uk" target="_blank">Sophie&#8217;s Baked Delights of Bourton-on-the-Water</a>, Sophie creates the yummiest home-baked cakes (a sample was one of the perks of this particular job) and wanted a website to market her delicious wares.</p>
<p>One of the pages displays the monthly menu for Sophie&#8217;s Baked Delights Club, a cake club where subscribers get a different home-baked cake delivered to them once per month.  Each month subscribers can choose from  two different cakes made with seasonal ingredients. Quite simple really but we wanted the page to display the menu in monthly order with the current month at the top.</p>
<p>The cake details are stored in a mySQL database so Sophie can go in and change them as she changes her menu.  But we only store the month rather than the full date so that the menu can just roll over from year to year without unneccesary maintenance being required.    This meant that we couldn&#8217;t just read through the file by date nor (except in January) could we just read the months in their normal (Jan, Feb, Mar&#8230;) order, if the current month is April we want to display the months as Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, Jan, Feb, Mar (stored as 4,5,6,7,8,9,10,11,12,1,2,3).</p>
<h3>Specifying a sort sequence in mySQL</h3>
<p>Fortunately mySQL has a mechanism for doing this, you can use ORDER BY FIELD in your select statement to specify the order you require.  So the code we need is;<br />
<pre><pre>SELECT * FROM cake_club_menu ORDER BY FIELD(menu_month,4,5,6,7,8,9,10,11,12,1,2,3) , menu_sequence_nbr
</pre></pre><br />
This selects the records we want and sorts them on the field menu_month but in the sequence specified.  The menu_sequence_nbr is a secondary sort field because we have 2 cakes per month and need to keep them in the right column.</p>
<h3>Using PHP to Create the ORDER BY FIELD statement</h3>
<p>Of course we can&#8217;t hard code the ORDER BY FIELD statement as the sequence will change every month, so I created a PHP function to create the  statement, hopefully the following code is pretty clear<br />
<pre><pre>&amp;lt;?php
//
// PHP functions for Sophies Baked Delights
//
function orderByFieldText()
{
//
// Dynamically create text for Order By Field mySQL statement
//   This allows us to list items in month order with the current month first and rolling in to next year
//
//  First get the current month
//
$thisMonth =(date(&quot;n&quot;));
//
//  Now set the base text for the statement - menu_month is the database field we want to order by
//
$orderByField = &quot;ORDER BY FIELD(menu_month,&quot;;
//
// Now loop through 12 times to create the list of month numbers for the statement
//
for ($i = 1; $i &amp;lt;= 12; $i +=1 )
 {
 $orderByField .= $thisMonth;   // Add this month to the statement
 if ($i &amp;lt;&amp;gt; 12) {                // If this isn&#039;t the last item in the list insert a comma
 $orderByField .= &#039;,&#039;;
 }
 else {                         // Else insert a closing bracket
 $orderByField .= &#039;)&#039;;
 }
 if ($thisMonth == 12)          // If we have got to December (12) next month is January (1)
 {
 $thisMonth = 1;
 }
 else {                         //  Else next month is this month +1
 $thisMonth += 1;
 }
 }
return $orderByField;
}
?&amp;gt;
</pre></pre></p>
<h3>Reading the database and displaying the menu</h3>
<p>Then we just need to call the function in the main PHP module and loop through the returned menu records writing the data to the screen as we go.   As you can see from the following code I used a table with a row for each month.<br />
<pre><pre>&amp;lt;table id=&quot;cakeClubMenu&quot;&amp;gt;
 &amp;lt;tbody&amp;gt;
&amp;lt;?php
//
// Populate the order by field for the database lookup
//
$orderByField = orderByFieldText();
//
// Read the cake club menu file to populate the table
//
$sql = &quot;SELECT * FROM cake_club_menu &quot; . $orderByField .&quot; , menu_sequence_nbr&quot;;
$menu_array = mysql_query($sql);
$i = 0;
//
// Now write each line of the table in turn
//
while($menu = mysql_fetch_array($menu_array)) {
 // convert month number to month name for display - thanks to &lt;a title=&quot;An easy way to convert a month number to a month name in PHP&quot; href=&quot;http://www.gilbertpellegrom.co.uk/php-month-number-to-month-name-the-easy-way/&quot;&gt;www.gilbertpellegrom.co.uk&lt;/a&gt;
 $monthNum = $menu[&#039;menu_month&#039;];   
 $monthName = date(&quot;F&quot;, mktime(0, 0, 0, $monthNum, 10));
//
//
 switch ($menu[&#039;menu_sequence_nbr&#039;])
 {
 case 1 :  // 1st cake for the month starts the row
 echo(&quot;&amp;lt;tr&amp;gt;\n&quot;);
 echo(&#039;&amp;lt;td&amp;gt;&#039;.$monthName.&#039;&amp;lt;/td&amp;gt;&#039;.&quot;\n&quot;);
 echo(&#039;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;&#039;.$menu[&#039;menu_cake_name&#039;].&#039;&amp;lt;/strong&amp;gt; - &#039;.$menu[&#039;menu_cake_description&#039;].&#039;&amp;lt;/td&amp;gt;&#039;.&quot;\n&quot;);
 break;
 case 2 :  // 2nd cake finishes the row
 echo(&#039;&amp;lt;td&amp;gt;OR&amp;lt;/td&amp;gt;&#039;.&quot;\n&quot;);
 echo(&#039;&amp;lt;td&amp;gt;&amp;lt;strong&amp;gt;&#039;.$menu[&#039;menu_cake_name&#039;].&#039;&amp;lt;/strong&amp;gt; - &#039;.$menu[&#039;menu_cake_description&#039;].&#039;&amp;lt;/td&amp;gt;&#039;.&quot;\n&quot;);
 echo(&#039;&amp;lt;/tr&amp;gt;&#039;.&quot;\n&quot;);
 break;
 default : // If a 3rd cake is required then this will need modification - currently not allowed
 break;
 }
 }
echo(&#039;&amp;lt;/tbody&amp;gt;&#039;.&quot;\n&quot;);
echo(&#039;&amp;lt;/table&amp;gt;&#039;.&quot;\n&quot;);
?&amp;gt;
</pre></pre><br />
You can see the finished product on the <a title="Sophie's Baked Delights club listing the menu on a rolling month basis" href="http://www.sophiesbakeddelights.co.uk/baked_delights_club_menu.php">Sophie&#8217;s Baked Delights website</a>, and I can assure you that the cakes are very good indeed.</p>
<p>Hopefully someone will find this method useful.  As with most problems the answers are all on the internet, but sometimes you need to find the answer before you know what you should have been searching for.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cotsweb.com/blog/changing-the-sort-order-in-mysql-to-give-a-rolling-month-138.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keeping your WordPress Blog safe</title>
		<link>http://www.cotsweb.com/blog/keeping-your-wordpress-blog-safe-79.html</link>
		<comments>http://www.cotsweb.com/blog/keeping-your-wordpress-blog-safe-79.html#comments</comments>
		<pubDate>Wed, 09 Sep 2009 09:49:15 +0000</pubDate>
		<dc:creator>cotsweb</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blogs]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://www.cotsweb.com/blog/?p=79</guid>
		<description><![CDATA[Anybody with any sort of website needs to think about security.  If nothing else, a hacked site is embarrassing. Part of keeping your site secure is keeping the software up to date, just like you do with your own computer (I hope).  There is a constant battle going on between nice people improving and fixing [...]]]></description>
			<content:encoded><![CDATA[<p>Anybody with any sort of website needs to think about security.  If nothing else, a hacked site is embarrassing.</p>
<p>Part of keeping your site secure is keeping the software up to date, just like you do with your own computer (I hope).  There is a constant battle going on between nice people improving and fixing software and nasty people trying to find new holes which they can exploit for their own gain.  The nice people are working for your benefit so take advantage of their labours and use the upgrades they provide.</p>
<p>If you have a self-hosted WordPress Blog, like this one, then you need to be aware of a new attack.   Take  a look at <a title="Old WordPress Versions Under Attack - upgrade to 2.8.4" href="http://lorelle.wordpress.com/2009/09/04/old-wordpress-versions-under-attack/" target="_blank">Lorelle on WordPress</a> for details.  If you haven&#8217;t upgraded to WordPress 2.8.4 then your blog is vulnerable to this attack.</p>
<p>We have already upgraded all the blogs we host, we keep an eye on software upgrades as a matter of course.  WordPress is very easy to keep up to date, some other packages require a lot more work, but we will always apply security fixes to any package we host.</p>
<p>No system is 100% secure but by keeping up to date you encourage those nasty people to look for easier targets.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cotsweb.com/blog/keeping-your-wordpress-blog-safe-79.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading a file with FCKeditor</title>
		<link>http://www.cotsweb.com/blog/reading-a-file-with-fckeditor-5.html</link>
		<comments>http://www.cotsweb.com/blog/reading-a-file-with-fckeditor-5.html#comments</comments>
		<pubDate>Fri, 09 May 2008 19:54:02 +0000</pubDate>
		<dc:creator>cotsweb</dc:creator>
				<category><![CDATA[Content Management]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[FCKeditor]]></category>
		<category><![CDATA[HTML editor]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[WYSIWYG]]></category>

		<guid isPermaLink="false">http://cotsweb.com/blog/?p=5</guid>
		<description><![CDATA[I am working on a website which contains sections which the client wants to be able to update themselves.  Not very difficult stuff, just updating their pricelist, special offers, that sort of thing.  Rather than a full blown CMS (Content Management System) I opted to have the content in HTML files which can be included [...]]]></description>
			<content:encoded><![CDATA[<p>I am working on a website which contains sections which the client wants to be able to update themselves.  Not very difficult stuff, just updating their pricelist, special offers, that sort of thing.  Rather than a full blown CMS (Content Management System) I opted to have the content in HTML files which can be included into the webpage as required.</p>
<p>All quite simple really, but I needed a way for the client to be able to edit the content online, a simple HTML editor would do but it needed to be WYSIWYG as, while the client is quite capable of updating a formatted document they don&#8217;t really want to get into HTML markup.  After a bit of research I decided that<a title="FCKeditor HTML text editor homepage" href="http://www.fckeditor.net/" target="_blank"> FCKeditor</a> looked pretty good.</p>
<p>Looking at comments about FCKeditor it seemed that it should be pretty easy to set up and indeed it was.  Installation was easy as was getting a quick sample page working, but could I figure out how to load a file into the editor?  No I couldn&#8217;t!  I knew it must be fairly simple but I just couldn&#8217;t find any example of how to do it.  Putting a string into FCKeditor using the Value parameter was straightforward but getting an actual file in there just confounded me.</p>
<p>After spending most of a day hunting around the internet I just couldn&#8217;t get it working properly.  I think I must just be more stupid than the average FCKeditor developer.  But the next day ( problems often look easier the next day) after a little more searching I managed to figure out how to load a file into FCKeditor.  So I thought I&#8217;d put the solution on this blog to save anyone else as silly as me a lot of time.</p>
<p>It is of course quite simple.  The value parameter for FCKeditor must be a string, this is then the starting text in the editor window, the trick is to make your file into a string.</p>
<p>Using PHP I prepared the following test page;</p>
<blockquote><p>&lt;?php<br />
include_once(&#8220;fckeditor/fckeditor.php&#8221;) ;<br />
?&gt;<br />
&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221; &#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;<br />
&lt;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221;&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/html; charset=iso-8859-1&#8243; /&gt;<br />
&lt;title&gt;Amend Pricelist&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;form action=&#8221;sampleposteddata.php&#8221; method=&#8221;post&#8221; target=&#8221;_blank&#8221;&gt;<br />
&lt;?php</p>
<p>// Read the file into an array<br />
$file_array = file(&#8220;pricelist.php&#8221;);</p>
<p>// Convert the array into a string<br />
$file_contents = implode(&#8216; &#8216;,$file_array);</p>
<p>$oFCKeditor = new FCKeditor(&#8216;FCKeditor1&#8242;) ;<br />
$oFCKeditor-&gt;BasePath = &#8216;/fckeditor/&#8217; ;</p>
<p>// Use the string as the initial value for FCKeditor</p>
<p>$oFCKeditor-&gt;Value = $file_contents ;</p>
<p>$oFCKeditor-&gt;Width  = &#8217;700&#8242; ;<br />
$oFCKeditor-&gt;Height = &#8217;750&#8242; ;<br />
$oFCKeditor-&gt;Create() ;<br />
?&gt;<br />
&lt;br /&gt;<br />
&lt;input type=&#8221;submit&#8221; value=&#8221;Submit&#8221;&gt;<br />
&lt;/form&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p>And it worked!  I had managed to load a file into FCKeditor.  There may be a better way of doing this, and I would love to hear about it if someone knows better, but it does the job.</p>
<p>I hope this blog saves someone else a bit of headscratching.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cotsweb.com/blog/reading-a-file-with-fckeditor-5.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

