NetAssoBlog

200gr Web, a touch of marketing a hint of law ...
maxim

Tutorial - Template FLEXIcontent - Part4: The content of a template

February 23

In this fourth part I will present and explain the purpose FlexicontentViewItems that will allow us to achieve our template for Item. And so I will detail all the variables that can be helpful in building your own templates.

stadium toulouse I will also talk about a lot of functions that can be found with the class flexicontent_html.

This tutorial is still built around my example want to display information about a football stadium.


Contents:

  • The purpose FlexicontentViewItems
    • Display a set of field from a position
    • Displays a single field
    • Management comments
    • Do more ...
      • item
      • item-> fields or fields
      • item-> positions
      • use
      • params
      • menu_params
  • The class flexicontent_html
    • Function striptadsandcut
    • Function extractimagesrc
    • Function printbutton
    • Function mailbutton
    • Function pdfbutton

The purpose FlexicontentViewItems

This object usable in all template for Item will allow you to bring up all the information related to content.
It is accessible through the $ this variable.
I now resume my item.php file (created in part1 of this tutorial) and I will start by reviewing the header of my.


  A
 2
 3
 4
  / / Prohibits direct access to the file
  '_JEXEC' ) or die ( 'Restricted access' ) ; defined ('_JEXEC') or die ('Restricted access');
  / / Set here the name of the template, in our case. Items.stade
  $this -> tmpl ; $ Tmpl = $ this -> tmpl; 


We will initiate our template then place a div tag by adding css class personalized according to the stage 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:

  16
  $this -> item -> id ; ?> type <?php echo $this -> item -> type_id ; ?> "> <Div id = "stade_contenu" class = "item stade_contenu <? Php echo $ this -> item -> id;?> Type <? Php echo $ this -> item -> type_id;?>"> 

Display a set of field from a position

As we saw in part 1 of the tutorial, FLEXIcontent can manage different position where we can place our fields. This entitles the user to place these new fields without modifying the template code.

Just put in our template then a loop that will go through all the fields contained in a given position. Here is the code I would use for each of the positions that I created (header, address, contact, image, description, information, gmap, bottom):


  17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
  <! - BOF header ->
 <div id="stade_entete">
   ( isset ( $this -> item -> positions [ 'entete' ] ) ) : ?> <? Php if (isset ($ this -> item -> positions ['header'])):?>
     ( $this -> item -> positions [ 'entete' ] as $champ ) : ?> <? Php foreach ($ this -> item -> positions ['header'] as $ field):?>
       $champ -> name ; ?> "> <Div class = "Field_A <? Php echo $ field -> name;?>">
       ( $champ -> label ) : ?> <? Php if ($ field -> label):?>
         $champ -> label ; ?> </div> <div class="etiquette"> <? php echo $ field -> label;?> </ div>
       ; ?> <? Php endif;?>
       $champ -> display ; ?> </div> <div class="valeur"> <? php echo $ field -> display;?> </ div>
       </ Div>
     ; ?> <? Php endforeach;?>
   ; ?> <? Php endif;?>
 </ Div>
 <! - EOF header -> 


Explanation:

isset ($ this-> item-> positions ['header']) / / indicates whether the fields are displayed or not in this position
php foreach ($ this-> item-> positions ['header'] as $ field): / / search all the fields content 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 / / returns the label of the field where I chose my settings in the field I chose to make it appear.
$ Field-> display / / displays the field value formatted according to the parameters that I set up (prefix + value + suffix)

Displays a single field

It is also possible to display a field directly without the position. This can sometimes be 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."


  62
 63
 64
 65
 66
 67
 68
  <! - Soundtrack image ->
 <div id="stade_image">
 <div class="champ_image_stade">
 $this -> fields [ 'image_stade' ] -> display ; ?> <? Php echo $ this -> fields ['image_stade'] -> display;?>
 </ Div>
 </ Div>
 <! - EOF image -> 


To go directly to the values ​​and parameter fields, use the $ this-> fields ['myfield'].

