Please read and follow the COMMON ISSUES first!
Always add your version information in every new post! Thank you!

Form2Content Forum

Questions and answers for Form2Content, a Joomla CCK.
  1. Hans de Jong
  2. F2C article templating
  3. Saturday, 09 May 2020
  4.  Subscribe via email
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
Responses (2)
Accepted Answer Pending Moderation
Hi Hans,

Interesting thinking, taking F2C and Smarty to the max.

For the second part regarding the Bday/age I would suggest to look into Regular Labs re-replacer.
https://www.regularlabs.com/extensions/rereplacer

Regards,
Patrick
Please read the F2C documentation before asking questions! Thank you if you've done so ;)
Accepted Answer Pending Moderation
More than 50 years of programming experience may help a bit, especially when your were used to working with preprocessors and trying to squeeze the size of source and object code to the min...

Thanks for your suggestion in using the rereplacer extension. I saw more interesting extensions on that website...

Regards,
Hans
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.