Movable Typeの条件文(if)

| | カテゴリ : Movable Type , サイト制作 | コメント(32) | トラックバック(0)
このエントリーをはてなブックマークに追加  
Movable Typeにも条件文がいくつかあります。

「もし?だったら」の「if」を紹介します。
Movable Typeのテンプレートを意図した表示を行うために、必要な条件文になります。「ブログ」や「サイト」構築に殆ど使用することになります。

CやPerlの言語なら以下になります。
if(条件式)
{
 条件一致(真)の処理;
}

Movable Typeの場合は以下になります。
<MTIf name="変数名" 条件式>
 条件一致(真)の処理
</MTIf>

まずは、値と値を代入するための変数名をセットします。
以下のMovable Typeタグを使用します。
<MTSetVarBlock name="変数名">値</MTSetVarBlock>

今回は、現在の記事のタイトルを値にセットし、変数「entry_title」に代入します。
記事のタイトルは、Movable Typeタグの「<$MTEntryTitle$>」で呼び出すことが出来ます。

変数名と値のセットは以下になります。
<MTSetVarBlock name="entry_title"><$MTEntryTitle$></MTSetVarBlock>

条件を行います。

今回の記事のタイトルは、「Movable Typeの条件文(if)」になるので、このタイトル比較対象にし一致(真)した場合の処理を行います。

比較するための演算子(比較演算子)を使う必要があります。これは他の言語でも同じです。
今回は、一致(真)の場合なので、eq=""を使います。

以下のようになります。
<MTSetVarBlock name="entry_title"><$MTEntryTitle$></MTSetVarBlock>
<MTIf name="entry_title" eq="Movable Typeの条件文(if)">
 記事のタイトルが一致しました。
</MTIf>

実際の処理の結果
 記事のタイトルが一致しました。

もちろん条件式に一致しなかった場合の、elseも使用することが出来ます。
<MTElse>?</MTElse>内に偽の処理を指定します。

今回は、現在の記事のタイトルと違う記事のタイトルを比較し、一致(偽)しなかった場合の処理を行います。
違う記事のタイトルは、「Movable Typeのメリット」とします。

以下のようになります。
<MTSetVarBlock name="entry_title"><$MTEntryTitle$></MTSetVarBlock>
<MTIf name="entry_title" eq="Movable Typeのメリット">
 記事のタイトルが一致しました。
<MTElse>
 記事のタイトルが一致しませんでした。
</MTElse>
</MTIf>

実際の処理の結果
 記事のタイトルが一致しませんでした。

<MTElseIf 条件式>を使用することで、さらに条件を繋げていくことも出来ます。
また、<MTIf>とは逆の条件文、<MTUnless>もあります。

比較演算子も他言語と同様あります。
  • like="" : 一部でも含まれれば真
  • eq="" : 一致すれば真
  • ne="" : 一致しなければ真
  • lt="" : 大きければ真
  • gt="" : 小さければ真
  • le="" : 以上であれば真
  • ge="" : 以下であれば真

トラックバック(0)

このブログ記事を参照しているブログ一覧: Movable Typeの条件文(if)

このブログ記事に対するトラックバックURL: http://takot.sakura.ne.jp/mt/mt-tb.cgi/631

コメント(32)

Hi, after reading this remarkable piece of writing i am
as well delighted to share my familiarity here with colleagues.

buy cbd oil evansville in buy cbd oil cape town buy cbd oil green roads buy
cbd oil copenhagen buy cbd oil buy cbd oil dischem buy cbd oil
brighton

Please let me know if you're looking for a writer for your blog.

You have some really great posts and I think I
would be a good asset. If you ever want to take
some of the load off, I'd really like to write some content for your blog in exchange for a link
back to mine. Please send me an e-mail if interested.
Cheers!

I enjoy what you guys tend to be up too. Such clever work and coverage!
Keep up the good works guys I've added you guys to our blogroll.

Oh my goodness! Impressive article dude! Thanks, However I am going through troubles with your RSS.
I don't understand why I cannot join it. Is
there anybody else having similar RSS problems? Anybody
who knows the answer will you kindly respond?
Thanx!!

Pretty nice post. I just stumbled upon your blog and wished to say that
I've really enjoyed surfing around your blog posts.
In any case I'll be subscribing on your feed and I'm
hoping you write again very soon!

It's amazing to pay a visit this site and reading the views of all friends concerning this piece of writing,
while I am also keen of getting know-how.

What's up to all, the contents existing at this website are
in fact amazing for people knowledge, well,
keep up the good work fellows.

What's up, I log on to your blog like every week.
Your humoristic style is awesome, keep up the good work!

First of all I want to say awesome blog! I had a quick question which
I'd like to ask if you do not mind. I was interested to know how you center yourself and
clear your head before writing. I have had a hard time clearing my thoughts in getting my ideas out.
I truly do enjoy writing but it just seems like the first 10 to 15 minutes
are usually lost simply just trying to figure
out how to begin. Any ideas or tips? Appreciate it!

Everything is very open with a really clear explanation of
the issues. It was definitely informative. Your site is useful.
Many thanks for sharing!

Good post but I was wanting to know if you could write a litte more on this topic?
I'd be very thankful if you could elaborate a little bit
further. Bless you!

Nice post. I learn someething new and challenging
on sites I stumbleupon everyday. It will always be helpful
to read trough articles from other authors and use a little something from their sites.

