<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>CODE - NEO-SHOCKER.COM</title>
    <link rel="alternate" type="text/html" href="http://code.neo-shocker.com/" />
    <link rel="self" type="application/atom+xml" href="http://code.neo-shocker.com/rss/atom.xml" />
    <id>tag:code.neo-shocker.com,2009-12-12://4</id>
    <updated>2010-07-15T19:14:37Z</updated>
    
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 5.02</generator>

<entry>
    <title>MT：変数と変数の比較</title>
    <link rel="alternate" type="text/html" href="http://code.neo-shocker.com/2010/07/mt-comparison-variable-variable.html" />
    <id>tag:code.neo-shocker.com,2010://4.428</id>

    <published>2010-07-15T13:30:00Z</published>
    <updated>2010-07-15T19:14:37Z</updated>

    <summary>MTIf で変数と変数で比較を行い条件分岐を行う場合、eq=、ne=、like=...</summary>
    <author>
        <name>Takahiro.</name>
        <uri>http://neo-shocker.com/</uri>
    </author>
    
    <category term="movabletype" label="Movable Type" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://code.neo-shocker.com/">
        <![CDATA[<p>MTIf で変数と変数で比較を行い条件分岐を行う場合、eq=、ne=、like= 等で指定する比較対象の変数の頭に「$」を追加します。例：eq=&quot;$foo&quot;</p>

<MTPrecode>&lt;MTIf name=&quot;hoge&quot; eq=&quot;$foo&quot;&gt;
<em>hoge</em> と <em>foo</em> が一致した場合の処理
&lt;/MTIf&gt;</MTPrecode>]]>
        
    </content>
</entry>

<entry>
    <title>html ファイル内で php スクリプトを動作させる #2</title>
    <link rel="alternate" type="text/html" href="http://code.neo-shocker.com/2010/07/html-include-php-2nd.html" />
    <id>tag:code.neo-shocker.com,2010://4.425</id>

    <published>2010-07-11T13:00:00Z</published>
    <updated>2010-07-11T17:10:05Z</updated>

    <summary>html 拡張子のファイルに .htaccess を使って PHP を実行する方...</summary>
    <author>
        <name>Takahiro.</name>
        <uri>http://neo-shocker.com/</uri>
    </author>
    
    <category term="htaccess" label="htaccess" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://code.neo-shocker.com/">
        <![CDATA[<p>html 拡張子のファイルに .htaccess を使って PHP を実行する方法です。
たいして小難しい事を実践していませんが、テキストファイルを html へ include する場合には便利かもしれまんせん。</p>

<p>.htaccess への記述方法は、サーバによって異なりますので、以下のうち動く方を書いてください。</p>

<MTPrecode>AddType application/x-httpd-php .html
AddHandler php-script .html</MTPrecode>

<p>あとは、PHP を実行したい位置へ</p>

<MTPrecode>&lt;?php include(&quot;sample.txt&quot;); ?&gt;</MTPrecode>

<p>といった感じで PHP を記述し、Web サーバへアップロードし、上記の例の場合、埋め込んだテキストファイルが表示されていれば完了です。</p>

<p>もし、文字化けが発生する場合は、html と埋め込むファイルの文字コードを合わせるか、html のどこかに以下の様な文字コードを追加してやります。</p>

<MTPrecode>&lt;?php header(&quot;Content-Type: text/html;charset=SJIS&quot;);?&gt;</MTPrecode>

<p>それでも色々不具合が出る場合は、とあるサーバの例ですが .htaccess を以下の様にします。</p>

<MTPrecode>AddType application/x-httpd-php .html
php_flag mbstring.encoding_translation off
php_value default_charset "UTF-8"</MTPrecode>

<p>文字コードを全て統一していれば、最初の一行だけ大体は片付くとは思いますが、もし、文字コードが不揃いの場合は、charset を色々変更してみてください。</p>]]>
        
    </content>
</entry>

