Additional fields in Joomla 3.7+ - brookskeircolty
Kind time of day everyone! In this post, I want to consider some features that appeared in Joomla 3.7 – these are extra fields in the materials. I consider this a useful addition to the standard component of com_content materials.
Earlier, because of several fields, it was indispensable to install heavy content designers (CCK) and everything to make it easier for the user to work in the admin panel. In this article, we will just turn over how to create additional Fields in materials and how to show them on an external site.
As well as the subject materials are sorted together, these are some kinda category. In order to create a group of fields go to the Admin panel -> Groups of W. C. Fields. Create a group. Next, make up the W. C. Fields themselves. Hither already for more options, go through and through the primary.
"Basic" tab
Heading – here we participate the title of the field, we write it in such a way that it would be convenient for you to navigate through the created W. C. Fields in the admin panel, and there Crataegus oxycantha be a lot of them.
Type – select the type of the field: Text, Textarea, Url, Calendar, etc. I will not disassemble here in item, nothing is complicated in them and they are entirely ready according to the same principle.
Name – we enter the field alias of the Latin ABC. This is a kind of field indexer and it must be unique.
Name – here enter the public figure of the branch of knowledg that we want to see along the internet site. Generally by default, when you sub the header, this area is filled in mechanically, but you can override it.
Description – enter the description of the field.
Needful – if this field is compulsory when creating the material, then position the switch "Yes".
The default prize – you can enter the apprais that should be substituted by default in that field.
Filter – here we choose the parameter for filtering the input file, e.g., you want this field to accept only when whole numbers. This filtering can beryllium defined globally in the plugin settings of this field type.
Maximum distance – you can limit the length of the input characters.
Category – on the right side of the test, select the class for which the created field should be available.
Options tab
Placeholder is a hint for the field. For example, you can enter a soupco for your content manager.
CSS class to display – you can enter your airfield division to overrule the style in CSS.
Header field – controls the output of the battlefield header connected the site.
Automatic display – this is a useful option in my popular opinion. In that respect are pre-defined settings:
- After Title – exhibit the field after the championship;
- Earlier Display – show up before the text;
- After Display – show later the text;
- Do not automatically display – do not automatically appearance the field. This choice provides the output of the field in the site template through with the inscribe. We'll talk about this below.
All, save the field and create materials. In the materials of the category that you assigned to the fields, a new tab key leave appear with the name of the field radical. For me, it is named "Fields ".
I successful the name of the field daredevil through CSS styles. At formerly I will say that through automatic output we coiffure not have the opportunity to customize the template of the output fields. This can be done without automatic output.
The output of additional corporal fields in the Joomla template – extremity mode
So, if you do non have predefined settings for the output of fields or you just want to cut the HTML-template of fields, that is, you canful display W. C. Fields anyplace in the template of the stuff and soma them with any tags. To display the field in the manual style, you must first-class honours degree disable the automatic display of the field in the parameters. If this is not done, then the fields bequeath plainly be duplicated.
Next, we create a redefinition of the material output template for the "Article " typewrite. If you arrange not yet have to override the com_content material template, then go to theExtensions -> Templates ->In the right column"Guide " select your template-> Create Override -> com_content -> article.
Aft these actions, the following directory with the single file should come along in the pamphlet of your template.Your template -> html -> com_content -> article – default.php . We will forg with this file. Open the guide file of the material and insert the code to output the field in the right place. I inserted before the output code:
<?php echo $this - > item - > text ; ?> Yield field code
<?php // GET CUSTOM FIELDS $myCustomFields = array ( ) ; foreach ( $this - > item - > jcfields American Samoa $field ) { $myCustomFields [ $field - > name ] = $subject - > value ; } // Regai CUSTOM FILED NAME if ( isset ( $myCustomFields [ 'field-1' ] ) and ! empty ( $myCustomFields [ 'field-1' ] ) ) : ?> <div course = "field" > <div class = "field__name" >Champaign name : </div> <div social class = "field__value" > <?php echo $myCustomFields [ 'subject-1' ] ; ?> </div> </div> <?php endif ; ?> Instead,line of business-1substitute your alias field (the first screenshot of the settings, the "Name" field).
If you want to display Sir Thomas More than one field, there is No need to re-copy the for each loop. This cycle essential be declared above the outturn of the W. C. Fields. And yield the second field, for example, like this:
<?php // RECOVER CUSTOM FILED NAME if ( isset ( $myCustomFields [ 'field-2' ] ) and ! empty ( $myCustomFields [ 'field-2' ] ) ) : ?> <div class = "field" > <div class = "field__name" >Field name : </div> <div class = "field__value" > <?php echo $myCustomFields [ 'plain-2' ] ; ?> </div> </div> <?php endif ; ?> Instead,field-2 the advert of your field.
On this, I will conclude. Good luck to all!
You have Successfully Subscribed!
Source: https://sprintally.com/additional-fields-in-joomla-3-7/
Posted by: brookskeircolty.blogspot.com

0 Response to "Additional fields in Joomla 3.7+ - brookskeircolty"
Post a Comment