FLEXIcontentでは、コンテンツ内容を表示させるための「テンプレート」を設定できます。
Joomla!にインストールして「テンプレート」とは別物なのに同じ名前なので非常に紛らわしいです。
2種類の「テンプレート」
Joomla!で普通に使うテンプレートは、エクスンテンションマネージャーに現れる方の「テンプレート」です。
CCKとしてFLEXIcontentを使う場合には、追加で「テンプレート」が作られますが、これはページのコンテンツを表示させるラッパーとして働く「テンプレート」です。
FLEXIcontentの「テンプレート」で作られたページコンテンツを表示するのがJoomla!の「テンプレート」です。
ややこしいにも程があります。Joomla専用なのだから、紛らわしい名前を付けないで欲しいです。
FLEXIcontentテンプレート
FLEXIcontent上のテンプレートはインストール直後には、
- blog
- default
- faq
- item-tabbed
- presentation
の5つのテンプレートが定義されていて、これを変えながら表示を制御していきます。

FLEXIcontentのテンプレート「blog」
それぞれのテンプレートごとに、記事タイプ別に単一記事を表示する場合と記事をリスティングする場合で、違うレイアウトを設定しますが、
- 個別記事
- Basic
- Modular
- リスティング
- Columned listing
- Table listing
- Per sub-category placement
- Tab / slider item placement
- Modular listing
と合計で7つが作られています。
PHPコード
これを個別に設定していきますが、表示を実際に制御しているPHPファイルがBasicの場合には
- item.php
- item_html5.php
です。これらのファイルを書き換えた場合には、FLEXIcontentをアップデートすると上書きされて変更内容が失われてしまいます。(FLEXIcontentのコンポーネント上で書き換えようとする場合には、警告されます)
常にitem.phpが呼び出され、FLEXIcontentテンプレート(Basic)のDisplay ParametersとしてHTML5が設定されている場合にitem_html5.phpをitem.phpから呼び出しています。
Use Globalは現行バージョンの3.0.8ではPHPコード、つまりitem.phpに設定されたデフォルト、xHTMLが使われます。
フィールド内容の呼び出し
記事のコンテンツ表示ですから、記事の内容と各種フィールドの読み込みが行われます。GUIである程度設定できますが、呼び出すときにはPHPコードで
<?php echo $this->item->プロパティ名; echo $this->fields['フィールド名']->value; ?>
などで表示させることが出来ます。詳しくは、FLEXIcontentのチュートリアルテンプレート4に書かれていますが、消えると嫌なので転載しておきます。
これらの機能は、記事コンテンツからしかアクセス出来ません。つまり、モジュールなどからはアクセス不能です。(無理やり、現在表示しているページのアイテムIDを使ってデータベースクエリで取得することはできます)
Item
This object contains all information regarding your own content
You can call it this way $this->item->”property”
id Identifier in the database title title alias alias introtext Introduction text fulltext All the text state Status of publication (1 : publish, 0 : not publish, -1 : archived, -2 : delete, -3 : pending, -4 : draft, -5 : in progress ) sectionid Section catid Main category created Creation date created_by Author id created_by_alias Author alias modified Last modification date modified_by Id of the last author who has modified section publish_up Start date of publication publish_down End date of publication version Version id ordering Number indicating the rank order metakey Keywords meta data metadesc Description of meta data metadata Metadata robots and author access Access Level (0 : public, 1 : private, 2 : special) hits Number of visits item_id Content id type_id Type id language Language (fr-FR, en-US) search_index All text is indexed for search cataccess Access level of the category (0 = public, 1: Private 2: Special) catpublished Indicates whether the category is published or not author Author name usertype Group name of the User typename Label the type of content creatoremail Email the original creator modifier Name of last author who made a change text Text (description field) to be displayed in the template (introduction or full text) cats Table listing the categories associated (cats [x] -> id, cats [x] -> title …) fields See details in the next chapter item->fields readmore_link Way to link to the “read more» positions See details in the next chapter item->Positions fieldvalues List the value of fields in a table (FieldValues [id_du_champs] [x]) favs Number of users who added the content in their favorite fav Indicates whether the content can be placed in favorites vote Object with the following values: rating_sum (average value of votes), rating_count(votes) lastip (last ip address voting). creator Creator name item->fields or fields
This way you can get all the information about the fields in your template, either for the core fields (title, text, created, created_by, modified, modified_by, hits, document_type, version, state, voting, favorites, categories , tags) but all your custom fields (as you have named them) that are associated with the type being displayed.
You need to call it this way $this->item->fields[‘field name’]->”property” or so $this->fields[‘field name’]->”property”
id Fields id field_type Field type name Field name label Field label description Field description isfilter Return true if this is a filter iscore isearch The field is being used for search ? isadvsearch The field is being used for advanced search ? published Published or not ? access Access Level (0 : public, 1 : private, 2 : special) ordering Number indicating the rank order value Value of the field display Show the formated value of the field Each field also has parameters that can be recovered in this way (object JParameter:)
$this->item->fields[‘field name’]->parameters->get(‘parameter’)
Here are the main parameters that can be found, not all are used depending on the type of field.
display_label Display the label emove_space Delete spaces pretext Prefix posttext Suffix default_value Default value allow_multiple Allow multiple value max_value The number of value maximum size The field size separatorf Separator values for the frontend opentag The open tag closetag The closing tag date_format Standard siplay format of date custom_date Custom display format date rows Number of ligne in the textarea cols Number of row in the textarea use_html The HTML editor is enabled ? item->positions
As we saw previously you can browse through all positions of a template to display your fields. Here are the details of the information you can use.
You need to call it this way $this->item->positions[‘name of position][‘field name’]->”property”
id Id of the field name Name of the field label Label of the field display Formated value of the field user
This object type juser gives you information about the user currently logged
A call in this way $this->user->”property”
id User id name Name of the user username Login of the user Email of the user usertype Address of the user registerDate Date of registration lastvisitDate Date of last connection params
It is an JParameter object that will allow us to find the settings related to the content.$ this-> params-> get (‘parameter’)
flexi_section FLEXIcontent associated section comments Enable input ( 0= no comment, 1 and 2 = JComments and JomComments) support_url Url Support flexi_fish Enable the Joomfish support filtercat Filter the category view filtertag Filter the tags view use_versioning Enable the versioning nr_versions Version stored show_title Content title link_title Link title show_readmore Read More link show_icons Icons show_pdf_icon Display PDF icon show_print_icon Display Print icon show_email_icon Display Email icon limit Number of element by page catlimit List limit (category) upload_extensions Allowed Extensions (File Types) upload_maxsize Max Size file_path Secure path to the directory media_path Secure path to the media restrict_uploads Restrict upload check_mime Check the MIME types image_extensions Extensions of images allowed (File Types) ignore_extensions Ignored Extensions upload_mime MIME types allowed enable_flash Enable the upload using flash feed_summary For each rss feed advcache Advanced cache adcache_time Time of the cache advcache_guest Only visitor disablecss Disable the css item_depth Item level add_item_pathway Add a path show_page_title Page title menu_image Image Menu secure Enable SSL page_title Display the page title page_description meta description menu_params
It is an JParameter object that will allows us to find the parameters associated with the content menu that must be displayed.
$this->menu_params->get('parameter')
item_depth Level of the element add_item_pathway Add a path page_title Page title show_page_title Show the page title pageclass_sfx CSS class suffix menu_image Image of the menu secure SSL active The flexicontent_html class
The flecicontent_html class offers some useful functions for our template.
Function striptagsandcut
This feature allows us to remove html tags from a text and cut cleanly after a certain number of characters.
1 2 // This exemple va will format and truncate $mon_texte after 100 characters echo flexicontent_html:: striptagsandcut ( $mon_texte,100 )Function extractimagesrc
1 2 // This exemple will generate a image tag with the needed parameters echo flexicontent_html:: extractimagesrc ( $this->fields[‘mon_champ_image’]);Function printbutton
This exemple will display the button and the link to print the current content
1 2 // Cet exemple will display the print icon in ou content echo flexicontent_html::printbutton( $this->print_link, $this->params );Function mailbutton
This exemple will display the button and the link to recomment the current content via email
1 2 // This example will display the icon Send by mail echo flexicontent_html::mailbutton( 'items', $this->params, null , $this->item->slug );Function pdfbutton
This will display the button and the link to generate active content in pdf
1 2 // This exemple will display an pdf icon into the active content echo flexicontent_html::pdfbutton( $this->item, $this->params )
GUIに落としこむ方法
コーディングは必要になりますが、GUIを使って表示場所を変えたりすることもできます。
まだ試していないので実際に働くかはわかりませんが、GUIで表示設定するときに呼び出して表示する関数を定義できることを使う方法です。
テンプレートチュートリアル2の後ろのほうに書かれています。
コメント