Related articles using F2C & NoNumber Articles Anywhere
The essence of this code is that Form2Content 'delivers' an array (list) of Joomla article title and ID's which can be selected in the submission form. This article list is than visualised as Related Articles (in the current article) using NoNumber Articles Anywhere extension.
Important: In the examples below we are using the Database Lookup (mult-select) field type with unique name RELATEDARTICLES.
1) Creating the related article list (array) in the submission form
We want our user to be able to select one or more related articles from a list of Joomla articles. For this we use the Database Lookup (mult-select) field type. Please read this article on how to configure the field and create an article selection list.
2) Visualise the related articles in the article
In step 1 we created the 'input', the possibility of selecting one or more Joomla articles. Now we want to visualise (render) the articles in the F2C template in such a way that we can see a 'clickable' list of related articles.
Creating SEF links in Joomla 1.7 can be tricky. As you might know we don't like re-inventing the wheel so we will be using a great extension (Joomla plugin) called Articles Anywhere from NoNumber.
Articles Anywhere Joomla plugin
The syntax for the Articles Anywhere plugin is very simple: (please note I replaced {} with [] tp prevent rendering.
In between the tags you can add data like article URL, intro text, main text etc.
Example:
This will render the title with link of article 123 and the first 100 characters of the article.
F2C template code
The F2C template code, using Smarty for the above example becomes the following. As always replace Joomla plugin { } with {ldelim} {rdelim}:
3) Converting the array into a list using Smarty
Since we are creating a list of unknown number of items from an array we will use the Smarty syntax {foreach} to create the list. In the array the key is stored in the variable $k and the value (item) in $i. The later we don't need since Articles Anywhere can already get it for us.
4) Some examples
Comma separated list of article titles with link
Note: The name=thislist is required to add the . after the last item
List of article introductions with read more