Use Case: I maintain a simple site for a small orchestra. Originally written in Joomla 2010, updated to Joomla 3 in 2016 and now updating to Joomla 4/5. Each concert, the items, conductor, soloists etc. are entered in the Administrator backend using my component com_concert which stores the data in my own tables in the database. The site part of the component enables sorting and filtering for displaying past events. I have completed the upgrade of the administrator component for inputting the data and the site part for displaying the concert history. In the past, someone has edited the front article page manually with the latest concert details, and then added those same details again into the long term database records in the backend. All I want to do is to insert the various latest concert details to the front article page so eliminating the need for doubling the task of entering the data. The front page needs to be able to be edited manually because for some concerts different images and extra text are needed. I think this need probably rules out the use of a form for displaying the latest concert details.
Solutions tried:
- It looked to me as if using Custom Fields was the right way to go. (see https://magazine.joomla.org/all-issues/april-2020/custom-fields-episode-4-a-step-by-step-tutorial) I have succeeded in adding custom fields to the Article and they appear in front of the page text correctly. But I want them to appear in various places on the page, within bits of text or next to an image, for example. Currently, the relevant text is simply typed into cells in a table for display purposes. Unfortunately, when I set the display option to “Do not automatically display”, they don't appear at all. From other postings, I thought the solution would be simply to insert the tags {field 1} {field 7} etc. to the locations I wanted, but all I get is the text "{field 1}" appearing, untranslated into a field value. Having tried many alternative placings of the tags, I decided to try something else. Sourcerer.
- Having installed Sourcerer, I can get the tags {Source} code.....{/Source} to work with a simple <?php echo statement. But to put the complete sql code into an article that needs to be editable by an unqualified person looks like a recipe for disaster, and I decided the only acceptable way of doing this within Sourcerer would be to make a simple call to a function within my site component. But after trying as many forms of "include" and function calls as I could think of, I cannot get anything other than an error message saying it cannot find the relevant class.
Question: Can anyone tell me either : (a)(my preferred solution) the correct syntax (preferably with an example)for placing a custom field in some text in an article? or (b) (fallback solution) the correct syntax within Sourcerer to call, say, a function in a helper file from my com_concert component? or, from the use case description, (c) a better way of doing it!