Chronoforms 5 Variabilisierung von Footer/Header

A few years ago, our agency created a website for a client that included several forms. At the time, however, we had added a fixed footer containing the company’s business details to the forms.

We then ran into a problem when one of the managing directors left the company, as every form had to be edited individually.

To avoid this problem in the future, we decided this time to use Joomla’s Fields feature.

 

 

To create a field, go to

 

Content –> Fields

 

and then select

 

New.

 

First, enter a name for the field. For the field type, select

 

Text (text)

 

For the name and label, you can use the name of the field.

 

For the required field option, select

 

No

 

In the Default Value field, we can now enter the footer we want to use. Since the content would be stored as a string and therefore would not contain any formatting, it is recommended to use HTML. To make Joomla output the HTML, select the Safe HTML option under Filter.

 

Then save the field.

 

We now need two more pieces of information. First, we need the ID of the field. This can be found in the backend overview of all fields. Finally, we need the database table prefix. This can be found in the hosting settings provided by the host. The prefix is the part that is added before every table name.

 

Once we have both pieces of information, we can set the variable within the form. To do this, go to the location where the old footer is displayed and replace it with the following code:

 

<?php

$db = \JFactory::getDBO();

$query = "

SELECT `default_value`

FROM `PlaceholderPrefix_fields`

WHERE `ID` = 'Placeholder_ID' ;

";

$db->setQuery($query);

$data = $db->loadAssocList();

echo $data[0]['default_value'];

?>

 

This database query allows us to display the field within the form. However, it is important to replace the placeholders above with the two pieces of information we identified earlier. In our case, the two placeholder lines looked like this:

 

FROM `YOURPREFIX_fields`

WHERE `ID` = '1' ;

 

As a final step, save the changes and test whether everything works as expected. This example was implemented by our web agency on a website running Joomla 3.9.18.