Search the FirstSpirit Knowledge Base
Hi everyone,
I'm quite new to FirstSpirit and it's API and not sure how could/should we solve the following Problem:
In our project we have a few statistical data, which are used by our editors on different pages. (e.g. number of employees in the company, number of open job position, number of customers...)
Currently these numbers are entered manually (hard-coded), on all pages where needed. Since these number change quite often, editors have to change them every time, in many different places.
Our idea is to create a separate table in datasouces in SiteArchitect, where these number would be stored, together with the descriptive placholder. (e.g. [employeeCount], [jobCount], [customerCount])
Afterwards, editors would replace the hard-coded numbers with these placholders.
The question is, what would be the best option to implement the replacement of these placeholders with the real numbers, from the defined datasource?
Our first attempt was to create a format template, which would do the replacement, and would be later included in all section templates where needed, via CMS_RENDER.
Although this works, our project is really big, and we have hundreds of templates, which should be updated with CMS_RENDER instruction.
Is there any other possibility to do this, possibly in fewer than hundred places?
Can something before/during the generation process be done, with FirstSpirit API and deployed as FS module for example?
Any other suggestion would be much appreciated.
Thanks!
Regards,
Dragan
Hi Dragan,
I have a few ideas in my mind currently. Depending on your requirements which are not totally clear to me.
Are those values always the same (also the same combination)? Or can the editors decide which values from a big list of possible values they want to display on a page? Can new values be added in the future? Etc.
So as always it depends.
Greetings Sandro
Hi Dragan,
Sandros provided already a good list of options. I want to add another one:
4. Replace placeholders in template code
You can replace the placeholders from within the template. The cleanest way would to provide some central function for the replacement, but as a quick start you can do something like $CMS_VALUE(my_text_input_component.replaceAll("${number_of_open_jobs}", 42))$ in your template code.
Regards,
Peter