Management comments

I only get the original source code of FLEXIcontent to bring up the comments:


  130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
  ( $this -> params -> get ( 'comments' ) ) : ?> <? Php if ($ this -> params -> get ('comments')):?>
  <! - BOF comments ->
  <div class="comments">
  <? Php
  $this -> params -> get ( 'comments' ) == 1 ) : if ($ this -> params -> get ('comments') == 1):
    file_exists ( JPATH_SITE . DS . 'components' . DS . 'com_jcomments' . DS . 'jcomments.php' ) ) : if (file_exists (JPATH_SITE. DS. 'components.' DS. 'com_jcomments.' DS. 'jcomments.php')):
      JPATH_SITE . DS . 'components' . DS . 'com_jcomments' . DS . 'jcomments.php' ) ; require_once (JPATH_SITE. DS. 'components.' DS. 'com_jcomments.' DS. 'jcomments.php');
      showComments ( $this -> item -> id , 'com_flexicontent' , $this -> escape ( $this -> item -> title ) ) ; echo JComments: showComments ($ this -> item -> id, 'com_flexicontent', $ this -> escape ($ this -> item -> title));
    endif;
  endif;

  $this -> params -> get ( 'comments' ) == 2 ) : if ($ this -> params -> get ('comments') == 2):
    file_exists ( JPATH_SITE . DS . 'plugins' . DS . 'content' . DS . 'jom_comment_bot.php' ) ) : if (file_exists (JPATH_SITE. DS. 'plugins'. DS. 'content'. DS. 'jom_comment_bot.php')):
      JPATH_SITE . DS . 'plugins' . DS . 'content' . DS . 'jom_comment_bot.php' ) ; require_once (JPATH_SITE. DS. 'plugins'. DS. 'content'. DS. 'jom_comment_bot.php');
      $this -> item -> id , 'com_flexicontent' ) ; JomComment echo ($ this -> item -> id, 'com_flexicontent');
    endif;
  endif;
  ?>
  </ Div>
  <! - EOF comments ->
 ; ?> <? Php endif;?> 

Through $ this-> params-> get ('comments'), it allows me to retrieve the parameters of FLEXIcontent and so I have to show whether or not commantaires. (0 = no comments, 1 = 2 = JComments and Jom Comment)
FLEXIcontent can integrate the management comments of two components JComments (recommended) and Jom Comment.
So the parameters for the comments are directly managed via 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 into your template. Here are the most important information you can use in your template.

Item

This object contains all information about your content directly
A call in this way $ this-> item-> "ownership"

id

ID in the given base

title

Title

alias

Alias

introtext

Introductory text (that corresponds to the description field is preferred)

fulltext

Full text (that corresponds to the description field is preferred)

state

State Publishing (1: published 0: Unpublished -1: archived, -2: deleted, -3: awaiting approval, -4: Draft, -5: in progress)

sectionid

Section

catid

Main Category

created

Creation date

created_by

Identifying the author

created_by_alias

Alias ​​of the author

modified

Last updated

modified_by

Id last author has amended section

a.publish_up

Start date of publication

publish_down

End date of publication

version

Version Number

ordering

Number indicating the rank order

metaKey

Keywords meta data

metadesc

Description of meta data

metadata

Robots and Author meta data

access

Level of access (0: public, 1: Private 2: Special)

hits

Number of visits

idem_id

Id content

type_id

Identifying the type of content

language