I think the admin of this web site is actually working hard in favor of his website, for the reason that here every material is
quality based information. http://www.melovers.com/users/MarilynnTo/info/

Thanks for sharing your thoughts on Movable Type. Regards

Most individuals have a good page rank, and they qualify to be a good inbound link to some site.
You will be amazed to comprehend that page rank 5 is way better
than page rank 3. https://www.viewnaija.com/user/RalfScurry

First of all I would likke to say wonderful blog! I had a quick question that I'd
like to ask if you don't mind. I was curious to know how you center yourself aand clear your
mind before writing. I've had a tough time clearing
my thoughts in getting my ideas ouut there. I do take pleasure in writing however
it just seeems like the first 10 tto 15 minutes are generally lost simply just tying to figure out how to begin. Anny suggestions or tips?
Kudos!

Does your blog have a contact page? I'm having problems
locating it but, I'd like to shoot you an email.
I've got some suggestions ffor your bloog you might be
interested in hearing. Either way, great site and I look forward to seeing
it exoand over time.

Hello there, just became alert to your blog through Google, and found that it's
truly informative. I am going to watch out for brussels.
I'll appreciate if you continue this in future.
Many people will be benefited from your writing. Cheers!

I think we have similar sounds might put on a crazy good show.
In April 1994, after returning to Seattle, Kurt discovered dead
into his home. More than 150,000 people come
to each location every 12 months. http://www.as-ilida.gr/UserProfile/tabid/43/UserID/1408120/Default.aspx

Good day! This is kind of off topic but I need some guidance from an established blog.
Is it hard to set up your own blog? I'm not very techincal but
I can figure things out pretty quick. I'm thinking about setting up my own but I'm not sure where to begin. Do
you have any tips or suggestions? Many thanks

These are actually fantastic ideas in concerning blogging.
You have touched some fastidious points here. Any way keep up wrinting. http://www.zerobyw4.com/home.php?mod=space&uid=727353&do=profile&from=space

So, so when you make your way through some fear, be filled with gratitude for your experience.
You have nott likely discovered the various benefits youu to have from usingg might not. https://geekpostware.com/Foro/index.php?action=profile

Nice post. I was checking constantly this blog and I'm impressed!
Extremely useful info particularly the last part :) I care for such information a lot.
I was looking for this particular info for a long time.
Thank you and good luck.

Excellent beat ! I wish to apprentice while you amend your site, how can i subscribe for a
blog site? The account helped me a acceptable deal.

I had been tiny bit acquainted of this your broadcast offered bright clear concept https://iwebl.ink/play8oygame174880

Good day! This is my first visit to your blog! We are a grouip of volunteers and starting a neww
initiative in a community in the same niche. Your blog provided us valuable information to work on. You have done a outstanding job!

Nice post. I learn something new and challenging
on websites I stumbleupon on a daily basis. It's always
useful to read content from other writers and use something from other sites.

After you post articles and updates on your website, notify the search
engines by utilizing a srvice like Ping-O-Matic. When creating a smoothie,
you should add your liquid ingredients to the blender first
and blend lightly.

These are truly great ideas in about blogging.
You have touched some fastidious points here.
Any way keep up wrinting.

Appreciating the persistence you put into your blog and detailed information you
present. It's good to come across a blog every once in a while
that isn't the same unwanted rehashed material.

Excellent read! I've saved your site and I'm adding your RSS feeds to
my Google account. http://tmjambitions.co.uk/?a%5B%5D=%3Ca+href%3Dhttp%3A%2F%2Fnewstrapon.com%2Fuser%2FTatianaMcG%3Eslot+mobile+Gionee%3C%2Fa%3E

It may sound like there is lots of new articles directories popping upp every shift.
To maximize my websitte rankings,I only submmit to sites have got ranked extremely well. http://wunderbarn.com/__media__/js/netsoltrademark.php?d=America.44.link%2Fhome.php%3Fmod%3Dspace%26uid%3D351261%26do%3Dprofile%26from%3Dspace

I think this is among the most vital info for me. And i am glad reading
your article. But want to remark on few general things, The web site style is perfect, the articles
is really nice : D. Good job, cheers http://www.hksibbs.com/home.php?mod=space&uid=874611&do=profile&from=space

コメントする

Insert Emoddy tag

画像の中に見える文字を入力してください。

プロフィール

Kamitani79
ニックネーム : Kamitani79
映画鑑賞、音楽、写真、ゲーム。地元・横浜をこよなく愛する( `・∀・´)ノヨロシク
自己紹介 :
このエントリーをはてなブックマークに追加

携帯サイト

つながり

  • ブロガー(ブログ)交流空間 エディタコミュニティ
  • あわせて読みたいブログパーツ
  • フィードメーター - Kamitani79-メロンとバナナとブログ
  • SEO
    loading
Creative Commons License
このブログのライセンスは クリエイティブ・コモンズライセンス.
Powered by Movable Type 6.2.4

最近のアクション

人気のエントリー

最近の写真・画像

空の写真

www.flickr.com
This is a Flickr badge showing public photos and videos from Kamitani79. Make your own badge here.

このブログ記事について

このページは、Kamitani79が2008年5月 2日 23:44に書いたブログ記事です。

ひとつ前のブログ記事は「携帯業界 ラストバトル」です。

次のブログ記事は「ロシア語のサイト制作とSEO」です。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。