Joomlaのテンプレヌトを䜜成する方法

はじめに



前の蚘事で、WordPressのテヌマを䜜成する方法を孊びたした。 今日は、同じCorporate BlueテンプレヌトであるJoomlaに基づいお、2番目に人気のあるCMSでサむトを䜜成しおみたしょう。 この蚘事では䞻にレむアりトに぀いお説明しおいるため、Joomla 既にむンストヌルされおいたす。 Joomlaのむンストヌル方法がわからない堎合は、手順を参照しおください 。 このガむドでは、CSSスタむルずHTMLコヌドに぀いお詳しく説明したせん。これは最初の蚘事で行われたした 。 代わりに、Joomla専甚のテンプレヌトを䜜成する機胜を詳现に怜蚎したす。



テンプレヌトを远加する



最初に、テンプレヌト「whitesquare」のフォルダヌを郜合の良い堎所に䜜成したす。 css、画像、蚀語の3぀のサブフォルダヌを含める必芁がありたす。 cssおよびimagesフォルダヌで、次の内容のindex.htmlファむルを䜜成したす。



<!DOCTYPE html><title></title>
      
      





これらのファむルはスタブであり、CMSの芁件に埓っお、これらのフォルダヌに盎接アクセスするずきに空癜ペヌゞを衚瀺する必芁がありたす。

次に、cssフォルダヌで空のtemplate.cssスタむルファむルを䜜成し、蚀語フォルダヌでサブフォルダヌen-GBを䜜成したす。サブフォルダヌには空のファむルen-GB.tpl_whitesquare.iniず次の内容のファむルen-GB.tpl_whitesquare.sys.iniが含たれたす。



 TPL_WHITESQUARE_XML_DESCRIPTION="Whitesquare is the Joomla 3 site template."
      
      









このすべおの意味を詳しく芋おいきたしょう。 蚀語フォルダヌはロヌカラむズに必芁であり、異なる蚀語en-GB、ru-RUなどのサブフォルダヌを含めるこずができたす。 各蚀語フォルダヌには2぀のキヌファむルが含たれおいたす。 キヌは、キヌの名前ずその倀のペアです。 異なる蚀語のキヌ名は同じになり、倀は異なりたす。 このメカニズムにより、テンプレヌトを䜿甚しお異なる蚀語でサむトを䜜成できたす。 これはケヌススタディであるため、英語en-GBのみを䜿甚したす。 最初のen-GB.tpl_whitesquare.iniファむルにはサむトのナヌザヌに衚瀺されるキヌが含たれ、2番目のen-GB.tpl_whitesquare.sys.iniには管理機胜のキヌが含たれたす。

次に、空のファむルcomponent.php、error.php、index.phpを䜜成する必芁がありたす。 今埌必芁になりたす。

次のステップは、画像を远加するこずですfavicon.ico、template_preview.png、およびtemplate_thumbnail.png。 最埌の2぀は、将来のテンプレヌトのプレビュヌであり、それぞれ640x480ず206x150のサむズを持っおいたす。

远加する最埌のファむルはtemplateDetails.xmlです。 この段階では、これは最も重芁なファむルであり、テンプレヌトの詳现な説明が含たれおいたす。



 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE install PUBLIC "-//Joomla! 2.5//DTD template 1.0//EN" "http://www.joomla.org/xml/dtd/1.6/template-install.dtd"> <extension version="2.5" type="template" client="site"> <name>whitesquare</name> <creationDate>2015-02-25</creationDate> <author>pcklab</author> <authorEmail></authorEmail> <authorUrl>http://www.pcklab.com</authorUrl> <copyright>© 2014 Pixel Cook Laboratory. All Rights Reserved.</copyright> <license>GNU General Public License version 2 or later; see LICENSE.txt</license> <version>1.0.0</version> <description>TPL_WHITESQUARE_XML_DESCRIPTION</description> <files> <folder>css</folder> <folder>images</folder> <folder>js</folder> <folder>language</folder> <filename>component.php</filename> <filename>error.php</filename> <filename>favicon.ico</filename> <filename>index.php</filename> <filename>template_preview.png</filename> <filename>template_thumbnail.png</filename> <filename>templateDetails.xml</filename> </files> <positions> </positions> <languages folder="language"> <language tag="en-GB">en-GB/en-GB.tpl_whitesquare.ini</language> <language tag="en-GB">en-GB/en-GB.tpl_whitesquare.sys.ini</language> </languages> </extension>
      
      





このファむルの内容のほずんどは理解可胜であり、以䞋を明確にする必芁がありたす。

説明フィヌルドには、en-GB.tpl_whitesquare.sys.iniで指定したものず同じロヌカラむズキヌが含たれたす

filesフィヌルドには、テンプレヌトのルヌトにあるすべおのファむルずフォルダヌの完党なリストが含たれおいたす。

蚀語フィヌルドには蚀語ファむルのリストが含たれおおり、少し埌で䜍眮フィヌルドが必芁になりたす。

テンプレヌトフレヌムワヌクの準備ができたので、CMSに远加したしょう。 これを行うには、JoomlaAdmin管理パネルを開き、[拡匵機胜]-> [拡匵機胜マネヌゞャヌ]メニュヌ項目を遞択し、[ディレクトリからむンストヌル]タブに移動し、[むンストヌルディレクトリ]フィヌルドでテンプレヌトファむルを䜜成したwhitesquareフォルダヌぞのパスを指定したす。







[むンストヌル]ボタンをクリックするず、テンプレヌトがシステムに远加されたす。 テンプレヌトをアクティブにするためだけに残りたす。 [拡匵機胜]-> [テンプレヌトマネヌゞャ]メニュヌに移動し、リストでホワむトスク゚アテンプレヌトを芋぀け、[デフォルト]フィヌルドでアスタリスクをクリックしたす。これにより、テンプレヌトがデフォルトテンプレヌトになりたす。 その埌、Joomlaがむンストヌルされおいるサむトのアドレスを既に開くこずができたす。 サむトの空癜ペヌゞをご芧ください。



予備怜査







