- Concatenate Any Fields Into a Single Field Value
- Joomla! 3.x
- Joomla! 4.x
SD Field Concat V2.5.3
Concatenate a large amount of fields into a single field value, and store it anywhere as per the choice of storage options as offered by SEBLOD. SD Field Concat is perfect for constructing unique article titles. For example, assuming you have a contact form that accepts a first name as one of the fields, you may then use SD Field Concat to save the article using a title that consists of the following type of format:
Contact Simon 2013-06-03 14:30:00
Where you have chosen to concatenate a predefined string ("Contact" in this case), the value of the first_name field ("Simon" in this case) and then a custom formatted PHP Date string (Y-m-d H:m:s in this case). If you choose to store this value inside the main article table as the title value, you are creating a custom title.
The uses are only limited as far as your imagination can take you.
What this field plugin DOES do:
- This field plugin allows you to concatenate multiple fields, plain text strings and date values into one string and save that value saved as per the normal offering of SEBLOD storage options.
- This plugin allows you to decide if you want the logic processed on article EDIT or not. If not, it's logic will only be run on article creation, and never again.
- This field plugin will allow you to save it's value as you would be able to save ANY other SEBLOD fields value. In other words, it relies on the default SEBLOD storage engine, it does not provide you with extra storage options.
- This plugin ALWAYS impresses you.
What this field plugin does NOT do:
- This field does NOT render itself in the backend or front end. Instead, it is 'invisible' and it's logic happens when the article submission form is processed.
- This field does NOT take live values from the main article stage (See my SD Live plugin for that)
- This field does NOT grab fields that are outside the scope of the current article. In other words, it can only grab form fields inside the CURRENT form of the CURRENT article in question.
- This plugin NEVER disappoints you!
Use and abuse this plugin, it's tougher than tough. It should be an integral aspect of all of your SEBLOD powered sites.
Basic Directions for Use
It's fairly simple to use the SD Field Concat plugin. Here is an overview of options as per the fields settings screen. Before I explain each of the options in the field settings screen, let's look at how you differentiate between concatenating fields, strings & dates:
The field separator
First things first, the SEPARATING character for all fields, strings and dates is a double pipe ||
Field Enclosures
When concatenating fields, they MUST be enclosed in #. For example, let's say you wanted to concatenate two fields whose names were first_name and last_name respectively. You would do so as follows, taking note of the uses of the # and || characters:
#first_name#||#last_name#
The above would be typed into the List of Fields option in the SD Concat field setup screen. Take careful note that the # character surrounds each field in the list while the || indicates a new field (or string or date). The double pipe above acts pretty much the same way as a comma does in an array.
Value Separators
If you are wondering what each value is separated by, the default character is a SPACE. You can override this by typing a value into the Value Separator option in the field setup screen. If you would like NO string separating your concatenated values, then the phrase ns should be entered into the Value Separator field, where ns is an acronym for No Separator...
Adding Dates
If you wanted to add a pre-formatted date to your list of fields, you need to add the $date phrase to your list. Building onto our first example above, let's assume you wanted to add the current date (in Yyyy-mm-dd format) to your title. For starters, you would add the $date phrase, so the value in the List of Fields option now becomes:
#first_name#||#last_name#||$date
The formatting of the date value however is done via the Date Format option. The DEFAULT option (if none is entered) is Y-m-d H:m:s
It is important to take note that the date formatting string is any valid PHP date() formatting string. If you are unsure of what these are, please consult the PHP documentation on the date() function.
Our newly updated field list above will not result in a value such as this:
Simon Dowdles 2013-06-03 15:00:00
Perfect for contact form articles isn't it? Also note the default space character separating all the concatenated values.
Getting The ID Of an Article
A lot of people make the mistake of using #art_id# to get the article ID of the current article. This is OKAY if the article is being EDITED, but if it is new then the value of #art_id# does not yet exist.
If your goal is to get the next auto increment for the articles table (for instance when creating a new article) you will need to use the following syntax:
Use the
While to get the next ID value of the content table, you would use this syntax:
Values are also stored in key value pairs inside the increments.ini file bundled with the plugin. Bear in mind this is ONLY stored for the #__content tables auto increment values, and NOT other tables. This also acts as a cache on future article saves, so no database lookups are performed after the first save.
Getting Any Column Value From #__content (++ V2.5.2)
This is a new feature introduced in Version 2.5.2 of the plugin. There is now a NEW field selector in the list of fields to concatenate, and it's syntax is as follows:
@colname(field_name)
Where 'colname' is the name of any column in the #__content table, and 'field_name' is the name of any field IN YOUR CONTENT TYPE FORM who's value you want to use as the ID for the id column of #__content.
For example, let's say you have (inside your form) a select dynamic field called 'my_articles' which lists articles form your content table using their ID for the value and their title as the select label. Doing this:
@alias(my_articles)
Is going to search the #__content table, find the row with the ID who's value matches the selected record in your select dynamic field, and return the 'alias' column of that row as the concatenation value.
Likewise, this:
@created(my_articles)
Will fetch the alias of that same record.
Now, what if you already KNOW the ID of the article you want to grab a certain column from in #__content and you don't want to just build a new field to grab the ID from? Simple, you have the choice of pushing the ID value straight into the brackets as follows:
@title(23)
This will fetch the title of the article who's ID is 23.
@catid(54)
Will fetch the catid column for the article with ID 54
What to expect in the future? Soon you will be able to get the value of ANY cck field from ANY article using the above method, and not just columns inside of #__content.
The Text or Value Option
The Text or Value? option in the field settings is pretty simple. It literally means do you want the VALUE of a field, or the TEXT. Let's take a simple HTML text field that has an html name attribute of user_name. If the user entered a value of "New User" in this form field and you had selected the 'text' option, you would get their input as the field value, New User in this case. Had you however chosen the 'value' option instead, you would have got the fields actual name, user_name in this case.
The same principle applies to checkboxes, radio buttons and even select fields. If concatenating a select simple field for example, you have the choice to harvest the select fields label, or the value behind it.
Multi Lingual Abilities
Should you wish to allow your concatenated values to be translated, you can set the Enable JText option to 'yes'. What this does, is create a language string from your concatenated value, that will be processed using the JText option.
It is IMPORTANT to take note of the structure for the JText enabled string. The following rules and formatting properties are applied to the final value to create a legal JText string:
The following characters are REMOVED from your final value and replace with a blank string (not a space):
; : ` ~ } { > < ! = , -
All spaces are then replaced by underscores, the value is then converted to an uppercase string and the entire value is prefixed by the phrase PLG_CCK_FIELD_SD_FIELD_CONCAT_
So, let's assume you had a concatenation who's final value was "Contact Form - Simon Dowdles". It's respective JText formatted language string would be PLG_CCK_FIELD_SD_FIELD_CONCAT_CONTACT_FORM_SIMON_DOWDLES and you would have the ability to apply the necessary language strings via your language override files.
The JText option is seldom used, but perhaps some may find it useful.
Apply on Form Creation And / Or Edition
Lastly, you have the choice to allow or disallow the logic of SD Field Concat to run when editing an article or not. Simply set the value of the Process on edit? option to either 'Yes' to have the logic run on article creation AND article edition, or 'No' to have it run only on article creation. Why would you want to NOT have the field process on edit? If you've used a date or time formatting string as one of your values, it's value will be updated to that of the date and time of the edition, and not the creation. This is a personal preference and you'll soon learn when to process on edit or not.
Version Compatibility
This version of SD Field Concat (V2.5.2) is for use with SEBLOD V3.0.4 > and Joomla! V3.0.4 Stable >
--
Enjoy what is arguably one of the most useful SEBLOD plugins to ever surface ;)
Change Log
2013-07-18 (V2.5.3)
!! Fixed next auto increment issue where next auto increment was not returning a correct value due to a fault INI file path.
2013-06-26 (V2.5.2)
++ Added new field selector in field list. See "Getting Any Column Value From #__content" above.
2013-06-25 (V2.5.1)
Fixed bug with user wanting to concatenate Article ID field on new article. This is now working correctly and the value is obtained from the MySQL table informations Auto_increment column.
EDIT [December 15, 2016]: Octopoos takes over the support of this product.
Business Clubs:
- Lifetime License
- Unlimited Domains
Single purchase:
- Free Updates
- Lifetime License
- Unlimited Domains
Details:
Requires:
Latest SEBLOD
Excellent Plugin
Great plugin, great benefit!