<?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>toyosystem &#187; CakePHP</title>
	<atom:link href="http://www.jamboree.jp/cms/archives/category/php/cakephp/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jamboree.jp/cms</link>
	<description>名古屋在住のWebプログラマー</description>
	<lastBuildDate>Fri, 26 Aug 2011 12:41:42 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>CakePHP1.2でキャッシュが消えない</title>
		<link>http://www.jamboree.jp/cms/archives/533</link>
		<comments>http://www.jamboree.jp/cms/archives/533#comments</comments>
		<pubDate>Wed, 09 Sep 2009 07:28:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/?p=533</guid>
		<description><![CDATA[CakePHP の自動キャッシュクリアが効くのは、コントローラ名＝モデル名のときだけ : akiyan.com ↑という時用 behaviorsで指定すれば多少ましかもしれないと思った。 たとえばPostモデルってのがあるんだけど、Postモデルにsave()かdelete()があったときにはトップページのtopっていうアクションのビューも削除して欲しいって時には。 post.php PLAIN TEXT PHP: var $actsAs = array&#40;'ClearCache'=&#62;array&#40;'names'=&#62;array&#40;'top'&#41;&#41;&#41;; として 以下のコードをclear_cache.phpとかで/models/behaviorsに保存しておけば PLAIN TEXT PHP: &#60;?php /* *&#160; キャッシュクリア */ class ClearCacheBehavior extends ModelBehavior &#123; &#160; &#160; &#160; var $names = array&#40;&#41;; &#160; &#160; &#160; function setup&#40;&#38;$model, $config = array&#40;&#41;&#41;&#123; &#160; &#160; &#160; &#160; if&#40;!empty&#40;$config&#91;'names'&#93;&#41;&#41; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.akiyan.com/blog/archives/2007/04/cakephp.html" target="_blank">CakePHP の自動キャッシュクリアが効くのは、コントローラ名＝モデル名のときだけ : akiyan.com</a><br />
↑という時用 behaviorsで指定すれば多少ましかもしれないと思った。</p>
<p>たとえばPostモデルってのがあるんだけど、Postモデルにsave()かdelete()があったときにはトップページのtopっていうアクションのビューも削除して欲しいって時には。</p>
<p>post.php</p>
<div class="igBar"><span id="lphp-3"><a href="#" onclick="javascript:showCodeTxt('php-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-3">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$actsAs</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'ClearCache'</span>=&gt;array<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'names'</span>=&gt;array<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'top'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
として</p>
<p>以下のコードをclear_cache.phpとかで/models/behaviorsに保存しておけば</p>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showCodeTxt('php-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/*</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> *&nbsp; キャッシュクリア</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> ClearCacheBehavior extends ModelBehavior <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$names</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> setup<span style="color:#006600; font-weight:bold;">&#40;</span>&amp;<span style="color:#0000FF;">$model</span>, <span style="color:#0000FF;">$config</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.php.net/empty"><span style="color:#000066;">empty</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'names'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">names</span> = <span style="color:#0000FF;">$config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'names'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> afterSave<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$created</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_clear<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> afterDelete<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_clear<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> _clear<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">names</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$name</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clearCache<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$name</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Postモデルが更新されるたびにtopのビューキャッシュもクリアされて<br />
いいと思います</p>
<h2>まとめ</h2>
<p>あと、CakePHPのビューのキャッシュはアクション名ベース（？）なので?id=99みたいなGETパラメータには対応していないとかもあるので、いっそビューのキャッシュはあきらめるというのも手です。</p>
<p><a href="http://www.exgear.jp/blog/2008/11/cakephp12-behavior%E3%81%A7%E3%83%A2%E3%83%87%E3%83%AB%E3%81%AE%E3%83%A1%E3%82%BD%E3%83%83%E3%83%89%E3%82%AD%E3%83%A3%E3%83%83%E3%82%B7%E3%83%A5%E3%82%92%E8%A1%8C%E3%81%86/" target="_blank">CakePHP1.2 Behaviorでモデルのメソッドキャッシュを行う : エクスギア　Blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/533/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP1.2で使えるテンプレート</title>
		<link>http://www.jamboree.jp/cms/archives/338</link>
		<comments>http://www.jamboree.jp/cms/archives/338#comments</comments>
		<pubDate>Tue, 03 Feb 2009 03:58:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/?p=338</guid>
		<description><![CDATA[CakePHPのサイトはカッコいいのに、CakePHPにデフォルトで入っているテンプレートはかっこ悪い。 もっと管理画面用のテンプレートってないのかなと思ったので、まず自分が一個公開します。 もとはフリーのテンプレートですがフォームやnotice,errorの部分などをCake風にアレンジしてあります。 見た目 ファイル default.ctpとstyle.cssが入っているので、適切な場所に配置してください。 minimalistic.zip(9KB) ライセンスはGPLです。 参考サイト Minimalistic Design]]></description>
			<content:encoded><![CDATA[<p><a href="http://cakephp.org/">CakePHPのサイト</a>はカッコいいのに、CakePHPにデフォルトで入っているテンプレートはかっこ悪い。<br />
もっと管理画面用のテンプレートってないのかなと思ったので、まず自分が一個公開します。<br />
もとはフリーのテンプレートですがフォームやnotice,errorの部分などをCake風にアレンジしてあります。</p>
<h2>見た目</h2>
<p><a href="http://www.jamboree.jp/cms/wp-content/uploads/2009/02/cakephp001.png"><img src="http://www.jamboree.jp/cms/wp-content/uploads/2009/02/cakephp001-300x204.png" alt="cakephp001" title="cakephp001" width="300" height="204" class="aligncenter size-medium wp-image-340" /></a></p>
<p><a href="http://www.jamboree.jp/cms/wp-content/uploads/2009/02/cakephp002.png"><img src="http://www.jamboree.jp/cms/wp-content/uploads/2009/02/cakephp002-300x200.png" alt="cakephp002" title="cakephp002" width="300" height="200" class="aligncenter size-medium wp-image-339" /></a></p>
<h2>ファイル</h2>
<p>default.ctpとstyle.cssが入っているので、適切な場所に配置してください。<br />
<a href="http://www.jamboree.jp/cms/wp-content/uploads/2009/02/minimalistic.zip">minimalistic.zip(9KB)</a><br />
ライセンスはGPLです。</p>
<h2>参考サイト</h2>
<p><a href="http://www.minimalistic-design.net/">Minimalistic Design</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/338/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP1.1のページングでGETパラメータを正しく引き継ぐ</title>
		<link>http://www.jamboree.jp/cms/archives/232</link>
		<comments>http://www.jamboree.jp/cms/archives/232#comments</comments>
		<pubDate>Sat, 27 Sep 2008 13:00:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/archives/232</guid>
		<description><![CDATA[以前にCakePHP1.1用のPaginationコンポーネントを紹介したんですが、getパラメータに配列を使うと正しくリンクを作ってくれなかったのでそれの補足。 要するにhttp://example.com/?data[Search][name]=1とかって感じの配列がGETパラメータにある場合に、このパラメータを引き継いでくれない（data=Arrayとかってなる）バグを修正した。 /views/helpers/pagination.phpの_generateUrlってメソッドを修正する。 http_build_queryっていう関数を使ったんですが、これは配列もしくはオブジェクトからURL エンコードされたクエリ文字列を生成する関数で、なんと多次元配列にも対応している。さすがPHP！（オブジェクトに対応してるほうが変か） PLAIN TEXT PHP: function _generateUrl &#40;$page=NULL,$pageDetails=NULL&#41; &#160; &#160; &#123; &#160; &#160; &#160; &#160; $pageDetails = $pageDetails?$pageDetails:$this-&#62;_pageDetails; &#160; &#160; &#160; &#160; $getParams = $this-&#62;getParams; // Import any other pre-existing get parameters &#160; &#160; &#160; &#160; if &#40;$this-&#62;_pageDetails&#91;'paramStyle'&#93;=="pretty"&#41; &#160; &#160; &#160; &#160; &#123; &#160; &#160; &#160; &#160; &#160; &#160; $pageParams=$pageDetails&#91;'importParams'&#93;; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>以前にCakePHP1.1用のPaginationコンポーネントを<a href="http://www.jamboree.jp/cms/archives/14">紹介した</a>んですが、getパラメータに配列を使うと正しくリンクを作ってくれなかったのでそれの補足。</p>
<p>要するにhttp://example.com/?data[Search][name]=1とかって感じの配列がGETパラメータにある場合に、このパラメータを引き継いでくれない（data=Arrayとかってなる）バグを修正した。</p>
<p>/views/helpers/pagination.phpの_generateUrlってメソッドを修正する。<br />
http_build_queryっていう関数を使ったんですが、これは配列もしくはオブジェクトからURL エンコードされたクエリ文字列を生成する関数で、なんと多次元配列にも対応している。さすがPHP！（オブジェクトに対応してるほうが変か）</p>
<div class="igBar"><span id="lphp-6"><a href="#" onclick="javascript:showCodeTxt('php-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-6">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> _generateUrl <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$page</span>=<span style="color:#000000; font-weight:bold;">NULL</span>,<span style="color:#0000FF;">$pageDetails</span>=<span style="color:#000000; font-weight:bold;">NULL</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$pageDetails</span> = <span style="color:#0000FF;">$pageDetails</span>?<span style="color:#0000FF;">$pageDetails</span>:<span style="color:#0000FF;">$this</span>-&gt;_pageDetails;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$getParams</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">getParams</span>; <span style="color:#FF9933; font-style:italic;">// Import any other pre-existing get parameters</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;_pageDetails<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'paramStyle'</span><span style="color:#006600; font-weight:bold;">&#93;</span>==<span style="color:#FF0000;">"pretty"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$pageParams</span>=<span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'importParams'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$pageParams</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'show'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'show'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$pageParams</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'sortBy'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'sortBy'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$pageParams</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'direction'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'direction'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$pageParams</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'page'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$page</span>?<span style="color:#0000FF;">$page</span>:<span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'page'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'sortByClass'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$pageParams</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'sortByClass'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'sortByClass'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$getString</span> = <a href="http://www.php.net/array"><span style="color:#000066;">Array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$prettyString</span> = <a href="http://www.php.net/array"><span style="color:#000066;">Array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'paramStyle'</span><span style="color:#006600; font-weight:bold;">&#93;</span>==<span style="color:#FF0000;">"get"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$getParams</span> = am<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$getParams</span>,<span style="color:#0000FF;">$pageParams</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">else</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$pageParams</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$key</span> =&gt; <span style="color:#0000FF;">$value</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'Defaults'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$key</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>up<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$pageDetails</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'Defaults'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$key</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>&lt;&gt;up<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$value</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$prettyString</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#FF0000;">"$key{$pageDetails['paramSeperator']}$value"</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">else</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$prettyString</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#FF0000;">"$key{$pageDetails['paramSeperator']}$value"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$url</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">url</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$prettyString</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$prettyString</span> = <a href="http://www.php.net/implode"><span style="color:#000066;">implode</span></a> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"/"</span>, <span style="color:#0000FF;">$prettyString</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$url</span> .= <span style="color:#0000FF;">$prettyString</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$getParams</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$url</span> .= <span style="color:#FF0000;">"?"</span>. http_build_query<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$getParams</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$url</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/232/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP1.1でキャリアごとの絵文字を表示</title>
		<link>http://www.jamboree.jp/cms/archives/227</link>
		<comments>http://www.jamboree.jp/cms/archives/227#comments</comments>
		<pubDate>Fri, 05 Sep 2008 11:02:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/archives/227</guid>
		<description><![CDATA[すでにいろいろな方法があるようです。 CakePHPで3キャリア携帯の絵文字を表示する :: Webプログラマー＋WebデザイナーなZARU日記（DB使用） ひでぶろぐ CAKEPHP絵文字入力・出力ヘルパー（DB使用） EmojiHelper - キャリアを意識せずに絵文字を出力できるCakePHPのHelperクラス - 芋ではない日記（JSON使用） 僕はDBを使うのが嫌だったのとJSONは使ったことがなかったのでMobilePictogramConverterという絵文字ライブラリがあるのでそれを使いました。 特徴 * DoCoMo, au, SoftBankの絵文字を相互変換可能 * 端末からサーバーへ送信された絵文字の変換が可能（掲示板など） * SJIS/UTF-8に対応 * PCでの絵文字表示が可能（画像） * 絵文字画像は全て透過GIFでアニメーションに対応 * DoCoMo隠し絵文字一部対応 * バイナリコード, Web入力コード, imgタグからの変換が可能 * 絵文字の削除が可能 * 文字列に含まれる絵文字の数を検出 * UserAgentからキャリアを判別し、キャリアに合った絵文字に自動変換が可能 すごいです。作った人。 手順 (1)MobilePictogramConverterを取得して解凍 (2)MobilePictogramConverterを/app/vendorsにいれる (3)MobilePictogramConverterのimgをWEBROOT_DIR/img/m/にいれる (4)/app/app_controller.phpを編集 PLAIN TEXT PHP: &#60;?php vendor&#40;'MobilePictogramConverter/MobilePictogramConverter'&#41;; &#160; class AppController extends Controller &#123; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>すでにいろいろな方法があるようです。<br />
<a href="http://blog.tofu-kun.org/080715194417.php" target="_blank">CakePHPで3キャリア携帯の絵文字を表示する :: Webプログラマー＋WebデザイナーなZARU日記（DB使用）</a><br />
<a href="http://www.hideblog.net/nikkis/show/11" target="_blank">ひでぶろぐ CAKEPHP絵文字入力・出力ヘルパー（DB使用）</a><br />
<a href="http://d.hatena.ne.jp/ymkn/20080131/p1" target="_blank">EmojiHelper - キャリアを意識せずに絵文字を出力できるCakePHPのHelperクラス - 芋ではない日記（JSON使用）</a></p>
<p>僕はDBを使うのが嫌だったのとJSONは使ったことがなかったので<a href="http://php-develop.org/MobilePictogramConverter/" target="_blank">MobilePictogramConverter</a>という絵文字ライブラリがあるのでそれを使いました。</p>
<blockquote><p>
特徴<br />
    *  DoCoMo, au, SoftBankの絵文字を相互変換可能<br />
    * 端末からサーバーへ送信された絵文字の変換が可能（掲示板など）<br />
    * SJIS/UTF-8に対応<br />
    * PCでの絵文字表示が可能（画像）<br />
    * 絵文字画像は全て透過GIFでアニメーションに対応<br />
    * DoCoMo隠し絵文字一部対応<br />
    * バイナリコード, Web入力コード, imgタグからの変換が可能<br />
    * 絵文字の削除が可能<br />
    * 文字列に含まれる絵文字の数を検出<br />
    * UserAgentからキャリアを判別し、キャリアに合った絵文字に自動変換が可能</p></blockquote>
<p>すごいです。作った人。</p>
<h2>手順</h2>
<p>(1)MobilePictogramConverterを取得して解凍<br />
(2)MobilePictogramConverterを/app/vendorsにいれる<br />
(3)MobilePictogramConverterのimgをWEBROOT_DIR/img/m/にいれる<br />
(4)/app/app_controller.phpを編集</p>
<div class="igBar"><span id="lphp-8"><a href="#" onclick="javascript:showCodeTxt('php-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-8">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">vendor<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'MobilePictogramConverter/MobilePictogramConverter'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> AppController extends Controller <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//app_controllerのいろいろは省略</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> beforeFilter<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/ob_start"><span style="color:#000066;">ob_start</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent::<span style="color:#006600;">beforeFilter</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> afterFilter<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parent::<span style="color:#006600;">afterFilter</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">// バッファを取得して、出力バッファをクリア</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$out</span> = <a href="http://www.php.net/ob_get_clean"><span style="color:#000066;">ob_get_clean</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"webservices"</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> &amp;&amp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"webservices"</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#FF0000;">"Mobile"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$out</span> = <a href="http://www.php.net/mb_convert_kana"><span style="color:#000066;">mb_convert_kana</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$out</span>,<span style="color:#FF0000;">"k"</span>,<span style="color:#FF0000;">"UTF-8"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$mpc</span> =&amp; MobilePictogramConverter::<span style="color:#006600;">factory</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$out</span>, MPC_FROM_EZWEB, MPC_FROM_CHARSET_UTF8, MPC_FROM_OPTION_WEB<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$mpc</span>-&gt;<span style="color:#006600;">setImagePath</span><span style="color:#006600; font-weight:bold;">&#40;</span>WEBROOT_DIR . <span style="color:#FF0000;">'img/m/'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$out</span> = <span style="color:#0000FF;">$mpc</span>-&gt;<span style="color:#006600;">autoConvert</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$out</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
バッファをためて一括で変換しています。絵文字と一緒に全角カナも半角カナに直してしまいます。<br />
$this->params["webservices"]で判別しているのはShin x blogさんの「<a href="http://www.1x1.jp/blog/2006/09/cakephp_mobile.html">CakePHP 携帯用ビューを表示する</a>」を使用して携帯のビューを切り替えているからです。</p>
<p>これで携帯のビュー内で&gt;img localsrc="180"/&lt;とかってやると絵文字が表示されます。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/227/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>デザイナーのためのCakePHP1.1メモ</title>
		<link>http://www.jamboree.jp/cms/archives/156</link>
		<comments>http://www.jamboree.jp/cms/archives/156#comments</comments>
		<pubDate>Sat, 17 May 2008 19:10:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/archives/156</guid>
		<description><![CDATA[「デザイナーのためのCakePHP入門」というエントリを書いていたのですが、さしあたって1.1の説明が必要になったのでデザイナーさん向けのメモ。主にビューでのHTMLヘルパーの説明になります。 どこを編集すればいいのか？ /app/views テンプレートファイルがあります /app/webroot Stylesheet、Javascript、画像、そのほかのファイルなどはこちらにおきます。css,js,imgというディレクトリがあらかじめ用意されています。大変申し訳ないのですがディレクトリ名はこのまま使ってください。（変えたい場合はプログラマに相談してください） テンプレートの構造 ここからは/app/views以下の話になります。 まずレイアウトが/layout以下にあり、layoutファイルの中の &#60;?php echo $content_for_layout ?&#62; という記述のところに中身が差し込まれます。 &#60;?php echo $this-&#62;renderElement('なんとか'); ?&#62; という記述を見つけたら、それは「/views/element/なんとか」ってファイルを取り込んでいますので、そちらを見てください（layoutファイル以外でも使われます） 各種タグなど 各種外部ファイルの読み込み PLAIN TEXT PHP: &#60;?php echo $html-&#62;css&#40;'import'&#41;; ?&#62; //スタイルシートを読み込む &#60;?php echo $javascript-&#62;link&#40;'prototype'&#41;;?&#62; //Javascriptを読み込む 拡張子は省略できます。それぞれ/app/webroot/css,/app/webroot/jsに入れておいてください。 画像を表示 PLAIN TEXT PHP: &#60;?php echo $html-&#62;image&#40;"logo.gif"&#41; ?&#62; これで/app/webroot/imgにあるlogo.gifを表示します。 PLAIN TEXT PHP: $html-&#62;image&#40;'logo.gif',array&#40;"id"=&#62;"logo","alt"=&#62;"会社ロゴ"&#41;&#41;; 第2引数にハッシュを渡してやることでimgタグにid="logo",alt="会社ロゴ"が追加されます。 リンク PLAIN TEXT PHP: &#60;?php echo $html-&#62;link&#40;"トップ" [...]]]></description>
			<content:encoded><![CDATA[<p>「<a href="http://www.jamboree.jp/cms/archives/139">デザイナーのためのCakePHP入門</a>」というエントリを書いていたのですが、さしあたって1.1の説明が必要になったのでデザイナーさん向けのメモ。主にビューでのHTMLヘルパーの説明になります。</p>
<h2>どこを編集すればいいのか？</h2>
<h3>/app/views</h3>
<p>テンプレートファイルがあります</p>
<h3>/app/webroot</h3>
<p>Stylesheet、Javascript、画像、そのほかのファイルなどはこちらにおきます。css,js,imgというディレクトリがあらかじめ用意されています。大変申し訳ないのですがディレクトリ名はこのまま使ってください。（変えたい場合はプログラマに相談してください）</p>
<h2>テンプレートの構造</h2>
<p>ここからは/app/views以下の話になります。<br />
まずレイアウトが/layout以下にあり、layoutファイルの中の</p>
<pre class="php">&lt;?php <span class="func" >echo</span> <span class="vars" >$content_for_layout</span> ?&gt;</pre>
<p>という記述のところに中身が差し込まれます。</p>
<pre class="php">&lt;?php <span class="func" >echo</span> <span class="vars" >$this</span>-&gt;renderElement(<span class="string" >'なんとか'</span>); ?&gt;</pre>
<p>という記述を見つけたら、それは「/views/element/なんとか」ってファイルを取り込んでいますので、そちらを見てください（layoutファイル以外でも使われます）</p>
<h2>各種タグなど</h2>
<h3>各種外部ファイルの読み込み</h3>
<div class="igBar"><span id="lphp-15"><a href="#" onclick="javascript:showCodeTxt('php-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-15">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$html</span>-&gt;<span style="color:#006600;">css</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'import'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#000000; font-weight:bold;">?&gt;</span> <span style="color:#FF9933; font-style:italic;">//スタイルシートを読み込む</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$javascript</span>-&gt;<span style="color:#006600;">link</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'prototype'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt; <span style="color:#FF9933; font-style:italic;">//Javascriptを読み込む </span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
拡張子は省略できます。それぞれ/app/webroot/css,/app/webroot/jsに入れておいてください。</p>
<h3>画像を表示</h3>
<div class="igBar"><span id="lphp-16"><a href="#" onclick="javascript:showCodeTxt('php-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-16">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$html</span>-&gt;<span style="color:#006600;">image</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"logo.gif"</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
これで/app/webroot/imgにあるlogo.gifを表示します。</p>
<div class="igBar"><span id="lphp-17"><a href="#" onclick="javascript:showCodeTxt('php-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-17">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$html</span>-&gt;<span style="color:#006600;">image</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'logo.gif'</span>,<a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"id"</span>=&gt;<span style="color:#FF0000;">"logo"</span>,<span style="color:#FF0000;">"alt"</span>=&gt;<span style="color:#FF0000;">"会社ロゴ"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
第2引数にハッシュを渡してやることでimgタグにid="logo",alt="会社ロゴ"が追加されます。</p>
<h3>リンク</h3>
<div class="igBar"><span id="lphp-18"><a href="#" onclick="javascript:showCodeTxt('php-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-18">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$html</span>-&gt;<span style="color:#006600;">link</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"トップ"</span> , <span style="color:#FF0000;">"/top"</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
とやると、/topへのトップというリンクを表示します。</p>
<div class="igBar"><span id="lphp-19"><a href="#" onclick="javascript:showCodeTxt('php-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-19">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$html</span>-&gt;<span style="color:#006600;">link</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"トップ"</span> , <span style="color:#FF0000;">"/top"</span>,<a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"target"</span>=&gt;<span style="color:#FF0000;">"_blank"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
このタグもハッシュで属性を追加できます。この場合はtarget="_blank"が追加されます。</p>
<h3>画像でのリンク</h3>
<div class="igBar"><span id="lphp-20"><a href="#" onclick="javascript:showCodeTxt('php-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-20">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$html</span>-&gt;<span style="color:#006600;">link</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$html</span>-&gt;<span style="color:#006600;">image</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"/logo.gif"</span>,<a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"id"</span>=&gt;<span style="color:#FF0000;">"logo"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>,<span style="color:#FF0000;">"/top"</span>,<span style="color:#000000; font-weight:bold;">false</span>,<span style="color:#000000; font-weight:bold;">false</span>,<span style="color:#000000; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
画像でのリンクは画像とリンクのタグを組み合わせるとできます。後半にfalseが3つも並んでいて無駄に見えますがこれは必要なので書くようにしてください。</p>
<h2>まとめ</h2>
<p>この他にもフォームを書くときなども専用のコードを書く必要があります。面倒くさいですね・・・</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/156/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>デザイナーのためのCakePHP入門</title>
		<link>http://www.jamboree.jp/cms/archives/139</link>
		<comments>http://www.jamboree.jp/cms/archives/139#comments</comments>
		<pubDate>Fri, 02 May 2008 01:57:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/archives/139</guid>
		<description><![CDATA[対象 プログラマがCakePHP(1.2)を押し付けてきてひどい目に遭っているコーディング担当用 PHPが< ?phpで始まり、?>で終わるということぐらいは知っているということにします。 拡張子 CakePHPで使われるデザインが書かれたファイル（以下テンプレート）の拡張子は.thtmlと.ctpがあります。.htmlだったら便利なんですけどね。プログラマからの嫌がらせだと思ってください。 Dreamweaver CS3で.thtml(CakePHP)の拡張子を編集できるようにするTIPS (what a bringdown) STUDIO KINGDOM Blog � DreamWeaverでCakePHP開発を行う際の設定(.thtml) 編集すべきファイルの場所 ファイルは/app/viewsとかにあります。さすがにこの場所はプログラマに教えてもらいましょう。(プロジェクトによっては場所が違いますので） テンプレート・・・/app/views/* スタイルシート･･･/app/webroot/css 画像・・・/app/webroot/img Javascript・・・/app/webroot/js webrootにおいては上記の4つのディレクトリ以外は基本的に自由にファイルを配置したりディレクトリを作っても大丈夫です。ただし画像やスタイルシートを上記の4つ以外に入れたいという場合はプログラマに相談してください。 テンプレートの編集 ここからは/app/views以下のテンプレートの編集の話です。CakePHPでは１つのページをいくつかのテンプレートを組み合わせて表示させています。 使われるのは「レイアウト」「メインのテンプレート（コンテント）」「エレメント」の３つです。 DreamWeaver使いの人なら ・レイアウト = テンプレートファイル ・コンテント = 普通のファイル ・エレメント = ユーティリティー と考えてもらっていいと思います。 レイアウト /app/views/layoutというディレクトリがあると思います。ここにはレイアウトファイルといってテンプレートの大枠部分が入っています。ヘッダやフッタ部分ですね。 エレメント /app/views/elementsというディレクトリには各ページで共通のパーツが入っています。メインメニューや、カレンダーなどの表示部分をココに入れておくことが多いです。 helpers,scaffolds,errors この３つは最初から用意されているディレクトリですので無視して大丈夫です。 それ以外 普通のページ用のテンプレートです。ブログでいうなら記事の表示部分に相当します。 どのファイルを編集すればいいのか どのページがどのファイルかわからない場合は、編集したいページのURLをみてみてください。 http://example.com/users/edit/1 だった場合は http://example.com/フォルダ名/ファイル名.ctp/1 ということになります。今回の場合は /app/views/users/edit.ctp(もしくはedit.thtml)を編集するということです。 たまに違う場合もありますが、フォルダも違うということは滅多にないと思うので同じフォルダのそれっぽい名前のファイルを開いてみてください。 まとめ これでCakePHPを使った開発の概要がわかってもらえたかと思います。なんだか素朴にPHPを編集していたときと比べるとかなり違っていますが、レイアウトやエレメントは使いこなすことでデザイナーの人にもメリットがある仕組みだと思います。次回は具体的なソースの編集Tipsなどを書く予定です。]]></description>
			<content:encoded><![CDATA[<h2>対象</h2>
<p>プログラマがCakePHP(1.2)を押し付けてきてひどい目に遭っているコーディング担当用<br />
PHPが< ?phpで始まり、?>で終わるということぐらいは知っているということにします。</p>
<h2>拡張子</h2>
<p>CakePHPで使われるデザインが書かれたファイル（以下テンプレート）の拡張子は.thtmlと.ctpがあります。.htmlだったら便利なんですけどね。プログラマからの嫌がらせだと思ってください。<br />
<a href="http://dflatt.org/eric/2007/09/dreamweaver_cs3thtmlcakephptip.html">Dreamweaver CS3で.thtml(CakePHP)の拡張子を編集できるようにするTIPS (what a bringdown)</a><br />
<a href="http://www.studio-kingdom.com/blog/cakephp/54">STUDIO KINGDOM Blog � DreamWeaverでCakePHP開発を行う際の設定(.thtml)</a></p>
<h2>編集すべきファイルの場所</h2>
<p>ファイルは/app/viewsとかにあります。さすがにこの場所はプログラマに教えてもらいましょう。(プロジェクトによっては場所が違いますので）</p>
<p>テンプレート・・・/app/views/*<br />
スタイルシート･･･/app/webroot/css<br />
画像・・・/app/webroot/img<br />
Javascript・・・/app/webroot/js</p>
<p>webrootにおいては上記の4つのディレクトリ以外は基本的に自由にファイルを配置したりディレクトリを作っても大丈夫です。ただし画像やスタイルシートを上記の4つ以外に入れたいという場合はプログラマに相談してください。</p>
<h2>テンプレートの編集</h2>
<p><img src='http://www.jamboree.jp/cms/wp-content/uploads/2008/04/view.gif' alt='view.gif' /><br />
ここからは/app/views以下のテンプレートの編集の話です。CakePHPでは１つのページをいくつかのテンプレートを組み合わせて表示させています。<br />
使われるのは「レイアウト」「メインのテンプレート（コンテント）」「エレメント」の３つです。<br />
DreamWeaver使いの人なら<br />
・レイアウト = テンプレートファイル<br />
・コンテント = 普通のファイル<br />
・エレメント = ユーティリティー<br />
と考えてもらっていいと思います。</p>
<h3>レイアウト</h3>
<p>/app/views/layoutというディレクトリがあると思います。ここにはレイアウトファイルといってテンプレートの大枠部分が入っています。ヘッダやフッタ部分ですね。</p>
<h3>エレメント</h3>
<p>/app/views/elementsというディレクトリには各ページで共通のパーツが入っています。メインメニューや、カレンダーなどの表示部分をココに入れておくことが多いです。</p>
<h3>helpers,scaffolds,errors</h3>
<p>この３つは最初から用意されているディレクトリですので無視して大丈夫です。</p>
<h3>それ以外</h3>
<p>普通のページ用のテンプレートです。ブログでいうなら記事の表示部分に相当します。</p>
<h2>どのファイルを編集すればいいのか</h2>
<p>どのページがどのファイルかわからない場合は、編集したいページのURLをみてみてください。</p>
<p>http://example.com/users/edit/1</p>
<p>だった場合は</p>
<p>http://example.com/フォルダ名/ファイル名.ctp/1</p>
<p>ということになります。今回の場合は<br />
/app/views/users/edit.ctp(もしくはedit.thtml)を編集するということです。<br />
たまに違う場合もありますが、フォルダも違うということは滅多にないと思うので同じフォルダのそれっぽい名前のファイルを開いてみてください。</p>
<h2>まとめ</h2>
<p>これでCakePHPを使った開発の概要がわかってもらえたかと思います。なんだか素朴にPHPを編集していたときと比べるとかなり違っていますが、レイアウトやエレメントは使いこなすことでデザイナーの人にもメリットがある仕組みだと思います。次回は具体的なソースの編集Tipsなどを書く予定です。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/139/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CakePHPで検索機能の実装を少し楽する</title>
		<link>http://www.jamboree.jp/cms/archives/138</link>
		<comments>http://www.jamboree.jp/cms/archives/138#comments</comments>
		<pubDate>Tue, 22 Apr 2008 14:40:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[今日のコード]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/archives/138</guid>
		<description><![CDATA[検索 ページング ソート この３つさえなければ僕はWebアプリが大好きです。 CakePHP1.2での簡単なやり方 CakePHP1.2ならLIKE文なんかをある程度作ってくれるのでWHER 1=1 AND...とか書かなくてOKで少しうれしいです。 コード usernameとpasswordが入ったUserモデルとuser_idとかnameとかname_ruby,tel_mobileとかが入ったProfileモデルに対してAND検索をする例。 /admin_index.ctp PLAIN TEXT PHP: &#60;h2&#62;ユーザの検索&#60;/h2&#62; &#60;form action="&#60;?php echo $html-&#62;url('/admin/users/index'); ?&#62;" method="get"&#62; &#60;table&#62; &#160; &#160; &#60;tr&#62; &#160; &#160; &#160; &#160; &#60;th width="20%"&#62;ログインID&#60;/th&#62; &#160; &#160; &#160; &#160; &#60;td&#62; &#160; &#160; &#160; &#160; &#160; &#160; &#60;?php echo $form-&#62;input&#40;'Words/username', array&#40;'size' =&#62; '20','label'=&#62;false&#41;&#41;;?&#62; &#160; &#160; &#160; &#160; &#60;/td&#62; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>検索</li>
<li>ページング</li>
<li>ソート</li>
</ul>
<p>この３つさえなければ僕はWebアプリが大好きです。</p>
<h2>CakePHP1.2での簡単なやり方</h2>
<p>CakePHP1.2ならLIKE文なんかをある程度作ってくれるのでWHER 1=1 AND...とか書かなくてOKで少しうれしいです。</p>
<h2>コード</h2>
<p>usernameとpasswordが入ったUserモデルとuser_idとかnameとかname_ruby,tel_mobileとかが入ったProfileモデルに対してAND検索をする例。</p>
<p>/admin_index.ctp</p>
<div class="igBar"><span id="lphp-23"><a href="#" onclick="javascript:showCodeTxt('php-23'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-23">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;h2&gt;ユーザの検索&lt;/h2&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;form action=<span style="color:#FF0000;">"&lt;?php echo $html-&gt;url('/admin/users/index'); ?&gt;"</span> method=<span style="color:#FF0000;">"get"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;table&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;tr&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;th width=<span style="color:#FF0000;">"20%"</span>&gt;ログインID&lt;/th&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">input</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Words/username'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'size'</span> =&gt; <span style="color:#FF0000;">'20'</span>,<span style="color:#FF0000;">'label'</span>=&gt;false<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/tr&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;tr&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;名前&lt;/th&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">input</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Words/name'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'size'</span> =&gt; <span style="color:#FF0000;">'30'</span>,<span style="color:#FF0000;">'label'</span>=&gt;false<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/tr&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;tr&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;フリガナ&lt;/th&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">input</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Words/name_ruby'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'size'</span> =&gt; <span style="color:#FF0000;">'30'</span>,<span style="color:#FF0000;">'label'</span>=&gt;false<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/tr&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;tr&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;携帯電話番号&lt;/th&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">input</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Words/tel_mobile'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'size'</span> =&gt; <span style="color:#FF0000;">'15'</span>,<span style="color:#FF0000;">'label'</span>=&gt;false<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/tr&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/table&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">submit</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'検索'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>/users_controller.php</p>
<div class="igBar"><span id="lphp-24"><a href="#" onclick="javascript:showCodeTxt('php-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-24">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> admin_index<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//検索ワードがあるかどうか</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$conditions</span> = <span style="color:#000000; font-weight:bold;">null</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'url'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'data'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'Words'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'Words'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'url'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'data'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'Words'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$like</span> = <span style="color:#0000FF;">$this</span>-&gt;_create_like_conditions<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">params</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'url'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'data'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'Words'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$conditions</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'and'</span> =&gt; <span style="color:#0000FF;">$like</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">User</span>-&gt;<span style="color:#006600;">recursive</span> = <span style="color:#CC66CC;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">set</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'users'</span>, <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">paginate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$conditions</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> _create_like_conditions<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$data</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$like</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$data</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$k</span>=&gt;<span style="color:#0000FF;">$v</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$like</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$k</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#FF0000;">'like %'</span>.<span style="color:#0000FF;">$v</span>.<span style="color:#FF0000;">'%'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$like</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h2>まとめ</h2>
<p>likeのところは、or,not,in,between,regexp,<>にも対応しています。また今回はand検索でしたがもちろんorでもいけます。</p>
<p>みんなには嫌われているけど現場では他に選択肢がないため大活躍なジャックバウワーのような存在「PHP＋CakePHP」、今日も助かったよ！</p></form>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/138/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CakePHP::ユニークな値かどうかチェック（重複チェック）</title>
		<link>http://www.jamboree.jp/cms/archives/133</link>
		<comments>http://www.jamboree.jp/cms/archives/133#comments</comments>
		<pubDate>Mon, 14 Apr 2008 17:52:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/archives/133</guid>
		<description><![CDATA[ユーザIDなど重複したら困る時のチェック。よく使うのでメモ MySQLの場合は、DBのuniqueを使ったスマートな方法もあります。 コード /model/user.php PLAIN TEXT PHP: function unique&#40;$field&#41;&#123; &#160; &#160;&#160; &#160; foreach&#40; $field as $key =&#62; $value &#41;&#123; &#160; &#160;&#160; &#160; &#160; &#160; $this-&#62;recursive = -1; &#160; &#160;&#160; &#160; &#160; &#160; $found = $this-&#62;find&#40;array&#40;"{$this-&#62;name}.$key" =&#62; $value&#41;&#41;; &#160; &#160;&#160; &#160; &#160;&#125; &#160; &#160;&#160; &#160; &#160; &#160; return !$found; &#160; &#160; &#125; /controller/user_controller.php PLAIN TEXT PHP: [...]]]></description>
			<content:encoded><![CDATA[<p>ユーザIDなど重複したら困る時のチェック。よく使うのでメモ<br />
MySQLの場合は、<a href="http://cakephp.jp/modules/newbb/viewtopic.php?topic_id=761&#038;forum=6&#038;post_id=1414#forumpost1414">DBのuniqueを使ったスマートな方法</a>もあります。</p>
<h2>コード</h2>
<p>/model/user.php</p>
<div class="igBar"><span id="lphp-28"><a href="#" onclick="javascript:showCodeTxt('php-28'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-28">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> unique<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$field</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#616100;">foreach</span><span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#0000FF;">$field</span> <span style="color:#616100;">as</span> <span style="color:#0000FF;">$key</span> =&gt; <span style="color:#0000FF;">$value</span> <span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">recursive</span> = -<span style="color:#CC66CC;color:#800000;">1</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$found</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"{$this-&gt;name}.$key"</span> =&gt; <span style="color:#0000FF;">$value</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> !<span style="color:#0000FF;">$found</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
/controller/user_controller.php</p>
<div class="igBar"><span id="lphp-29"><a href="#" onclick="javascript:showCodeTxt('php-29'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-29">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//省略 addメソッドとか</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'User'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'username'</span><span style="color:#006600; font-weight:bold;">&#93;</span> &amp;&amp; !<span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">User</span>-&gt;<span style="color:#006600;">unique</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"username"</span> =&gt; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">data</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'User'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'username'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">User</span>-&gt;<span style="color:#006600;">invalidate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"unique"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">User</span>-&gt;<span style="color:#006600;">save</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">data</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//・・・以下省略 </span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
/view/user/add.ctp</p>
<div class="igBar"><span id="lphp-30"><a href="#" onclick="javascript:showCodeTxt('php-30'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-30">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;td width=<span style="color:#FF0000;">"65%"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">input</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'User/username'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'label'</span> =&gt; <span style="color:#000000; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$form</span>-&gt;<span style="color:#006600;">error</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'User/unique'</span>, <span style="color:#FF0000;">'このIDはすでに使用されています。'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;?&gt;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/td&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/133/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP1.2での管理者用レイアウト設定</title>
		<link>http://www.jamboree.jp/cms/archives/132</link>
		<comments>http://www.jamboree.jp/cms/archives/132#comments</comments>
		<pubDate>Mon, 14 Apr 2008 09:31:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[今日のコード]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/archives/132</guid>
		<description><![CDATA[admin routingを使っていて、adminの時だけ別のレイアウトを設定したい場合。 こうやってみればいいんじゃないかという例 コード PLAIN TEXT PHP: &#60;?php //app/app_controller.php class AppController extends Controller &#123; &#160; &#160; function beforeRender&#40;&#41; &#123; &#160; &#160; &#160; &#160; echo $this-&#62;action; &#160; &#160; &#160; &#160; if &#40;preg_match&#40;"/^" . Configure::read&#40;'Routing.admin'&#41;&#160; . "_/i", $this-&#62;action&#41;&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; $this-&#62;layout = 'admin_default'; &#160; &#160; &#160; &#160; &#125; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>admin routingを使っていて、adminの時だけ別のレイアウトを設定したい場合。<br />
こうやってみればいいんじゃないかという例</p>
<h2>コード</h2>
<div class="igBar"><span id="lphp-32"><a href="#" onclick="javascript:showCodeTxt('php-32'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-32">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//app/app_controller.php</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> AppController extends Controller <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> beforeRender<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">action</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/preg_match"><span style="color:#000066;">preg_match</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"/^"</span> . Configure::<span style="color:#006600;">read</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Routing.admin'</span><span style="color:#006600; font-weight:bold;">&#41;</span>&nbsp; . <span style="color:#FF0000;">"_/i"</span>, <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">action</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">layout</span> = <span style="color:#FF0000;">'admin_default'</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h2>まとめ</h2>
<p>他のやり方ってあるのかな？知りたいです。<br />
あと、管理者用とユーザ用のコントローラを分けたいときにRailsのようにcontrollers/admin/user_controller.phpみたいにディレクトリを切りたいんだけど、それもやり方を知りたい。今はadmin_user_controller.phpとかを作っているけどカッコ悪い</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/132/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP::HABTMの編集画面を作る</title>
		<link>http://www.jamboree.jp/cms/archives/98</link>
		<comments>http://www.jamboree.jp/cms/archives/98#comments</comments>
		<pubDate>Wed, 13 Feb 2008 03:48:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.jamboree.jp/cms/archives/98</guid>
		<description><![CDATA[CakePHP1.1の話。ほかのやり方があったら教えて欲しいです。ちょっと面倒。 目的 CakePHPのブログチュートリアルのようにエントリーに複数のタグをつけるような場合で &#60;?php echo $habtm-&#62;checkboxMultiple('Tag/Tag', $tags, $selected_tags, array('multiple' =&#62; 'multiple')) ?&#62; こうやって書いたら、チェックボックスでタグがダラダラーとでてきて、もちろん選択済みのものが選択されている状態を作るのが目的。 選択済みのタグのリストを作る shepherdweb 上記サイトのとおりにやってください！ セレクトボックスをやめてチェックボックスにする Create Multiple Checkboxes Instead of a Multiple-Select in your Views 上記サイトのとおりにやってください！（habtmヘルパーをインクルードするのを忘れずに） 以上]]></description>
			<content:encoded><![CDATA[<p>CakePHP1.1の話。ほかのやり方があったら教えて欲しいです。ちょっと面倒。</p>
<h2>目的</h2>
<p>CakePHPのブログチュートリアルのようにエントリーに複数のタグをつけるような場合で</p>
<pre class="php">&lt;?php <span class="func" >echo</span> <span class="vars" >$habtm</span>-&gt;checkboxMultiple(<span class="string" >'Tag/Tag'</span>, <span class="vars" >$tags</span>, <span class="vars" >$selected_tags</span>, <span class="keyword" >array</span>(<span class="string" >'multiple'</span> =&gt; <span class="string" >'multiple'</span>)) ?&gt;</pre>
<p>こうやって書いたら、チェックボックスでタグがダラダラーとでてきて、もちろん選択済みのものが選択されている状態を作るのが目的。</p>
<h2>選択済みのタグのリストを作る</h2>
<p><a href="http://shepherdweb.com/2006/08/21/editing-hasandbelongstomany-habtm-relationships-in-cakephp/">shepherdweb</a><br />
上記サイトのとおりにやってください！</p>
<h2>セレクトボックスをやめてチェックボックスにする</h2>
<p><a href="http://bakery.cakephp.org/articles/view/create-multiple-checkboxes-instead-of-a-multiple-select-in-your-views">Create Multiple Checkboxes Instead of a Multiple-Select in your Views</a><br />
上記サイトのとおりにやってください！（habtmヘルパーをインクルードするのを忘れずに）</p>
<p>以上</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamboree.jp/cms/archives/98/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