Language (en-US, 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

Name of author

usertype

Group name of the user

typename

Label the type of content

creatoremail

Email the creator of the original

creator

Name of creator

change

Name of last author having made a change

text

Text (field description) 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 that have 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 (ip voting last address).

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, but all your custom fields (such as you have named) that are associated with the type being displayed.
A call in this way $ this-> item-> fields ['field name'] -> "property" or so $ this-> fields ['field name'] -> "ownership"

id

Id field

field_type

Field Type

name

Field Name

label

Label of field

description

Field description

IsFilter

This field is there a filter?

iScore


isearch

The field is being used for research

isadvsearch

The field is 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 table entry field

display

Viewing the formatted value of the field.

Each field also has parameters that can be recovered in this way (subject 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 panel

remove_space

Remove spaces

Pretext

Prefix

posttext

Suffix

default_value

Default

allow_multiple

Allow multiple values

MAX_VALUE

Maximum value

size

Field Size

separatorf

Separator values ​​for the frontend

OpenTag

Previous tag value

closeTag

Tag succeeding value

date_format

Standard display format of date

custom_date

Custom display format of date

rows

Number of rows in a textarea

passes

Number of columns in a textarea

use_html

The HTML editor is enabled?

item-> positions

As discussed previously you can browse through all positions of a template to display your fields. Here is the detailed information you can use.
A call in this way $ this-> item-> positions ['name of position] [' field name '] -> "ownership"

id

Id field

name

Field Name

label

Label of field

display

Formatted value of the field

use

This object type juser gives you information about the currently logged
A call in this way $ this-> user -> 'property'

id

ID of the user

name

Name

username

User login

e-mail

Email address of the user

usertype

Type of User

registerDate

Date of registration

lastvisitDate

Date of last connection

params

It is an object JParameter that will allow us to find the parameters related to the content.
$ This-> params-> get ('parameter')

flexi_section

Section associated with FLEXIcontent

comments

Enable input (0 = no comments, 1 = 2 = JComments and Jom Comment)

support_url

Support URL

flexi_fish

Enable support Joomfish

filtercat

Filter categories views

filtertag

Filter views tags

use_versioning

Enable versioning

nr_versions

Versions kept

show_title

Title of content

link_title

As clickable

show_readmore

Link Read more ...

show_icons

Icons

show_pdf_icon

PDF icon

show_print_icon

Print icon

show_email_icon

Email icon

limit

items per page

catlimit

Limit lists (categories)

upload_extensions

Allowed Extensions (File Types)

upload_maxsize

Maximum size

file_path

Secure path to the directory

media_path

Media path to the directory

restrict_uploads

Restrict uploads

check_mime

Check MIME types

image_extensions

Extensions of images allowed (File Types)

ignore_extensions

Extensions ignored

upload_mime

MIME types allowed

enable_flash

Enable upload Flash

feed_summary

For each RSS feed

advcache

Advanced Cache

advcache_time

Duration of the cache

advcache_guest

Visitors only

disablecss

Disable CSS

item_depth

Item Level

add_item_pathway

Add to path

show_page_title

Page Title

menu_image

Menu image

secure

Active SSL

page_title

Show the title of the page

page_description

Meta description

menu_params

It is an object JParameter that will allow us to recover the parameters associated with the menu of the contents that must be displayed.
$ This-> menu_params-> get ('parameter')

item_depth

Item Level

add_item_pathway

Add to path

page_title

Page Title

show_page_title

Show the title of the page

pageclass_sfx

CSS Class Suffix

menu_image

Menu image

secure

Active SSL

The class flexicontent_html

This class of FLEXIcontent offers some useful features for our templates.

Function striptagsandcut

This feature allows us to remove html tags from a text and cut cleanly after a certain number of characters.

  / / This example will format and truncate after 100 characters $ my_text
 striptagsandcut ( $mon_texte , 100 ) ; echo flexicontent_html: striptagsandcut ($ my_text, 100); 


Function extractimagesrc

This feature allows us to generate an image tag from a field of type image.

  / / This example will format and truncate after 100 characters $ my_text
 extractimagesrc ( $this -> fields [ 'mon_champ_image' ] ) ; echo flexicontent_html: extractimagesrc ($ this -> fields ['mon_champ_image']); 


Function printbutton

This function displays the button and the link to print the current content

  / / This example will display the Print icon in our content
 printbutton ( $this -> print_link , $this -> params ) ; echo flexicontent_html: printbutton ($ this -> print_link, $ this -> params); 


Function mailbutton

This function displays the button and the link to recommend active content in mail

  / / This example will display the icon Send mail to our content
 mailbutton ( 'items' , $this -> params , null , $this -> item -> slug ) ; echo flexicontent_html: mailbutton ('items', $ this -> params, null, $ this -> item -> slug); 


Function pdfbutton

This function displays the button and the link to generate active content in pdf

  / / This example will display the icon in our PDF content
 pdfbutton ( $this -> item , $this -> params ) ; echo flexicontent_html: pdfbutton ($ this -> item, $ this -> params); 



This is the fourth game is over, the next time I will address the templates category. Once again please make your comments or to ask questions if you do not understand something.





















i. item-> positions

















Category: Web

Comments

On 24/02/2010 at 09:18, Emmanuel Danan said:

Emmanuel Danan

Wow, what synthesis :) One word: BRAVO!
Thank you to you for this new contribution.
Manu.

On 24/02/2010 at 09:31, Maxim said:

maxim

This tutorial would not exist without your component ;) And thank you

On 24/02/2010 at 09:38, Micke said:

Micke

.... I am speechless!
bravo

On 01/03/2010 at 15:43, Helio said:

Helio

A big THANK Maxime :)