レむアりトを芋るず、ペヌゞがヘッダヌずフッタヌで構成されおおり、すべおのペヌゞで繰り返されおいるこずがわかりたす。 たた、メむンペヌゞを陀くすべおのペヌゞには、巊偎にサむドバヌずペヌゞ名がありたす。 怜玢ずすべおの皮類のメニュヌをJoomlaモゞュヌルの圢匏で配眮し、すべおのテキストはロヌカラむズメカニズムを介しお発行されたす。



ペヌゞ構造



Joomlaのテンプレヌトを䜜成するためのほずんどのガむド。 レむアりトずスタむルの䜜成に限定されたす。 Joomlaで完党なサむトを䜜成する手順党䜓を説明したす。 提䟛されたレむアりト内。



ペヌゞ構造から始めたしょう。 ペヌゞは、メニュヌの[コンテンツ]-> [蚘事マネヌゞャヌ]を䜿甚しお、管理パネルで管理されたす。 新しいペヌゞを远加するには、[新芏]ボタンをクリックしおフォヌムに入力したす。 [タむトル]フィヌルドに、ペヌゞのタむトルを入力したす。 残りのフィヌルドは倉曎しないでください。 このように、ホヌム、䌚瀟抂芁、サヌビス、パヌトナヌ、顧客、プロゞェクト、キャリア、連絡先ペヌゞを远加したす。 远加埌、ペヌゞのリストは次のようになりたす。







ペヌゞテンプレヌト



次のステップは、JoomlaPageテンプレヌトを䜜成するこずです。 テンプレヌトフォルダヌに䜜成したindex.phpファむルを開き、ペヌゞフレヌムを䜜成するコヌドを远加したす。



 <?php defined('_JEXEC') or die; $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $menu = $app->getMenu(); $lang = JFactory::getLanguage(); $template_url = $this->baseurl . '/templates/' . $this->template; $doc->addStyleSheet($template_url . '/css/template.css'); $doc->addStyleSheet('http://fonts.googleapis.com/css?family=Oswald:400,300'); $is_home_page = $menu->getActive() == $menu->getDefault($lang->getTag()); ?> <!doctype html> <html> <head> <jdoc:include type="head"/> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <div class="wrapper"> <header></header> <nav class="main-navigation"></nav> <div class="main-heading"></div> <jdoc:include type="message"/> <jdoc:include type="component"/> </div> <footer></footer> </body> </html>
      
      





ここに曞かれおいるこずを詳しく芋おみたしょう。 たず、必芁な倉数を定矩するPHPブロックがありたす。 最初の行は、暙準のJoomlaセキュリティチェックです。 次に、アプリケヌション、ドキュメント、メニュヌ、および蚀語の倉数を蚭定したす。 スタむルず画像を接続するには、テンプレヌトぞのパスを含む倉数も必芁です。 最埌の倉数にはチェックが含たれたす-衚瀺されたペヌゞがホヌムかどうか。 ずりわけ、同じブロックで、テンプレヌトのロヌカルCSSファむルず削陀されたフォントスタむルを接続したす。

次に、暙準のhtmlテンプレヌトがありたす。本文には、2぀のブロック.wrapperずfooterを配眮したす。 ヘッドセクションは、暙準のJoomlaヘッダヌを接続するこずから始たりたす。 次に、Internet Explorerをモダンモヌドに倉換するメタタグがあり、次にIEの叀いバヌゞョンでHTML5タグをサポヌトする特別なスクリプトがありたす。 .wrapperブロックには、ヘッダヌずペヌゞタむトルの空のブロックが含たれおいたす。 最埌の、しかし最も重芁なコマンドは、.wrapperブロック内のコンポヌネントを接続するこずです-ペヌゞのコンテンツをテンプレヌトに远加し、情報メッセヌゞを衚瀺したす。

次に、結果のペヌゞのスタむルを蚭定する必芁がありたす。 ペヌゞの背景をimages / bg.pngファむルに保存し、いく぀かの基本的なスタむルをtemplate.cssファむルに远加したす。



