Zum Hauptinhalt gehen

Replace placeholders in text

Kommentare

2 Kommentare

  • Zendesk API User
    Author: bIT_sosswald - 9/24/2020 8:55

    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.

    1. Use of DataSources
      When using DataSources I would implement something like a DataSource-Link to select which data source entry should be displayed. (You can directly select a DataSource entry as a link target like you do it with pages or files.)
      Now the section / page template would use this link to access the DataSource entry, extract the values and also the labels like “Number of employees” and put them in the generated HTML. This can be done using a render template to only have this code once.

      Positive: Flexible, you can add additional values in the future
      Negative: You must select / reference the DataSource entry each time

    2. Use of global data
      If the amount of those numbers is fixed and no (or very less) new stuff is added in the future you could use a GCA-Page to maintain this data as global data. Depending on the requirements you now can just put that data into the HTML or provide the editors with select-option to select which of the data should be shown on the page.

      Positive: No DataSources are needed, the editors must not select a specific DataSource entry
      Negative: Less flexible when new stuff should be added. (Implementation effort needed.)

    3. Changing the generated HTML afterwards.
      You had the idea already and yes this is possible. FirstSpirit generates into a local staging directory. So it would be possible to just print some placeholders in the HTML, parse all HTML files after generation and replace the placeholders. This could be done in a central module which is started by an executable in your generation schedule.

      Positive: You can do it with Java and the editors don’t have to do anything.
      Negative: Preview will differ from the live website, you have a dependency between your templates and the module (if a template developer is messing things up your module will break and you will have a broken website.)

    So as always it depends.  

    Greetings Sandro

    0
  • Zendesk API User
    Author: Peter_Jodeleit - 9/25/2020 13:56

    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

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.