With the superb series of tutorials you gave us with the news we got from Emmanuel and the team behind Flexicontent Flexiaccess and reports of the release of a prominent stable version of its two components I think we have what it takes to start producing very promising results with Flexicontent.

It seems to me that with the flexibility of Flexicontent the only limit seems to be our imagination :)

Again a big thank you to you for these beautiful Maxime tutorials and another big thank you to the team Flexicontent.

On 01/03/2010 at 19:32, Eric said:

Eric

Thank you for this tutorial, unfortunately I can not call a field directly, it does not work!

I explained the process, and as a result, I have nothing that appears and two references:
Notice: Undefined index:
Notice: Trying to get property of non-object

And nothing :-(

Do you have an idea where the problem may come? Thank you in advance,

Eric

On 03/03/2010 at 09:58, Maxim said:

maxim

Eric, can you tell me the code you wrote so I know exactly the cause of your problem?

On 04/03/2010 at 16:39, Nathaniel said:

Nathaniel

I'm pretty beginner in web design, however I managed to just about to turn FLEXIcontent which I think is the best tool currently possible to create a catalog when the specification is unclear.

When I call the functions printbutton pdfbutton and I have a text in English and not just a lousy image. I do not understand why.

I surely can not be gifted but anyway thank you for this tutorial and this fantastic tool, it achieves a new level in the content management.

On 04/03/2010 at 17:09, Maxim said:

maxim

FLEXIcontent check if images are present in the directory images / M_images / ', if they are not present then it displays text.
Images must be named respectively:
printButton.png
emailButton.png
pdf_button.png

You probably had to remove the images from your media ...

On 05/03/2010 at 12:57, Eric said:

Eric

> Maxim: thank you for your answer. I reinstalled everything and put the same code, and this time it works. I had to delete something the first time that prevented proper operation. Thank you again for this tutorial!

On 15/03/2010 at 15:31, Nathaniel said:

Nathaniel

Thank you for the answer. When I use PDF tool I have an old error message in the body of the pdf:

Warning: Invalid argument Supplied for foreach () in / home / xxxxxxx / public_html / joomla / components / com_flexicontent / views / items / view.pdf.php
on line63:

foreach ($ fields as $ field) {

This is a bug FLEXIcontent it not?

On 16/03/2010 at 15:48, Maxim said:

maxim

Yes indeed I have already met this problem too. it must come from a type of Fields mismanaged for generating the pdf ... in short I have not pushed my research the best in my opinion is that you ask the question (or you're looking for) in the forum FLEXIcontent. http://www.flexicontent.org/forum/

At 01:04 on 19/03/2010 Karim said:

Karim

hello;
I followed the tutorial from one and thank you for everything you did.
but I'm stuck on the 3
when you said:

1 - see the header of my item.php (I leave the same file name and place in a new directory) is that the new directory and name of the temlate should I wear?

2 - when I place <div id="stade_contenu" class="stade_contenu itemitem-> id;?> Typeitem-> type_id;?> "> (Nothing appears)

3 - when I put the loop It m'affiche a column when I copy and paste the same loop for the other field, there is only the first field display.

4 - when I remove the line (<div id="stade_contenu" class="stade_contenu itemitem-> id;?> Typeitem-> type_id;?> ") It always displays a single field

I think I did not understand what to put.
puije send you what I did in MP?

Greetings

At 17:13 on 19/03/2010 Karim said:

karim

Hello and thank you for the tutorial
at first I did not catch exactly what to do, but when I understood the need to create a class file, which I can not know itself because I am a beginner, everything worked.
for Item, I could customize my display almost as I want! (I must of course CSS), but when I wanted to attack the template for the category, it did damage.

I want to know which files and cover, and it possible to have the same reasoning for the category for Item?
ps: a tutorial when the classes?

Thank you and greetings

On 22/03/2010 at 20:13, Maxim said:

maxim

I'm back in the place, after our little excursion to JoomlaDay.
To tell you the truth I have not really grasped your problem Karim. Would need you to explain exactly what you want to do and where you blocked.
Regarding the last part (tutorial class template), it is being written. I admit that my schedule is pretty full right now but I hope to publish by next weekend.

On 22/03/2010 at 20:17, Maxim said:

maxim

I also wanted to return to the issue of Nathaniel because I had the answer to JoomlaDay this weekend. The PDF it does not work : P At least it has the merit of being clear.
Exsitent professional solutions but we must be ready to release $ 2,000 for a license ...

On 14/04/2010 at 15:41, erix said:

erix

Hi,

First of all thank you for coming to JoomlaDay, your summary on this blog was one of what I was most pleased to read, then I wanted to thank you warmly for your tutorial pages that are really a spare for while those looking to customize a little (lot?) FLEXIcontent them.

It is clear, detailed, very educational, editorial quality and a reproach. You understood it been a while since I used to refer to your pages from the forum joomla.fr (and I just dig into it too).

Good luck to you!

On 05/07/2010 at 12:40, Gael said:

Gael

Thank you for this doc that I did not find the site of FLEXIcontent.

I do have one question: I need to use the values ​​"raw" unformatted, one of my field.
But with the value attribute, I end up with more values ​​in both value [0] in the form of text separated by commas.
Is that a function is already implemented in Flexicontent to retrieve the value I'm interested (in this case, for example, the URL of a weblink)?

On 05/07/2010 at 17:31, Maxim said:

maxim

I think I understand your problem, you need use the php: unserialize ($ str);
More info here http://php.net/manual/fr/function.unserialize.php

On 15/07/2010 at 09:28, Jay said:

Jay

Hello. waiting for your template tutorials.!
thanks so far for the hard work.

On 15/07/2010 at 09:33, Maxim said:

maxim

Yes i know, i have to do it ... i just miss the time for the moment ... but one day i swear ;)

On 28/07/2010 at 09:26, Gael Boyenval said:

Gaël Boyenval

Super tutorials ... really well done, the best source to some days I find on the web for FC!
I am eagerly waiting part 5! To when?

On 28/07/2010 at 11:18 AM, Maxim said:

maxim

Thank you, part 5 is in an area that I have to dust off. I am currently on other projects. But it will happen one day promised, I do not get me more in terms of time now : War:

On 21/03/2011 at 13:02, Damien said:

Damien

Hello, after the discovery of this tutorial, well done and very educational, I have a display problem in my article. I did change as described above but unfortunately I only have the "core fields" that appears on my page and not at all those I create in the same tutorial. You can upload your file "item.php" or a demo page that could allow me to better understand the principle display STP! Thank you in advance and congratulations for this great job : D

On 21/03/2011 at 16:15, Maxim said:

maxim

Hello,
I think if you have your custom fields that have not been assigned to one area of ​​your template. We must go FLEXIcontent, then in the template section. Select the template you want to change and affect your fields in the areas in question. I think this should suffice. let me know.

On 21/03/2011 at 16:39, Damien said:

Damien

I managed to display the fields created by changing the tutorial item.php (php code instead of html).
By cons, they are all aligned to the left on my page, not at all as provided in the template.png. In the tutorial part 1, for setting the file you item.php explains that we will return it later but I do not see or? I think it's in that file that sets the positions of every field! But how do have?? : S

On 21/03/2011 at 16:49, Maxim said:

maxim

The position of the field depends on the CSS file. This requires that you apply CSS properties needed to make the right alignments.

On 21/03/2011 at 17:10, Damien said:

Damien

OK, I'll try to compare the pages of the blog template with the stage for better understanding. Just one last question, the. CSS (item.css) that you posted part1 does not place the fields as shown in the file "item.png"?

PS: It must sound silly to you all these questions, sorry to pollute the page (A)

On 22/03/2011 at 09:58, Damien said:

Damien

Hello, I found why the CSS does not work in your chapter "Display a set of field from a position" you put in the first line:

After comparison with the template "default", I changed "<div id =" to "<div class =" and everything works 8)

For me to play with CSS to get what I want : Crazy:

On 22/03/2011 at 11:23, Maxim said:

maxim

So perfect ;)
Just for information one id is defined with a # (hash) in the CSS file, while the class is defined with only one. (Point) but in the end CSS properties are the same.

