Warning: Table './drupal_fandt_old/accesslog' is marked as crashed and last (automatic?) repair failed query: SELECT uid, timestamp FROM accesslog WHERE (path = 'node/80' OR uid > 0) AND sid = '6eea81174bae65c1a32a9123511cab21' ORDER BY timestamp DESC LIMIT 0, 1 in /var/www/akishige/fandt/includes/database.mysqli.inc on line 128
Drupal テーマのオーバーライド | FOREST & trees

Drupal テーマのオーバーライド

Drupal のテーマシステムにおいて,とても特徴的でかつ強力なのが「オーバーライド (Override)」という機能です。オーバーライドとは,よく「上書き」などと訳されますが,Drupal テーマにおけるオーバーライドとは,既存のテンプレートによるアウトプットを自分がカスタマイズしたテンプレートによるアウトプットで書き換えるというものです。

たとえばノードのテンプレートを例にとると,Drupal では一番基本となるノードテンプレートのほかに,特定のコンテンツタイプだけに適用されるテンプレートや,特定ノードだけに適用されるテンプレートを持たせることができます。このため,たとえば通常はノードのタイトルが <h2> タグで囲われているけれど,blog コンテンツタイプのノードだけは <h1> タグで囲いたいとか,node/123 の本文だけは特別な CSS のクラスを持たせて,見た目をカスタマイズしたい,などというニーズに細かく対応させることが可能です。

テンプレートファイル・オーバーライドの実際例

次の図はユーザー ID 1 のユーザーアカウント編集ページの表示に使用するテンプレートを Drupal が決定する際のロジックを説明したものです。

この方法をとることで,たとえばユーザーアカウントページ上ではサイドバーを無効にする,などといったことが可能です。

僕が個人的にとくに頻繁に利用するのが,特定コンテンツタイプ向けの node テンプレートです。たとえば FlowPlayer というビデオプレイヤー機能を提供するモジュールがあるのですが,このモジュールは API を提供してくれるだけで,プレイヤーそのものは書き出してくれません。そこで,たとえば Video というコンテンツタイプがあれば node-video.tpl.php というテンプレートファイルを作って,このテンプレートファイル内に <?php print $flowplayer; ?> などというコードを埋め込むのです (実際に FlowPlayer モジュールを使うには,このほかに template.php ファイルなどに別のコードが必要です)。こうすれば,「ほかのコンテンツタイプを表示するときにはビデオプレイヤーは含まれないが,Video コンテンツタイプのノードを表示するときだけビデオプレイヤーが追加される」ということが実現できます。

このように Drupal は,画面を構成する HTML を書き出すときに「より適用対象が限定されたテンプレートファイル」から「より一般的に利用されるテンプレートファイル」へと順に探していき,いずれかが見つかれば,そのテンプレートファイルを使用して HTML の書き出しを行います。これは完全に自動で行われるので,オーバーライド用のテンプレートファイルを追加する以外には何もする必要はありません。あとは Drupal がすべてやってくれます。

»

Comments

den

Thanks for this nice post it is excellent work done by you..i am waiting for next post. Unlock Your Hip Flexors Wake Up Lean Venus Factor Extreme PaleoHacks Cookbook CB Passive Income Smart Solar Box Review Text Your Ex Back

The majority of men wonder if

The majority of men wonder if one could obtain such type of Oakley sunnies in a budget. Fat Burning Kitchen Review Yoga Burn review

Goodness, this is truly

Goodness, this is truly intriguing perusing. I am happy I discovered this and got the chance to peruse it. Awesome employment on this substance. I like it. Pest Control West Palm Beach

mita

Thanks very much to share articles with us all, is not important to me any kind of platform that you use that matters to me is the content in this web content and how unique articles that you write on the web. klik disini read more baca selengkapnya info lebih lanjut baca seterusnya

Christmas Coming Soon!!

