It is possible to add custom information for each individual article in Article Details Profiles, on top of the detailed information you can already show.
In order to do that, we can take advantage of 2 events that are available in the extension.
First, we need to be able to add the field type in the list of fields available for output and second, we need to set how the output will present itself for each article.
With this tutorial, you will be able to add:
- a field type that outputs a link.
For this tutorial, you need:
You can use the plugin
plg_articledetails_mydetails as-is, but its usage is limited and is meant for learning purposes.
The plugin can easily be internationalized by adding your own language files (in this case,
mydetails.xml will need to be updated accordingly) or by creating language overrides.
Step 1 Install the plugin (not on a production site). It will be found under
Step 2 Open the plugin file
mydetails.php. The code is documented with key information.
Step 3 Go to the method
onArticleDetailsPrepareDetailSelection. This is the code that will be called whenever the select box containing all the information types is created.
Step 4 Add the name of the type you want to see as information type to the array of information types.
$information_types = '[information type]';
Note The information type is made of [the plugin name]_[the type]. For instance : mydetails_url.
Step 5 Go to the method
onArticleDetailsGetDetailData. This is the code that will be called whenever items are shown on the page. For parameter explanations, check the source code.
Step 6 The output code is placed into layouts that you can override.
On plugin install, the sample layouts are moved into the extension (into
/layouts/details). It is imperative that the layouts are placed there in order for them to be taken into account. You can override them in your template.
Layout files must follow the convention:
Note For the list of icons you can use as default for your type, go to documentation/common-features/icon-picker-common.
Step 7 Save your code.
Step 8 Open the file
Step 9 Add the key/value pair that corresponds to the information type that you have created. Follow the convention:
PLG_ARTICLEDETAILS_[plugin name]_DETAIL_LABEL_[information type]
Copy, duplicate and customize the code at your will and show information you need for your next project!