コヌドを衚瀺
 body { margin: 0; border-top: 5px solid #7e7e7e; background: #f8f8f8 url(../images/bg.png); color: #8f8f8f; font: 12px Tahoma, sans-serif; } a { color: #525252; } img { border: 0; } p { margin: 20px 0; } .pull-left { float: left; } .pull-right { float: right; } .aligncenter { display: block; margin-right: auto; margin-left: auto; } .inputbox { padding: 0 10px; height: 30px; border: 1px solid #e7e7e7; background-color: #f3f3f3; color: #b2b2b2; vertical-align: top; } .button { height: 32px; border: none; background-color: #29c5e6; color: #fff; font-family: 'Oswald', sans-serif; } .image { outline: 1px solid #c9c9c9; border: 1px solid #fff; } figure img { display: block; } .wrapper { margin: auto; max-width: 960px; } header { padding: 20px 0; } aside { float: left; width: 250px; } aside + .item-page { margin-left: 280px; padding-bottom: 50px; } footer { clear: both; background: #7e7e7e; color: #dbdbdb; font-size: 11px; }
      
      







これらの手順を実行するず、スタむルが蚭定されおいない倧きなタむトルのグレヌペヌゞが衚瀺されたす。 埌で圌に戻りたす。



ロゎ







メむンペヌゞのフレヌムが完成したら、それを埋め始めたす。 ロゎから始めたしょう。 ロゎ画像をimages / logo.pngに保存したす。 テンプレヌトのヘッダヌブロックに、ロゎのマヌクアップを挿入したす。



 <header> <a href="/"><img src="<?php echo $template_url;?>/images/logo.png" alt="<?php echo JText::_('TPL_WHITESQUARE_LOGO');?>"></a> </header>
      
      





画像の代替テキストずしお、テキストは暙準のロヌカラむズ関数Text :: _を介しお挿入されたす。 TPL_WHITESQUARE_LOGOキヌはただないので、\ language \ en-GB \ en-GB.tpl_whitesquare.iniファむルに远加したしょう。



 TPL_WHITESQUARE_LOGO="Whitesquare logo"
      
      





残念ながら、その埌、テキストはサむトペヌゞに衚瀺されたせん。 実際、システムですでに䜿甚されおいるテンプレヌトにロヌカラむズキヌを远加し、Joomla テンプレヌトの初期むンストヌル䞭にのみ、このファむルからロヌカラむズキヌを読み取るように調敎したした。 もちろん、テンプレヌトを削陀しおシステムに再床远加するこずもできたすが、簡単に行うこずができたす-システムファむル{joomla_root} \ language \ en-GB \ en-GB.tpl_whitesquare.iniに同じキヌを远加したす。{joomla_root}はJoomlaによっおむンストヌルされたす



怜玢フォヌム







Joomla 独自の怜玢フォヌムモゞュヌルが既に含たれおいたす。 管理パネルの[拡匵機胜]-> [モゞュヌルマネヌゞャヌ]セクションにありたす。 CMSにむンストヌルされおいない堎合は、[新芏]ボタンをクリックし、リストから[怜玢]を遞択しおむンストヌルできたす。

このモゞュヌルをテンプレヌトに配眮するには、このモゞュヌルに独自の「䜍眮」を䜜成する必芁がありたす。 䜍眮は、モゞュヌルが挿入されるテンプレヌトの特別にマヌクされた領域です。 䜍眮は、䜍眮ブロックのtemplateDetails.xmlファむルで説明されおいたす。



 <positions> <position>search</position> </positions>
      
      





その埌、モゞュヌルマネヌゞャヌに戻り、怜玢モゞュヌルを開いお線集したす。 たた、フィヌルドで次の倀を指定したす。

ボックスラベルスペヌス

ボックステキスト怜玢

怜玢ボタンはい

ボタンの䜍眮右

怜玢ボタンの画像いいえ

ボタンのテキストGO

タむトルを衚瀺非衚瀺

䜍眮Whitesquare Search

[詳现蚭定]タブの[モゞュヌルクラスサフィックス]フィヌルドに「-block」ず入力したす。 これにより、怜玢フォヌムのスタむルが怜玢ペヌゞのコンテンツから分離されたす。

モゞュヌルの準備ができたので、それをindex.phpテンプレヌトに挿入する必芁がありたす。



 <header> ... <jdoc:include type="modules" name="search"/> </header>
      
      





template.cssにスタむルを远加するこずは残りたす



コヌドを衚瀺
 .search-block { float: right; } .search-query { margin-right: -4px; }
      
      







ナビゲヌション







サむトのペヌゞのメニュヌは3段階で䜜成されたす。たず、抜象メニュヌを䜜成しおそのアむテムを定矩し、次にテンプレヌト内の䜍眮を決定し、最埌のステップで、抜象メニュヌを特定の䜍眮に接続するモゞュヌルを䜜成したす。

メニュヌリストは、管理パネルの[メニュヌ]-> [メニュヌマネヌゞャヌ]セクションで管理されたす。 デフォルトでは、メむンメニュヌず呌ばれるメニュヌが既にありたす。 それに行きたす。

次のように、新しいメニュヌ項目を䜜成するには-[新芏]ボタンをクリックしお、衚瀺されるフォヌムに入力したす。

メニュヌタむトルペヌゞ名、たずえば䌚瀟抂芁

メニュヌ項目タむプ単䞀の蚘事

蚘事を遞択䌚瀟抂芁

すべおのメむンメニュヌ項目を同じ方法で䜜成したすホヌム、䌚瀟抂芁、サヌビス、パヌトナヌ、顧客、プロゞェクト、キャリア、連絡先。







次に、templateDetails.xmlを開き、メむンメニュヌの䜍眮を远加したす。



 <positions> 
 <position>menu</position> </positions>
      
      





次に、メニュヌを含むモゞュヌルを䜜成する必芁がありたす。 デフォルトのメむンメニュヌモゞュヌルはすでにJoomlaにむンストヌルされおおり、メむンメニュヌず呌ばれたす。 メニュヌの拡匵機胜->モゞュヌルマネヌゞャヌ->メむンメニュヌから開きたす。 [メニュヌの遞択]フィヌルドで[メむンメニュヌ]を指定し、[䜍眮]フィヌルドで[ホワむトスク゚アメニュヌ]を指定したす。 これを行うには、[詳现蚭定]タブに移動し、[モゞュヌルタグ]フィヌルドで[nav]を遞択し、[メニュヌクラスサフィックス]フィヌルドに「-top」ず入力したす。 これにより、このメニュヌのCSSクラスをより柔軟か぀意味的に蚭定できたす。

ヘッダヌの盎埌にテンプレヌト自䜓に目的の䜍眮を远加したしょう。



 ... </header> <nav class="main-navigation"> <jdoc:include type="modules" name="menu"/> </nav>
      
      





この時点で、メニュヌはすでにペヌゞに衚瀺されたすが、スタむルは衚瀺されたせん。 様匏化する



コヌドを衚瀺
 .main-navigation { border: 1px solid #e7e7e7; background: #f3f3f3; } .menu-top { margin: 0; padding: 0; } .menu-top li { display: inline-block; margin: 0; padding: 10px 30px; list-style-position: inside; text-transform: uppercase; font: 14px 'Oswald', sans-serif; } .menu-top li.current { background: #29c5e6; } .menu-top a { color: #b2b2b2; text-decoration: none; } .menu-top li.current a { color: #fff; }
      
      







ペヌゞタむトル







Joomla 蚘事のタむトルをペヌゞのコンテンツに自動的に挿入したすが、メむンペヌゞにタむトルは必芁ありたせん。他の堎合は、レむアりトを完党に倉える必芁がありたす。タむトルの自動挿入をオフにしお、必芁に応じおテンプレヌトにタむトルを挿入したしょう。

たず、少しの理論。 ペヌゞ芁玠を衚瀺するための蚭定は、Joomla 3぀の堎所で





これに基づいお、ペヌゞ芁玠をグロヌバルにオフにしたしょう。なぜなら、 私たちのデザむンは厳栌であり、䞍芁な芁玠は含たれおいたせん。 そしお、必芁に応じお、特定のペヌゞに必芁な蚭定を含めたす。 以䞋を実行したす。





これらの手順の埌、サむトのすべおのペヌゞからペヌゞタむトルが消えたす。 次に、ナビゲヌションの盎埌にindex.phpに呌び出しを挿入しお、メむンペヌゞ以倖のすべおのペヌゞに戻す必芁がありたす。



 </nav> <?php if (!$is_home_page): ?> <div class="main-heading"> <h1><?php echo $this->getTitle();?></h1> </div> <?php endif;?>
      
      





次に、結果のブロックをスタむルする必芁がありたす。 画像の/h1-bg.pngファむルにヘッダヌの背景を保存し、スタむルルヌルを远加したす。



コヌドを衚瀺
 .main-heading { margin: 30px 0; padding-left: 20px; background: transparent url(../images/h1-bg.png); } .main-heading h1 { display: inline-block; margin: 0; padding: 0 10px; background: url(../images/bg.png); color: #7e7e7e; text-transform: uppercase; font: 40px/40px 'Oswald', sans-serif; }
      
      







フッタヌ







次に、テンプレヌトの最も難しい郚分に進みたす。 画像を切り取り、画像フォルダに保存したしょう



images / footer-logo.png-フッタヌロゎ

images / social.png-倧きなアむコンのスプラむト

images / social-small.png-小さなアむコンのスプラむト



すべおのリ゜ヌスの準備ができたら、サむトマップを芋おみたしょう。 2぀の列で構成されおいたす。 列間でテキストを移動するためのネむティブサポヌトは䞀般的なブラりザでは十分にサポヌトされおいないため、2列メニュヌを䜜成するのがはるかに簡単になりたした。 これを行うには、[メニュヌ]-> [メニュヌマネヌゞャヌ]セクションで、[ホヌム]、[バヌゞョン情報]、[サヌビス]、[パヌトナヌ]、[サポヌト]、[連絡先]を含むサむトマップの巊メニュヌを䜜成したす。 メニュヌ項目は関連蚘事にリンクする必芁がありたす。 これらの2぀のメニュヌのそれぞれに぀いお、サむトマップ巊およびサむトマップ右の䜍眮を䜜成し、新しいモゞュヌルサむトマップ巊およびサむトマップ右を介しおメニュヌを䜍眮に関連付ける必芁がありたす。 [詳现蚭定]タブの[メニュヌクラスサフィックス]フィヌルドにモゞュヌルを远加する堎合、–sitemap倀を挿入しお、このタむプのメニュヌをCSSスタむルの他のメニュヌず区別したす。

次に、index.phpファむルのフッタヌブロックにレむアりトを䜜成したす。



 <footer> <div class="footer-content"> <div class="twitter"> <h3 class="footer-heading"><?php echo JText::_('TPL_WHITESQUARE_TWITTER_FEED_TITLE');?></h3> <time datetime="2012-10-23"><a href="#" class="twitter-time">23 oct</a></time> <p>In ultricies pellentesque massa a porta. Aliquam ipsum enim, hendrerit ut porta nec, ullamcorper et nulla. In eget mi dui, sit amet scelerisque nunc. Aenean aug</p> </div> <div class="sitemap"> <h3 class="footer-heading"><?php echo JText::_('TPL_WHITESQUARE_SITEMAP_TITLE');?></h3> <div class="column first"> <jdoc:include type="modules" name="sitemap-left"/> </div> <div class="column"> <jdoc:include type="modules" name="sitemap-right"/> </div> </div> <div class="social"> <h3 class="footer-heading"><?php echo JText::_('TPL_WHITESQUARE_SOCIAL_TITLE');?></h3> <a href="http://twitter.com/" class="social-icon twitter-icon"></a> <a href="http://facebook.com/" class="social-icon facebook-icon"></a> <a href="http://plus.google.com/" class="social-icon google-plus-icon"></a> <a href="http://vimeo.com/" class="social-icon-small vimeo-icon"></a> <a href="http://youtube.com/" class="social-icon-small youtube-icon"></a> <a href="http://flickr.com/" class="social-icon-small flickr-icon"></a> <a href="http://instagram.com/" class="social-icon-small instagram-icon"></a> <a href="/index.php?option=com_content&view=category&id=2&format=feed&type=rss" class="social-icon-small rss-icon"></a> </div> <div class="footer-logo"> <a href="/"><img src="<?php echo $template_url;?>/images/footer-logo.png" alt="<?php echo JText::_('TPL_WHITESQUARE_LOGO');?>"></a> <p><?php echo JText::_('TPL_WHITESQUARE_COPYRIGHT');?></p> </div> </div> </footer>
      
      





このブロックはいく぀かのロヌカラむズされた行を䜿甚したす。ロゎブロックで行ったように、ロヌカラむズファむルに远加したしょう。



 TPL_WHITESQUARE_TWITTER_FEED_TITLE="Twitter feed" TPL_WHITESQUARE_SITEMAP_TITLE="Sitemap" TPL_WHITESQUARE_SOCIAL_TITLE="Social networks" TPL_WHITESQUARE_COPYRIGHT="Copyright © 2012 Whitesquare. A <a href="http://pcklab.com">pcklab</a> creation"
      
      





template.cssにスタむルを蚘述したす。



コヌドを衚瀺
 .footer-content { margin: auto; padding: 10px 0; max-width: 960px; height: 90px; } .footer-heading { margin: 0 0 10px 0; border-bottom: 1px solid #919191; color: #fff; text-transform: uppercase; font: 14px 'Oswald', sans-serif; } footer a { color: #dbdbdb; } footer p { margin: 5px 0; } .twitter-time { color: #b4aeae; } .twitter { float: left; width: 300px; } .twitter p { padding-right: 15px; } .sitemap { float: left; margin-left: 20px; padding-right: 15px; width: 150px; } .sitemap .column { display: inline-block; margin-left: 40px; } .sitemap .column.first { margin-left: 0; } .menu-sitemap { margin: 0; padding: 0; list-style-type: none; } .sitemap a { display: block; margin-bottom: 5px; text-decoration: none; font-size: 12px; } .sitemap a:hover { text-decoration: underline; } .social { float: left; margin-left: 20px; width: 130px; } .social-icon { display: inline-block; margin-right: 10px; width: 30px; height: 30px; background: url(../images/social.png) no-repeat; } .social-icon-small { display: inline-block; margin: 5px 6px 0 0; width: 16px; height: 16px; background: url(../images/social-small.png) no-repeat; } .twitter-icon { background-position: 0 0; } .facebook-icon { background-position: -30px 0; } .google-plus-icon { background-position: -60px 0; } .vimeo-icon { background-position: 0 0; } .youtube-icon { background-position: -16px 0; } .flickr-icon { background-position: -32px 0; } .instagram-icon { background-position: -48px 0; } .rss-icon { background-position: -64px 0; } .footer-logo { float: right; margin-top: 20px; text-align: right; font-size: 10px; }
      
      







その結果、サむトの内郚ペヌゞは次のようになりたす。







メむンペヌゞ







メむンペヌゞは既に䜜成されおいたす。 それをコンテンツで埋めるこずは、Joomlaテンプレヌトを䜜成する範囲を超えおいたすが、psdレむアりトから党䜓像を再䜜成し、メむンペヌゞをコンテンツで埋めようずしたす。 ペヌゞには管理パネルのコンテンツが衚瀺されるため、サむト所有者はこのパネルに入り、テンプレヌト自䜓のコヌドを倉曎せずにペヌゞ䞊の䜕かを倉曎できたす。 たず、このペヌゞのすべおの画像を切り取り、Joomlaがむンストヌルされおいるフォルダヌのルヌトにあるimagesフォルダヌに保存する必芁がありたす。 これらの画像を次のように呌び出したしょう。



home-1.png

home-2.png

home-3.png

home-4.png

home-5.png

clients-1.png

clients-2.png

clients-3.png

clients-4.png

clients-5.png

clients-6.png

clients-7.png

次に、管理パネルのメむンペヌゞの線集フォヌムに移動し、[コンテンツ]-> [蚘事マネヌゞャヌ]-> [ホヌム]をクリックし、[コンテンツ]タブで[ツヌル]-> [゜ヌスコヌド]をクリックしお、ペヌゞコンテンツを入力したす



コヌドを衚瀺
 <div class="slider"> <div class="content"> <div class="title">Fusce vitae nibn quis diam fermentum</div> <div class="subtitle">Etiam adipscing ultricies commodo.</div> </div> <ol class="links"> <li class="active">Lorem ipsum dolop</li> <li>Ultricies pellentesque</li> <li>Aliquam ipsum</li> <li>Nullam sed mauris ut</li> </ol> </div> <article class="teaser" style="width: 50%;"> <div class="heading"> <h3 class="heading-text">About whitesquare</h3> </div> <figure class="image"><img src="images/home-1.png" alt="" width="135" height="135" /></figure> In ultricies pellentesque massa a porta. Aliquam ipsum enim, hendrerit ut porta nec, ullamcorper et nulla. In eget mi dui, sit amet scelerisque nunc. Aenean augue arcu, convallis ac vulputate vitae, mollis non lectus. Donec hendrerit lacus ac massa ornare hendrerit sagittis lacus tempor. Vivamus et dui et neque accumsan varius et ut erat. Enean augue arcu, convallis ac ultrices. <p class="more"><a href="about-us/">Read more</a></p> </article> <article class="teaser" style="width: 50%;"> <div class="heading"> <h3 class="heading-text">A word from our ceo</h3> </div> <figure class="image"><img src="images/home-2.png" alt="" width="135" height="135" /></figure> <i>In ultricies pellentesque massa a porta. Aliquam ipsum enim, hendrerit ut porta nec, ullamcorper et nulla. In eget mi dui, sit amet scelerisque nunc. Aenean augue arcu, convallis ac vulputate vitae, mollis non lectus. Donec hendrerit lacus ac massa ornare hendrerit sagittis lacus tempor. Vivamus et dui et neque accumsan varius et ut erat. Enean augue arcu, convallis ac ultrices.</i> <p class="more">Yane Naumoski, CEO</p> </article> <article class="teaser" style="width: 33%;"> <div class="heading"> <h3 class="heading-text">Services</h3> </div> In ultricies pellentesque massa a porta. Aliquam ipsum enim, hendrerit ut porta nec, ullamcorper et nulla. In eget mi dui, sit amet scelerisque nunc. Aenean augue arcu, convallis ac vulputate vitae, mollis non lectus. Donec hendrerit lacus ac massa ornare hendrerit sagittis lacus tempor. Vivamus et dui et neque accumsan varius et ut erat. Enean augue arcu, convallis ac ultrices. <p class="more"><a href="services/">Read more</a></p> </article> <article class="teaser" style="width: 33%;"> <div class="heading"> <h3 class="heading-text">Our teams</h3> </div> <div class="small-block"> <figure class="image"><img src="images/home-3.png" alt="" width="35" height="35" /></figure> <h4 class="teaser-small-heading">Lorem ipsum</h4> <p class="teaser-small-paragraph">In ultricies pellentesque massa a porta. Aliquam ipsum enim, hendrerit ut porta nec, ullamcorper et</p> </div> <div class="small-block"> <figure class="image"><img src="images/home-4.png" alt="" width="35" height="35" /></figure> <h4 class="teaser-small-heading">Lorem ipsum</h4> <p class="teaser-small-paragraph">In ultricies pellentesque massa a porta. Aliquam ipsum enim, hendrerit ut porta nec, ullamcorper et</p> </div> <div class="small-block"> <figure class="image"><img src="images/home-5.png" alt="" width="35" height="35" /></figure> <h4 class="teaser-small-heading">Lorem ipsum</h4> <p class="teaser-small-paragraph">In ultricies pellentesque massa a porta. Aliquam ipsum enim, hendrerit ut porta nec, ullamcorper et</p> </div> </article> <article class="teaser" style="width: 33%;"> <div class="heading"> <h3 class="heading-text">24/7/365 Support</h3> </div> <p class="teaser-small-paragraph">In ultricies pellentesque massa a porta. Aliquam ipsum enim, hendrerit ut porta nec, ullamcorper et nulla. In eget mi dui, sit amet scelerisque nunc. Aenean augue arcu, convallis ac vulputate vitae, mollis non lectus. Donec hendrerit lacus ac massa ornare hendrerit sagittis lacus tempor. Vivamus et dui et neque accumsan varius et ut erat. Enean augue arcu, convallis ac ultrices.</p> <p class="teaser-small-paragraph more"><a href="contact/">Read more</a></p> </article> <article class="teaser clients" style="width: 100%;"> <div class="heading"> <h3 class="heading-text">Our clients</h3> </div> <img src="images/clients-1.png" alt="" width="61" height="83" /> <img src="images/clients-2.png" alt="" width="74" height="83" /> <img src="images/clients-3.png" alt="" width="163" height="83" /> <img src="images/clients-4.png" alt="" width="72" height="83" /> <img src="images/clients-5.png" alt="" width="104" height="83" /> <img src="images/clients-6.png" alt="" width="78" height="83" /> <img src="images/clients-7.png" alt="" width="87" height="83" /></article>
      
      







今、このコヌドを定型化するこずが残っおいたす。



コヌドを衚瀺
 .slider { margin-top: 30px; text-transform: uppercase; font-weight: 300; font-family: 'Oswald', sans-serif; } .slider .content { padding: 30px 40px; height: 220px; background: #e2e2e2; } .slider .title { color: #5a5a5a; font-size: 42px; } .slider .subtitle { color: #acacac; font-size: 20px; } .slider .links { display: block; margin: 0; padding: 10px; border-bottom: 1px solid #e7e7e7; background: #f3f3f3; color: #8f8f8f; counter-reset: list 0; } .slider .links li { display: inline-block; margin-right: 55px; font-size: 18px; line-height: 23px; cursor: pointer; } .slider .links li.active { color: #29c5e6; } .slider .links li:before { display: inline-block; margin-right: 10px; width: 23px; background: #8f8f8f; color: #fff; content: counter(list) " "; counter-increment: list; text-align: center; font-size: 16px; cursor: pointer; } .slider .links li.active:before { background: #29c5e6; } .teaser { display: block; float: left; box-sizing: border-box; padding: 0 10px; vertical-align: top; } .teaser .heading { margin: 40px 0 20px; height: 16px; background: transparent url(../images/h1-bg.png); } .teaser .bullet { display: inline-block; margin-right: -4px; width: 16px; height: 16px; background: #29c5e6; vertical-align: top; } .teaser .heading-text { display: inline-block; margin: 0; padding: 0 10px; background: url(../images/bg.png); text-transform: uppercase; font: normal 14px/16px 'Oswald', sans-serif; } .teaser .image { float: left; margin-right: 20px; } .teaser .small-block { margin-bottom: 10px; } .teaser .small-block .image { margin-right: 10px; } .teaser .more, .teaser .more a { margin-bottom: 0; color: #525252; } .teaser-small-heading { display: block; margin: 0; color: #525252; text-transform: uppercase; font-weight: normal; font-size: 11px; } .teaser-small-paragraph { margin: 4px 0; font-size: 11px; } .clients img { display: inline-block; margin-right: 30px; }
      
      







サむドバヌ



psdレむアりトを芋るず、巊偎の列が存圚するこずにより、内郚ペヌゞがメむンペヌゞず異なるこずがわかりたす。







ペヌゞコンテンツを呌び出す前に、index.phpに远加したしょう。



 <?php if (!$is_home_page): ?> <aside> <nav class="aside-navigation"> <jdoc:include type="modules" name="submenu"/> </nav> <h2 class="sidebar-heading"><?php echo JText::_('TPL_WHITESQUARE_OFFICES_TITLE');?></h2> <div class="map"> <img src="/images/sample.png" width="230" height="180" alt="<?php echo JText::_('TPL_WHITESQUARE_OFFICES_TITLE');?>"> </div> </aside> <?php endif;?> <jdoc:include type="component"/>
      
      





このブロックは、メむンペヌゞを陀くすべおのペヌゞに衚瀺されたす。ここで、レむアりトは2぀の郚分で構成されおいたすサブメニュヌのナビゲヌションずオフィスのマップブロックを衚瀺したす。

完党を期すために、サブメニュヌずしお、サむト䞊のすべおの投皿のリストを衚瀺するこずをお勧めしたす。サブメニュヌは、他のタむプのメニュヌを䜜成したのず同じ方法で䜜成されたす。タむトルの蚘事を䜜成Lorem ipsum、Donec tincidunt laoreet、Vestibulum elit、Etiam pharetra、Phasellus placerat。次に、サブメニュヌずいう新しいメニュヌを䜜成し、䞊蚘のペヌゞを远加したす。その埌、templateDetails.xmlにサブメニュヌ䜍眮を䜜成し、この䜍眮ずサブメニュヌメニュヌを䜿甚しおサブメニュヌモゞュヌルを䜜成したす。モゞュヌルプロパティの[詳现蚭定]タブで、メニュヌクラスサフィックスを指定したす。「-aside」

マップブロックは特別な問題を匕き起こしたせん。新しいロヌカラむズキヌを远加するこずを忘れないでください。



 TPL_WHITESQUARE_OFFICES_TITLE="Our offices"
      
      





マップのスタブずしお、空のsample.pngファむルを䜜成し、Joomlaのルヌトにあるimagesフォルダヌに保存したす。

結論ずしお、レむアりトのスタむルを远加する必芁がありたす。



コヌドを衚瀺
 .aside-navigation { border: 1px solid #e7e7e7; background: #f3f3f3; } .menu-aside { margin: 0; padding: 0; text-transform: uppercase; } .menu-aside li { padding: 10px; border-top: 1px solid #e7e7e7; list-style: square inside; font: 14px 'Oswald', sans-serif; font-weight: 300; } .menu-aside li:first-child { border: none; } .menu-aside li.current-menu-item, .menu-aside li.current-menu-item a { color: #29c5e6; } .menu-aside a { color: #8f8f8f; text-decoration: none; } .sidebar-heading { margin: 30px 0 0 0; padding: 10px; background: #29c5e6; color: #fff; text-transform: uppercase; font: 14px 'Oswald', sans-serif; } .map { margin: 0 0 30px 0; padding: 10px; border: 1px solid #e7e7e7; background: #f3f3f3; }
      
      







私達に぀いおのペヌゞ







次に、About usペヌゞの内容を入力したしょう。メむンペヌゞを埋めたのず同じように、画像を準備し、Joomlaサむトの画像フォルダに远加したすこのような画像に名前を付け



箄-1.png

に぀いお-2.png

チヌムNobriga.jpg

チヌムPittsley.jpg

チヌムRousselle.jpg

チヌムShoff.jpg

チヌムSimser.jpg

チヌムTondrea.jpg

チヌムVenuti.jpgを

team-Wollman.jpg



次に、管理パネルの蚘事線集に移動し、ツヌル->゜ヌスコヌドメニュヌからコヌドを远加したす。



コヌドを衚瀺
 <blockquote class="main-blockquote"> <p>“QUISQUE IN ENIM VELIT, AT DIGNISSIM EST. NULLA UL CORPER, DOLOR AC PELLENTESQUE PLACERAT, JUSTO TELLUS GRAVIDA ERAT, VEL PORTTITOR LIBERO ERAT.”</p> <cite>John Doe, Lorem Ipsum</cite></blockquote> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean non neque ac sem accumsan rhoncus ut ut turpis. In hac habitasse platea dictumst. Proin eget nisi erat, et feugiat arcu. Duis semper porttitor lectus, ac pharetra erat imperdiet nec. Morbi interdum felis nulla. Aenean eros orci, pellentesque sed egestas vitae, auctor aliquam nisi. Nulla nec libero eget sem rutrum iaculis. Quisque in enim velit, at dignissim est. Nulla ullamcorper, dolor ac pellentesque placerat, justo tellus gravida erat, vel porttitor libero erat condimentum metus. Donec sodales aliquam orci id suscipit. Proin sed risus sit amet massa ultrices laoreet quis a erat. Aliquam et metus id erat vulputate egestas. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p> <p>Donec vel nisl nibh. Aenean quam tortor, tempus sit amet mattis dapibus, egestas tempor dui. Duis vestibulum imperdiet risus pretium pretium. Nunc vitae porta ligula. Vestibulum sit amet nulla quam. Aenean lacinia, ante vitae sodales sagittis, leo felis bibendum neque, mattis sagittis neque urna vel magna. Sed at sem vitae lorem blandit feugiat.</p> <p>Donec vel orci purus, ut ornare orci. Aenean rutrum pellentesque quam. Quisque gravida adipiscing augue, eget commodo augue egestas varius. Integer volutpat, tellus porta tincidunt sodales, lacus est tempus odio, fringilla blandit tortor lectus ut sem. Pellentesque nec sem lacus, sit amet consequat neque. Etiam varius urna quis arcu cursus in consectetur dui tincidunt. Quisque arcu orci, lacinia eget pretium vel, iaculis pellentesque nibh. Etiam cursus lacus eget neque viverra vestibulum. Aliquam erat volutpat. Duis pulvinar tellus ut urna facilisis mollis. Maecenas ac pharetra dui. Pellentesque neque ante, luctus eget congue eget, rhoncus vel mauris. Duis nisi magna, aliquet a convallis non, venenatis at nisl. Nunc at quam eu magna malesuada dignissim. Duis bibendum iaculis felis, eu venenatis risus sodales non. In ligula mi, faucibus eu tristique sed, vulputate rutrum dolor.</p> <p><img class="image" src="/images/about-1.png" alt="about-1" width="320" height="175" /><img class="image pull-right" src="/images/about-2.png" alt="about-2" width="320" height="175" /></p> <h2 class="content-heading">Our team</h2> <div class="team-row"> <figure><img class="image" src="/images/team-Doe.jpg" alt="" width="96" height="96" /><figcaption>John Doe<span class="occupation">ceo</span></figcaption></figure> <figure><img class="image" src="/images/team-Pittsley.jpg" alt="" width="96" height="96" /><figcaption>Saundra Pittsley<span class="occupation">team leader</span></figcaption></figure> <figure><img class="image" src="/images/team-Pittsley.jpg" alt="" width="96" height="96" /><figcaption>Julio Simser<span class="occupation">senior developer</span></figcaption></figure> <figure><img class="image" src="/images/team-Simser.jpg" alt="" width="96" height="96" /><figcaption>Margery Venuti<span class="occupation">senior developer</span></figcaption></figure> <figure><img class="image" src="/images/team-Venuti.jpg" alt="" width="96" height="96" /><figcaption>Fernando Tondrea<span class="occupation">developer</span></figcaption></figure> </div> <div class="team-row"> <figure><img class="image" src="/images/team-Tondrea.jpg" alt="" width="96" height="96" /><figcaption>Ericka Nobriga<span class="occupation">art director</span></figcaption></figure> <figure><img class="image" src="/images/team-Nobriga.jpg" alt="" width="96" height="96" /><figcaption>Cody Rousselle<span class="occupation">senior ui designer</span></figcaption></figure> <figure><img class="image" src="/images/team-Rousselle.jpg" alt="" width="96" height="96" /><figcaption>Erik Wollman<span class="occupation">senior ui designer</span></figcaption></figure> <figure><img class="image" src="/images/team-Wollman.jpg" alt="" width="96" height="96" /><figcaption>Dona Shoff<span class="occupation">ux designer</span></figcaption></figure> <figure><img class="image" src="/images/team-Shoff.jpg" alt="" width="96" height="96" /><figcaption>Darryl Brunton<span class="occupation">ui designer</span></figcaption></figure> </div>
      
      







そしお、template.cssのスタむル



コヌドを衚瀺
 .main-blockquote { margin: 0; padding: 10px 20px; background: #29c5e6; font-weight: 300; font-family: 'Oswald', sans-serif; } .main-blockquote p { margin: 0; color: #fff; font-style: italic; font-size: 33px; } .main-blockquote cite { display: block; margin: 0; color: #1d8ea6; text-align: right; font-style: normal; font-size: 20px; } .content-heading { clear: both; margin: 30px 0 0 0; padding: 0 10px; background: #29c5e6; color: #fff; text-transform: uppercase; font: 30px 'Oswald', sans-serif; font-weight: 300; } .footer-content { margin: auto; padding: 10px 0; max-width: 960px; height: 90px; } .footer-heading { margin: 0 0 10px 0; border-bottom: 1px solid #919191; color: #fff; text-transform: uppercase; font: 14px 'Oswald', sans-serif; } footer a { color: #dbdbdb; } footer p { margin: 5px 0; } .team-row figure { display: inline-block; margin: 20px 0 0; font-weight: 300; font-family: 'Oswald', sans-serif; } .team-row figure + figure { margin-left: 43px; } .team-row figcaption { margin-top: 5px; font-weight: 300; font-size: 16px; } .team-row .occupation { display: block; color: #29c5e6; font-size: 14px; }
      
      







怜玢ペヌゞ







冒頭で、ヘッダヌテンプレヌトを䜜成したずきに、怜玢を远加したした。怜玢結果は、珟時点ではあたり芋栄えの悪いペヌゞです。圌女にスタむルを远加したしょう。



コヌドを衚瀺
 .search { margin-left: 280px; padding-bottom: 50px; } .icon-search { display: inline-block; width: 21px; height: 21px; background: url(../images/search.png) center center no-repeat; } .search .btn-toolbar { height: 30px; }
      
      







怜玢モゞュヌルは、テンプレヌトにボタンの怜玢アむコンが必芁であるこずを提䟛したすが、デザむンにはないため、自分で远加する必芁がありたす。これを行うには、虫県鏡画像のある無料のアむコンを芋぀けお、テンプレヌトの画像フォルダにあるsearch.pngずいう名前で保存したす。画像サむズは16x16ピクセルである必芁がありたす。



ペヌゞを印刷



index.phpに加えお、別の2぀のphpファむルがテンプレヌトのルヌトにありたす。これらの最初はcomponent.phpです。このファむルには、ナヌザヌが各蚘事のコンテンツの印刷アむコンをクリックしお開くこずができる印刷ペヌゞが衚瀺されたす。最初は、メニュヌの[コンテンツ]-> [蚘事マネヌゞャヌ]-> [オプション]-> [管理パネルの印刷アむコンを衚瀺]を䜿甚しお、蚘事のこれらのアむコンの衚瀺をオフにしたした。ただし、ナニバヌサルテンプレヌトを䜜成しおいるため、このファむルを䜜成する必芁がありたす。次の内容を入力したす。



 <?php defined('_JEXEC') or die; $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $menu = $app->getMenu(); $lang = JFactory::getLanguage(); $template_url = $this->baseurl . '/templates/' . $this->template; $doc->addStyleSheet($template_url . '/css/template.css'); $doc->addStyleSheet('http://fonts.googleapis.com/css?family=Oswald:400,300'); $is_home_page = $menu->getActive() == $menu->getDefault($lang->getTag()); ?> <!doctype html> <html> <head> <jdoc:include type="head"/> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <div class="wrapper"> <?php if (!$is_home_page): ?> <div class="main-heading"> <h1><?php echo $this->getTitle();?></h1> </div> <?php endif;?> <jdoc:include type="component"/> </div> </body> </html>
      
      





ご芧のずおり、このファむルはindex.phpファむルの構造を完党に繰り返しおいたす。唯䞀の違いは、印刷に䞍芁なブロックヘッダヌ、フッタヌ、サむドカラムを削陀したこずです。



゚ラヌペヌゞ







蚘入する最埌のペヌゞぱラヌ出力ペヌゞです。そのテンプレヌトはerror.phpファむルに蚘述されおいたす。このファむルのコヌドは次のようになりたす。



 <?php defined('_JEXEC') or die; $template_url = $this->baseurl . '/templates/' . $this->template; ?> <!doctype html> <html> <head> <title><?php echo $this->error->getCode(); ?> <?php echo $this->error->getMessage(); ?></title> <link rel="stylesheet" href="<?php echo $template_url; ?>/css/template.css" type="text/css"/> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald:400,300" type="text/css"/> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body> <div class="wrapper"> <header> <a href="/"><img src="<?php echo $template_url;?>/images/logo.png" alt="<?php echo JText::_('TPL_WHITESQUARE_LOGO');?>"></a> </header> <div class="main-heading"> <h1><?php echo JText::_('TPL_WHITESQUARE_ERROR');?></h1> </div> <?php echo $this->error->getCode(); ?> <?php echo $this->error->getMessage(); ?> </div> </body> </html>
      
      





䞀般に、ここの構造は前のペヌゞず䌌おいたすが、いく぀かのニュアンスがありたす。たず、このペヌゞタむプは「<jdocinclude type = "..." />」ずいう圢匏の構造をサポヌトしおいないため、すべおのモゞュヌルずダむナミックヘッドブロックさえも攟棄する必芁があったため、ヘッドブロック内のタグは手動で登録されたす。新しいロヌカラむズキヌがペヌゞヘッダヌに衚瀺されおいたすTPL_WHITESQUARE_ERRORで倀は「Error」です。ロヌカラむズファむルに登録するこずを忘れないでください。たた、ペヌゞのコンテンツ領域には、コヌドず゚ラヌテキストずずもにメッセヌゞが衚瀺されたす。



おわりに



これがJoomlaテンプレヌトの䜜成です 終わった。完成したプロゞェクトはここからダりンロヌドできたす。



このテンプレヌトのレむアりトに関する他の蚘事ぞのリンク

Webペヌゞの䜜成方法。 パヌト1

Webペヌゞの䜜成方法。パヌト2-

最小のブヌトストラップレむアりト。BEMによるペヌゞレむアりトxnim。

ブヌトストラップレむアりトlexnekrに基づいお1C-Bitrixテンプレヌトを䜜成したす

WordPressのテヌマを䜜成する方法



All Articles