<entry>
    <title>body タグ以外で onload を使用する</title>
    <link rel="alternate" type="text/html" href="http://code.neo-shocker.com/2010/06/onload-event-other-body.html" />
    <id>tag:code.neo-shocker.com,2010://4.418</id>

    <published>2010-06-18T14:00:00Z</published>
    <updated>2010-06-23T18:06:44Z</updated>

    <summary>Dreamweaver 等の Generator で JavaScript 埋め...</summary>
    <author>
        <name>Takahiro.</name>
        <uri>http://neo-shocker.com/</uri>
    </author>
    
    <category term="javascrip" label="JavaScrip" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://code.neo-shocker.com/">
        <![CDATA[<p>Dreamweaver 等の Generator で JavaScript 埋め込んだ場合、body タグに onload でイベントをコールする場合があります。また、body タグに onload を行うと他の Script に悪影響を及ぼす事もあります。</p>

<p>そうした場合、&lt;body&gt; 〜 &lt;/body&gt; の間で onload で実行したい箇所に以下の様に Script を記述する事で、body タグで onload 同様に Script を走らせる事が出来ます。</p>

<MTPrecode>&lt;script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;&gt;
&lt;!--
window.onload = function(){実行したい内容}
//--&gt;
&lt;/script&gt;</MTPrecode>]]>
        
    </content>
</entry>

<entry>
    <title>カテゴリに属するブログ記事の1件目のリンクを取得</title>
    <link rel="alternate" type="text/html" href="http://code.neo-shocker.com/2010/06/get-category-1st-entry-permalink.html" />
    <id>tag:code.neo-shocker.com,2010://4.414</id>

    <published>2010-06-11T06:00:00Z</published>
    <updated>2010-06-11T06:13:32Z</updated>

    <summary>カテゴリに属するブログ記事の1件目のパーマリンクを取得して、ページメニューのリン...</summary>
    <author>
        <name>Takahiro.</name>
        <uri>http://neo-shocker.com/</uri>
    </author>
    
    <category term="movabletype" label="Movable Type" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://code.neo-shocker.com/">
        <![CDATA[<p>カテゴリに属するブログ記事の1件目のパーマリンクを取得して、ページメニューのリンクを最新記事へのリンクにします。<br />
MTCategoryCount でカテゴリに記事が何件あるかカウントし、0件でない場合に mt:Entries ～でパーマリンクを取得して、カテゴリラベルへ記事のパーマリンクを設定します。<p>

<MTPrecode>&lt;mt:Categories&gt;
&lt;mt:SetVarBlock name=&quot;cat_cnt&quot;&gt;&lt;$MTCategoryCount$&gt;&lt;/mt:SetVarBlock&gt;
&lt;mt:If name=&quot;cat_cnt&quot; ne=&quot;0&quot;&gt;
&lt;mt:Entries lastn=&quot;1&quot;&gt;&lt;a href=&quot;&lt;$mt:EntryPermalink$&gt;&quot;&gt;&lt;$mt:CategoryLabel$&gt;&lt;/a&gt;&lt;/mt:Entries&gt;
&lt;mt:Else&gt;
記事が無い場合の処理
&lt;/mt:If&gt;
&lt;/mt:Categories&gt;</MTPrecode>

<p>サブカテゴリの記事の場合は、mt:SubCategories で行います。</p>

<MTPrecode>&lt;mt:SubCategories category=&quot;parent_category&quot;&gt;
&lt;mt:SetVarBlock name=&quot;cat_cnt&quot;&gt;&lt;$MTCategoryCount$&gt;&lt;/mt:SetVarBlock&gt;
&lt;mt:If name=&quot;cat_cnt&quot; ne=&quot;0&quot;&gt;
&lt;mt:Entries lastn=&quot;1&quot;&gt;&lt;a href=&quot;&lt;$mt:EntryPermalink$&gt;&quot;&gt;&lt;$mt:CategoryLabel$&gt;&lt;/a&gt;&lt;/mt:Entries&gt;
&lt;mt:Else&gt;
記事が無い場合の処理
&lt;/mt:If&gt;
&lt;/mt:SubCategories&gt;</MTPrecode>

<p>使いどころはあるのか疑問ですが。</p>]]>
        
    </content>
</entry>

