I use a submission form where users can tell about themselves. There are fields like $NAME @COUNTRY, @STATE , @CITY and more. In a multi-line text area field users can tell more about themselves. Often they enter the same info as given in the other fields. No problem, until they move to another city and only update the @city field.
No problem fto edit their text for them, but I found out it is easy to have it done automatically, so the story is shown consisitent with other info in the Joomla article.
It works like this:
Ask them in the submission form to use placeholders in the text, e.g. %name, %country and so on...
When the article is reviewed by an editor/administrator for first time submission the actual names can be replaced by the placeholder too of course.
In the article template we only need to use the Smarty modifier replace:
{$INTRODUCTION|replace:'%name':$FIRST_NAME_RAW|replace':%city':$CITY}
As each time the user edits the submission form, a new version of the Joomla article is compiled, the introductional text showing the latest information.
A bit more difficult is when they enter their age in the @INTRODUCTION field, as age change in time... The submission form contains the field @BIRTHDATE and by using the joomla extensiion AgeOf, a correct age can be shown on it's own when someone watches the article using code like this:
I am {ldelim}ageof{rdelim}{$BIRTHDATE}{ldelim}/ageof{rdelim} old.
It is possible however to have the correct age shown in a longer text, by using the placeholder %age in the $INTRODUCTION field and adding the following modifiers in the article template:
{$INTRODUCTION|replace:'%age':'{ageof}%age{/ageof}'|replace:'%age':$BIRTHDATE}
A two stage replacement...
I have tried to do this in one stage, but I didn't manage. If anyone knows a shorter code, please reply.
Joomla 3.9.18
Form2Content Pro version 6.17.4
Form2Content Forum
Questions and answers for Form2Content, a Joomla CCK.
- Hans de Jong
- F2C article templating
- Saturday, 09 May 2020
- Subscribe via email
- Page :
- 1
There are no replies made for this post yet.
However, you are not allowed to reply to this post.
However, you are not allowed to reply to this post.