A replacement for Form2Content for Joomla 4. This relies on the power of Fields and generates native Joomla articles by using a template. It should be noted that although the plugin can be installed and used with no modification, the intention is that developers customise it to suit their needs and at a minimum override the layout.

Note that this plugin works at a category level, so ALL content within a specific category or categories will be templated.

plg_content_f2cv1.2.3

Testing Instructions

  • Create a category for testing
  • Create a field group for testing
  • Create a few fields in the field group making sure to set the following properties
    • set the category to the one you created for testing
    • Options -> Automatic Display: Do not automatically Display
  • Install the plugin as usual and set the following Options
    • Field Group, the one you created for testing
    • Category, the one you created for testing
    • Site Template
    • Render Intro, Render Main: Yes
    • select the f2c_intro and f2c_main layouts
  • Don't forget to enable the plugin.
  • Now create an article in the test category and fill in the fields (note any content you enter into the main editor will be overwritten as you have both Intro and Main selected)

You should end up with an article that looks a bit like this, with the intro and main text identical:

[test-text]   just some random text
[test-calendar]   2023-06-20 10:38:15
[test-imagelist]   apple.jpg, bananas_2.jpg, fruits.gif, tamarind.jpg

It will list all the fields available to you, with their names in square brackets and show you the raw field contents.

Next Steps

Now to modify the layouts in clarimuse/fields2content to suit your needs. 

Go to System / Site Templates and click on your template.

Click on the Create Overrides tab and override the Layout clarimuse/fields2content. You can now edit the overrides to add in the html and fields you need. Note that in most cases it is possible to mix php output of fields with the curly bracket codes as inserted by the field plugin. If you used form2content in the past you can probably use the *.tpl file as a basis for the override, substituting the fields for the template parameters.

For a field that is just a string:

<?php echo $this->escape($fields['myfieldname']); ?>

Alternatively you could use curly bracket field code:

{field 3}

For fields which are arrays, you need to ensure you either iterate over the array or output using the second method. 

Advanced Users / Developers

Do you need to have several of these plugins or want to make it your own?

plg_content_xxxxv1.2.3

The plugin was developed to be as generic as possible whilst still being useful. Download a copy of the plugin and unzip - replace all instances of xxxx in both the filenames and file contents with the name of your choice. Probably best to keep the case the same as well.

Zip the folder and install.

Extended Field Info

In the plugin click on the Extended tab and then choose Extended - this will give you access to the full field objects and not just their values. Can be useful as some information such as file paths for imagelist are in fieldparams.

Example:  fieldinfo.txt

Advanced Use Example

This example is of creating a job advert - you cannot install and use this as it is, as the fields etc are not set up, it is just for you to browse the code and the layouts.

fields2content example files

When an item is finally deleted, the associated files are removed from the system. onContentBeforeDelete gets all the fields and after the article is deleted, onContentAfterDelete removes any files.

The plugin also forcibly sets a publish_down time to make it consistent, and also sets some metadata.

Improving the publishing experience

Wouldn't it be good to give the users who are publishing this content using the plugin a tailored edit form. Download the editing files and follow the instructions included. This moves the title up, so it shows on all tabs, moves the Fields to the first tab, moves the Editor to the last tab and only shows options that are relevantant or cause issues if hidden.

f2c edit files

The last niggle for me was that creating an article in the front end showed it full width, hiding the right hand menu, but when editing an existing item the menus still showed. A small edit to my index.php fixed this (note that my template is a child of Cassiopeia). Search sidebar-left if your menus are on the left.

Find the line if ($this->countModules('sidebar-right', true) and change it to read if ($this->countModules('sidebar-right', true) && $layout !== 'edit')

That takes care of the css class added if there are any modules on the right. If the css is left in then there is a space left for the modules.

Find the line <?php if ($this->countModules('sidebar-right', true)) : ?> and change to <?php if ($this->countModules('sidebar-right', true) && $layout !== 'edit') : ?>

Which means that the modules are not output. Now your edit screen will be full width.