<?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>走出Windows &#187; ECShop</title>
	<atom:link href="http://www.killwin.com/articles/category/web/ecshop/feed" rel="self" type="application/rss+xml" />
	<link>http://www.killwin.com</link>
	<description>抛弃Windows就是走向高效率</description>
	<lastBuildDate>Fri, 23 Sep 2011 12:50:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>ECShop 商品分类添加图片</title>
		<link>http://www.killwin.com/articles/303.html</link>
		<comments>http://www.killwin.com/articles/303.html#comments</comments>
		<pubDate>Thu, 15 Jul 2010 16:12:52 +0000</pubDate>
		<dc:creator>LuckyBoy</dc:creator>
				<category><![CDATA[ECShop]]></category>

		<guid isPermaLink="false">http://www.killwin.com/?p=303</guid>
		<description><![CDATA[想给每个分类有个图片，网上找了教程，肯定不能成功，现在把成功的方法写出来，供大家参考 数据库 category表 添加一个字段 cat_img ，类型设置 varchar 打开 admin/templates/category_info.htm 找个地方添加下面代码 分类图片: &#60;input name=&#34;cat_img&#34; size=&#34;35&#34; type=&#34;file&#34; /&#62; {if $cat_info.cat_img}&#60;img src=&#34;images/yes.gif&#34; border=&#34;0&#34; alt=&#34;&#34; /&#62;{else}&#60;img src=&#34;images/no.gif&#34; alt=&#34;&#34; /&#62;{/if} 打开 admin/category.php 找到 require&#40;dirname&#40;__FILE__&#41; . '/includes/init.php'&#41;; 下面添加 include_once&#40;ROOT_PATH . '/includes/cls_image.php'&#41;; 找到 $cat&#91;'cat_recommend'&#93; = !empty&#40;$_POST&#91;'cat_recommend'&#93;&#41; ? $_POST&#91;'cat_recommend'&#93; : array&#40;&#41;; 全文共2处，两处下面都添加 $cat&#91;'cat_img'&#93; = $image-&#38;gt;upload_image&#40;$_FILES&#91;'cat_img'&#93;&#41;; 保存，ok了 以下为7月18日更新 上面所述这样做，会有一个问题，添加了分类图片，如果再编辑了分类而没有上传图片，那么图片会被清除，所以做如下修正 将下面这句 $cat&#91;'cat_img'&#93; = $image-&#62;upload_image&#40;$_FILES&#91;'cat_img'&#93;&#41;; 改成 [...]]]></description>
			<content:encoded><![CDATA[<p>想给每个分类有个图片，网上找了教程，肯定不能成功，现在把成功的方法写出来，供大家参考</p>
<p>数据库 category表 添加一个字段 cat_img ，类型设置 varchar</p>
<p>打开 admin/templates/category_info.htm</p>
<p>找个地方添加下面代码</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">分类图片: &lt;input name=&quot;cat_img&quot; size=&quot;35&quot; type=&quot;file&quot; /&gt;
{if $cat_info.cat_img}&lt;img src=&quot;images/yes.gif&quot; border=&quot;0&quot; alt=&quot;&quot; /&gt;{else}&lt;img src=&quot;images/no.gif&quot; alt=&quot;&quot; /&gt;{/if}</pre></div></div>

<p>打开 admin/category.php</p>
<p>找到</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/includes/init.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>下面添加</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span>ROOT_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/includes/cls_image.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>找到</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$cat</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cat_recommend'</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cat_recommend'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>  ? <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cat_recommend'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>全文共2处，两处下面都添加</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$cat</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cat_img'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$image</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>upload_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cat_img'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>保存，ok了</p>
<hr />
以下为7月18日更新</p>
<p>上面所述这样做，会有一个问题，添加了分类图片，如果再编辑了分类而没有上传图片，那么图片会被清除，所以做如下修正</p>
<p>将下面这句</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$cat</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cat_img'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$image</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">upload_image</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cat_img'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>改成</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$cat_img</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$image</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">upload_image</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cat_img'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cat_img</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$cat</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'cat_img'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cat_img</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.killwin.com/articles/303.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