Christmas hamper ideas very often contain things that are associated with the festive time of year, such as mince pies or mulled wine, and this can be a great excuse to have the family together to make the most of the hampers. Shared out between family members, or consumed alone, hampers are thoughtful and surprising and can be decorated in any which way that you take a fancy to, making it more personal to the recipient.  Why not buy your hampers online and then add your own finishing touches to it? A bunch of flowers perhaps, or some toys for the kids. You could even decorate the hamper with ribbons, italian panettone cake, bows or flowers, and even petals to make it scented. Again, most online retailers of hampers will be happy to meet your requirements for a minimal price.  Hampers are original gifts which say a lot about both the person and the person receiving the gift. This depends on the contents within the hampers that you are buying, but as they can be converted, as such, to any style that you want, this makes them gifts that are perfect for the whole family, both separately and combined! Buying hampers for the whole family is a great way, not only to save money and time, but also to be more personal about your gifts. You can add anything you like to hamper and most websites will allow you to choose the contents within it and have it priced up that way too. Christmas is the occasion where gift's hampers are used, Christmas celebrations turn out early interesting with these gift hampers, to make Christmas can be made special even for your loved one who are far away from you, by sending them a wide range of gift hampers with assorted gift bundled in one. The Christmas gift hampers UK include cakes, pastries, chocolates, homemade sweets, flowers, stars, plastic Santa, jingle bells, small Christmas tree and many gift vouchers and many more. There are many types of gift hampers, food hampers available as per your needs and budgets, all these hampers are unique in their own ways and never miss to get a complement.

Fiverr

You can just trust us with a peace of mind and that your fellow countrymen are doing a fabulous job, and they are not behind others in optimizing your business for the top positions on major search engines. We are serving the best, and at quite an affordable rates that are hard to find in open market. So try the skills and experience of our Fiverr SEO Service, and we will not let your expectations down!

Aw, this was

Aw, this was a really nice post. In idea I would like to put in writing like this additionally – taking time and actual effort to make a very good article… but what can I say… I procrastinate alot and by no means seem to get something done. Berita Bola Prediksi Bola Information

An interesting

An interesting discussion is worth comment. I think that you should write more on this topic, it might not be a taboo subject but generally people are not enough to speak on such topics. To the next. Cheers Berita Bola Prediksi Bola Information

Wow, great, I was wondering

Wow, great, I was wondering how to cure acne naturally. and found your site by google, learned a lot, now i’m a bit clear. Buy Coursework Online. I’ve bookmark your site and also add rss. keep us updated.

This is a awesome website.

This is a awesome website. The site proprietor has done an eminent occupation of assembling it, the data here is truly clever.  Write my Essay

oh wow this is awesome i

oh wow this is awesome i wasnt aware of it before but thanks for this i know that java has this but drupal also is having it thanks dirty pick up lines for all the lines that are really dirty and the other stuff that is really fasscinating is the  christian pick up lines that really lineesthat are chrsitain and holy

I appreciate you and hopping

I appreciate you and hopping for some more informative posts. happy new year 2016 new year 2016 happy new year 2016 images feliz año nuevo 2016

Traveling on a tight budget

Traveling on a tight budget often restraints families together with individuals with experiencing their vacation to the maximum. But by using a little following a good budget and investigate, you can have a luxury holiday vacation even on a tight budget. travel-and-vacations.net

Being a good city for great wonder Cape Metropolis offers a perfect environment for any difficulties amorous. Majestic hills, the straw yellow seashore, a good Mediterranean conditions, an patio lifestyle are really a perfect background for that romantic Cape Metropolis vacation. travellersbay.net

 

The Honeymoon searching for

The Honeymoon searching for wedding may be a time honored tradition that extends back to hundreds of years. This stands out as the time as soon as the couple will enjoy matrimonial bliss off from the emotional stress of job or friends and family. Unfortunately, honeymoon travel are usually prohibitively overpriced. caribbeanhoneymoontravel.org

Travel Professional India superb deals are usually offered as a result of number for reasons, which is a impede rate for bookings, less alluring climate and climatic conditions in special destinations and even promotions regarding certain holiday products. advancetourandtravel.net

The Great need of Travel Coverage & Reasons to build Travel Coverage Many don't realize the great need of travel coverage. Travel coverage provides proper protection while voyaging. It covers one alongside travel correlated accidents & out of the blue medical expenses through travel. airlinetravelinsurance.net

 

A Breitling watch is a

A Breitling watch is a high-end watch that is accessible in both men's and women's versions and in dozens of sizes and styles. Some Breitling watches accept a individual punch on them and others accept one or added subdials on the http://www.ctmedicare.org face. Luckily, no amount what archetypal of watch you have, the instructions on how to accomplish the altered types of Breitling watches are about identical. If you apperceive how to set one, you can set any of them.

dissertation

Your article is awesome! How long does it take to complete this article? I have read through other blogs, but they are cumbersome and confusing. I hope you continue to have such quality articles to share with everyone! I believe a lot of people will be surprised to read this article!       http://www.cheap-essay-writing.co.uk/