On 24/03/2011 at 04:41, greg said:

greg

Hello,

Is it possible to retrieve a page and list all the information of a field that was defined in another type of page?

example I set for each page "Country" field a "Visa" which entered its "price" and I would like to recover all of the price of visas per country in a single page. Is it possible Flexicontent?

Thank you in advance for the answer.

On 24/03/2011 at 12:26, ​​Maxim said:

maxim

Hello,
I think this is possible through a new type that you can create a field of type "select multiple" and make a sql query to display the list of values ​​associated with it.
The alternative would be to change the template of the class associated with the type and list the field values.
Both solutions require some technical skills that I can not detail because of time.

On 06/12/2011 at 11:58, Jean-Francois said:

Jean-Francois

Hello Maxime;
A big thank you for your very clear explanations, thanks to them I decided to use Flexicontent for a site that I am preparing.
I begin, but I hope to get there.

I followed your tutorial, but one thing I do not know resolve: when viewing content Frontend, there is a line break between the label and the field value.

I looked in the CSS, but impossible for me to find the solution.

So if you had an idea of ​​line of research.
It would help me.

I use Joomla 1.5.25 Practical information, Flexicontent version: 1.5.4 (r558).
So I'm testing locally with EasyPHP.

On 06/12/2011 at 22:40, Jean-Francois said:

Jean-François

I answer myself to my question.
Here's the code I created:

item-> positions ['address'])):?>
item-> positions ['address'] as $ field):?>
<div class="champ_name; ?> ">
label):?>
label;?> display;?>

display;?>

So it works for me. It seems that we have to repeat this for all loop positions.

Hope this can help others.
Cordially.

On 06/12/2011 at 22:41, Jean-Francois said:

Jean-François

Sorry but it seems that the code is not displayed correctly.

On 07/12/2011 at 09:33, Maxim said:

maxim

Hello to better answer your questions, we set up a forum on the site http://extensions.netassopro.com/ . Thank you to submit your questions in the appropriate section to share your concern with the community.

The email will not be displayed

Example of website

Your comment:

| -)] O);): |: War:: Star:: S: Pizza:: Pig:: Phone:: P: Monk:: Listen:: Jail:: Idea:: Happy:: Halloween:: Haha:: Girl:: Ghost:: Drink:: D: Crazy:: Cold:: Cloudy:: @:): ($8)(L)(A)(L)(6)