This tutorial is offered by NetAssoPro, you can find all components, modules and plugins for FLEXIcontent here
NOTE : This tutorial is actualy good, but we work on it to update it with new option introduce in stable version.
In the part 4, I will present and explain the purpose FlexicontentViewItems that will allows us to achieve our template for Item. And so I will detail all the variables that can be helpful in building your own templates.
I will also talk about a lot of functions that can be found with the class flexicontent_html.
This tutorial is always built around my example will display information about a football stadium.
This object is usable in all template in Item view, and will allow you to bring up all the information related to content.
It is accessible through the variable $this.
I now resume my item.php file (created in the part1 of this tutorial) and I will begin by reviewing the header of my.
We will then introduce our template set with a div tag by adding customized css class depending on the stadium and type of content. For this I use:
$this->item->id = returns the identifier of the content
$this->item->type_id = returns the identifier of the type of content
It gives that :
1 |
<div id="stade_contenu" class="stade_contenu itemitem->id; ?> typeitem->type_id; ?>">
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<!-- BOF entete -->
<div id="stade_entete">
<?php if (isset($this->item->positions['entete'])) : ?>
<?php foreach ($this->item->positions['entete'] as $champ) : ?>
<div class="champ_<?php echo $champ->name; ?>">
<?php if ($champ->label) : ?>
<div class="etiquette"><?php echo $champ->label; ?></div>
<?php endif; ?>
<div class="valeur"><?php echo $champ->display; ?></div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<!-- EOF entete -->
Explanation : isset ($this->item->positions['header']) // indicates whether the fields should be displayed or not in this positionphp foreach($this->item->positions ['header'] as $field) / / search all the content fields of the position$field->name // returns the name of the field, I use it to declare a unique CSS class that will allow me then to format my field as I want$field->label // return the label of the field if I chose my settings in the field I chose to make it appear.$field->display // display the field value formatted according to the parameters that set up (prefix + value + suffix)
Display a single field
It is also possible to directly display a field without the position. This can be sometimes useful to make a simple template without any positions (which are heavier in terms of code). I will use this part of code to display my image "image_stade."
1
2
3
4
5
6
7
<!-- BOF image -->
<div id="stade_image">
<div class="champ_image_stade">
<?php echo $this->fields['image_stade']->display; ?>
</div>
</div>
<!-- EOF image -->
To access directly to the values and parameter fields, use the $this->fields['myfield'].
Comments Management
I only get the original source code of FLEXIcontent to bring up the comments:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php if ($this->params->get('comments')) : ?>
<!-- BOF comments -->
<div class="comments">
<?php
if ($this->params->get('comments') == 1) :
if (file_exists(JPATH_SITE.DS.'components'.DS.'com_jcomments'.DS.'jcomments.php')) :
require_once(JPATH_SITE.DS.'components'.DS.'com_jcomments'.DS.'jcomments.php');
echo JComments::showComments($this->item->id, 'com_flexicontent', $this->escape($this->item->title));
endif;
endif;
if ($this->params->get('comments') == 2) :
if (file_exists(JPATH_SITE.DS.'plugins'.DS.'content'.DS.'jom_comment_bot.php')) :
require_once(JPATH_SITE.DS.'plugins'.DS.'content'.DS.'jom_comment_bot.php');
echo jomcomment($this->item->id, 'com_flexicontent');
endif;
endif;
?>
</div>
<!-- EOF comments -->
<?php endif; ?>
Through $this->params->get ('comments'), it allows me to recover the parameters of FLEXIcontent and so I have to show whether or not comments. (0 = no comment, 1 = JComments and 2 = Jom Comments).
FLEXIcontent can integrate the management comments of two components JComments (recommended) and Jom Comment.
So the parameters for the comments are directly managed through the component that is integrated.
Do More...
Through the following chapters, I showed you how to display fields so basic, it may be that sometimes you need to go a little further in your template. Here are the most important information you can use in your template.
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
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
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 )
The part 4 of the tutorial is over, the next time I will approach the templates category. Once again feel free to feedback or to ask questions if you do not understand something in the forum.