<entry>
    <title>HTML5 Video で複数のソースを指定する</title>
    <link rel="alternate" type="text/html" href="http://code.neo-shocker.com/2010/05/html5-video-element-multiple-source.html" />
    <id>tag:code.neo-shocker.com,2010://4.400</id>

    <published>2010-05-07T13:00:00Z</published>
    <updated>2010-05-07T17:38:03Z</updated>

    <summary>HTML5 の Video Element で、以下の様にする事で複数のソースフ...</summary>
    <author>
        <name>Takahiro.</name>
        <uri>http://neo-shocker.com/</uri>
    </author>
    
    <category term="html" label="html" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://code.neo-shocker.com/">
        <![CDATA[<p>HTML5 の Video Element で、以下の様にする事で複数のソースファイルを読み込みが可能。</p>

<MTPrecode>&lt;video controls=&quot;controls&quot;&gt;<br />
&lt;source src=&quot;http://robertnyman.com/video/swedish-flag.mp4&quot;&gt;<br />
&lt;source src=&quot;http://robertnyman.com/video/swedish-flag.ogv&quot;&gt;<br />
&lt;p&gt;Sorry, your web browser doesn't support the video element&lt;/p&gt;<br />
&lt;/video&gt;</MTPrecode>

<p><a href="http://robertnyman.com/2010/01/25/the-video-element-in-html5-great-possibilites-but-also-codec-and-licensing-problems/" target="_blank">The video element in HTML5 &#8211; great possibilities, but also codec and licensing problems - Robert&#039;s talk</a><br />
<a href="http://robertnyman.com/html5/video/video-demo.html" target="_blank">Video Demo</a></p>]]>
        
    </content>
</entry>

<entry>
    <title>ワイヤレスゼロ構成サービスの開始</title>
    <link rel="alternate" type="text/html" href="http://code.neo-shocker.com/2010/05/cmd-start-wireless-zero-config.html" />
    <id>tag:code.neo-shocker.com,2010://4.398</id>

    <published>2010-05-05T13:00:00Z</published>
    <updated>2010-06-17T19:02:48Z</updated>

    <summary>無線 LAN でネットに接続する際、ネットワーク一覧を開いたら「ワイヤレスゼロ構...</summary>
    <author>
        <name>Takahiro.</name>
        <uri>http://neo-shocker.com/</uri>
    </author>
    
    <category term="commandprompt" label="Command Prompt" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://code.neo-shocker.com/">
        <![CDATA[<p>無線 LAN でネットに接続する際、ネットワーク一覧を開いたら「ワイヤレスゼロ構成サービスを開始してください」と表示されていた場合、コマンドプロンプトから以下のコマンドを実行すると、ワイヤレスゼロ構成サービスが開始されます。</p>

<p><MTPrecode>net start wzcsvc</MTPrecode></p>

<p>ただ、ワイヤレスゼロ構成サービスが開始されていない PC でコマンドを実行しても、再起動すると自動的にサービスが開始されないので、ネットワークとサービスの設定を下記ページの様に変更すると、以降 Windows 起動時にワイヤレスゼロ構成サービスが自動的に開始されます。</p>

<p><a href="http://support.microsoft.com/kb/884239/ja" target="_blank">Windows XP におけるワイヤレス ネットワークのトラブルに関する対処方法</a></p>]]>
        
    </content>
</entry>

<entry>
    <title>MT：ブログ記事のカテゴリを取得</title>
    <link rel="alternate" type="text/html" href="http://code.neo-shocker.com/2010/04/mt-entry-post-get-categories.html" />
    <id>tag:code.neo-shocker.com,2010://4.379</id>

    <published>2010-04-02T06:00:00Z</published>
    <updated>2010-04-02T06:36:30Z</updated>

    <summary>アーカイブテンプレートのブログ記事で、投稿されたブログ記事の属するカテゴリを取得...</summary>
    <author>
        <name>Takahiro.</name>
        <uri>http://neo-shocker.com/</uri>
    </author>
    
    <category term="movabletype" label="Movable Type" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://code.neo-shocker.com/">
        <![CDATA[<p>アーカイブテンプレートのブログ記事で、投稿されたブログ記事の属するカテゴリを取得。</p>

<p><MTPrecode>&lt;MTEntryCategories&gt;<br />
&lt;$MTCategoryBasename$&gt;<br />
&lt;$MTCategoryLabel$&gt;<br />
&lt;/MTEntryCategories&gt;</MTPrecode></p>

<p>「&lt;$MTCategoryBasename$&gt;」でカテゴリのファイル名、「&lt;$MTCategoryLabel$&gt;」でカテゴリ名を取得します。</p>]]>
        
    </content>
</entry>

<entry>
    <title>MT：フォルダ毎で表示する内容を変更する</title>
    <link rel="alternate" type="text/html" href="http://code.neo-shocker.com/2010/03/mt-displayed-change-folder.html" />
    <id>tag:code.neo-shocker.com,2010://4.368</id>

    <published>2010-03-08T13:00:00Z</published>
    <updated>2010-03-08T19:03:21Z</updated>

    <summary>Movable Type でフォルダ（トップレベルフォルダ）毎にサイドバーの表示...</summary>
    <author>
        <name>Takahiro.</name>
        <uri>http://neo-shocker.com/</uri>
    </author>
    
    <category term="movabletype" label="Movable Type" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://code.neo-shocker.com/">
        <![CDATA[<p>Movable Type でフォルダ（トップレベルフォルダ）毎にサイドバーの表示を変更するといった場合「MTFolderBasename」をブロックタグ「MTSetVarBlock」で括り、値を取得します。</p>

<p><MTPrecode>&lt;MTSetVarBlock name=&quot;folder_name&quot;&gt;<br />
    &lt;MTTopLevelFolder&gt;&lt;$MTFolderBasename$&gt;&lt;/MTTopLevelFolder&gt;<br />
&lt;/MTSetVarBlock&gt;</MTPrecode></p>

<p>次に「MTIf」で、先のブロックタグで取得した値を「name」で呼び出し、呼び出した値が「eq」と一致するかを判断します。</p>

<p><MTPrecode>&lt;MTIf name=&quot;folder_name&quot; eq=&quot;folder1&quot;&gt;</MTPrecode></p>

<p>「name」で取得した値が「eq」と一致した場合は上記構文の下に記述した内容を表示します。<br />
もし違う場合は、同様に「MTElseIf」で「eq」に一致するかを判断します。</p>

<p><MTPrecode>&lt;MTElseIf eq=&quot;folder2&quot;&gt;</MTPrecode></p>

<p>「name」が「eq」と一致する場合は、上記構文の下に記述した内容を表示します。</p>

<p>後は、必要な分だけ「MTElseIf」を繰り返していくと、フォルダ毎に表示する内容を変更する事が出来ます。</p>

<p>纏めると以下の様になります。</p>

<p><MTPrecode>&lt;MTSetVarBlock name=&quot;folder_name&quot;&gt;<br />
    &lt;MTTopLevelFolder&gt;&lt;$MTFolderBasename$&gt;&lt;/MTTopLevelFolder&gt;<br />
&lt;/MTSetVarBlock&gt;<br />
&lt;MTIf name=&quot;folder_name&quot; eq=&quot;folder1&quot;&gt;<br />
    folder1 の内容<br />
&lt;MTElseIf eq=&quot;folder2&quot;&gt;<br />
    folder2 の内容<br />
&lt;MTElseIf eq=&quot;folder3&quot;&gt;<br />
    folder3 の内容<br />
&lt;/MTIf&gt;</MTPrecode></p>

<p>また「eq」の代わりに「like」を使用して、name に like="xxx" が含まれる場合という指定も可能で</p>

<p><MTPrecode>&lt;MTSetVarBlock name=&quot;folder_name&quot;&gt;<br />
    &lt;MTTopLevelFolder&gt;&lt;$MTFolderBasename$&gt;&lt;/MTTopLevelFolder&gt;<br />
&lt;/MTSetVarBlock&gt;<br />
&lt;MTIf name=&quot;folder_name&quot; like=&quot;folder&quot;&gt;<br />
    folder1、folder2、folder3 の内容<br />
&lt;MTElseIf like=&quot;directory&quot;&gt;<br />
    directory1、directory2、directory3 の内容<br />
&lt;/MTIf&gt;</MTPrecode></p>

<p>と指定すると、folder1 〜 folder3、directory1 〜 directory3 までが同じ内容が表示されます。</p>

<p><a href="http://www.movabletype.jp/documentation/appendices/tags/setvarblock.html" target="_blank">MTSetVarBlock｜テンプレートタグリファレンス</a><br />
<a href="http://www.movabletype.jp/documentation/appendices/tags/if.html" target="_blank">MTIf｜テンプレートタグリファレンス</a><br />
<a href="http://www.movabletype.jp/documentation/appendices/tags/elseif.html" target="_blank">MTElse｜テンプレートタグリファレンス</a></p>]]>
        
    </content>
</entry>

<entry>
    <title>アンダースコアハック</title>
    <link rel="alternate" type="text/html" href="http://code.neo-shocker.com/2010/02/underscore-hack.html" />
    <id>tag:code.neo-shocker.com,2010://4.361</id>

    <published>2010-02-21T14:00:00Z</published>
    <updated>2010-03-08T19:14:59Z</updated>

    <summary>Windows Internet Explorer 6 に適用する場合、プロパテ...</summary>
    <author>
        <name>Takahiro.</name>
        <uri>http://neo-shocker.com/</uri>
    </author>
    
    <category term="css" label="CSS" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://code.neo-shocker.com/">
        <![CDATA[<p>Windows Internet Explorer 6 に適用する場合、プロパティの前に「 _ 」を追加する事で、IE6 のみにアンダースコアで指定した値を適用する。<br />
ただし、W3C CSS Validator ではエラーになります。</p>

<p><MTPrecode>.hoge {<br />
    width: 500px;    /* IE6 以外 */<br />
    _width: 400px;    /* IE6 */<br />
}</MTPrecode></p>

<p>※ アンダースコアで指定した値は、必ず下に書き、後から読み込む様にします。</p>]]>
        
    </content>
</entry>

<entry>
    <title>html ファイル内で php スクリプトを動作させる</title>
    <link rel="alternate" type="text/html" href="http://code.neo-shocker.com/2010/02/html-include-php.html" />
    <id>tag:code.neo-shocker.com,2010://4.357</id>

    <published>2010-02-16T14:00:00Z</published>
    <updated>2010-03-08T19:18:28Z</updated>

    <summary>html ファイル内で php スクリプトを動作させる場合 .htaccess ...</summary>
    <author>
        <name>Takahiro.</name>
        <uri>http://neo-shocker.com/</uri>
    </author>
    
    <category term="htaccess" label="htaccess" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://code.neo-shocker.com/">
        <![CDATA[<p>html ファイル内で php スクリプトを動作させる場合 .htaccess に以下の記述をします。<br />
対象を .html だけにする場合は、.htm を削除します。</p>

<MTPrecode>AddType application/x-httpd-php .html .htm</MTPrecode>

<p>また、サーバによっては以下の様にする場合もあります。</p>

<MTPrecode>AddHandler php-script .html</MTPrecode>]]>
        
    </content>
</entry>

<entry>
    <title>.htaccess 301 Redirect</title>
    <link rel="alternate" type="text/html" href="http://code.neo-shocker.com/2010/02/htaccess-301-redirect.html" />
    <id>tag:code.neo-shocker.com,2010://4.354</id>

    <published>2010-02-15T13:00:00Z</published>
    <updated>2010-03-08T19:16:35Z</updated>

    <summary>&quot;www.youdomain.com&quot; を &quot;yourdomain.com&quot; へ...</summary>
    <author>
        <name>Takahiro.</name>
        <uri>http://neo-shocker.com/</uri>
    </author>
    
    <category term="htaccess" label="htaccess" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="ja" xml:base="http://code.neo-shocker.com/">
        <![CDATA[<p>"www.youdomain.com" を "yourdomain.com" へ Redirect する場合 .htaccess に</p>

<MTPrecode>RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.yourdomain\.com)(:80)? [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://yourdomain.com/$1 [R=301,L]</MTPrecode>]]>
        
    </content>
</entry>

</feed>
