Best practice in Anvil for creating a page with a lot of static text? Labels?

Hi all. I want to have a form which will essentially be a few paragraphs of static text. The only way I can see to do this in Anvil is with labels. I’m thinking that the easiest way to manage this would be to store the content for each paragraph in a data table, and reference it from the form like so:

# Usual import statements snipped for brevity

class Test(TestTemplate):
  def __init__(self, **properties):
    # Set Form properties and Data Bindings.
    self.init_components(**properties)
   
    # Set the text properties for the labels from the stored strings in the data tables
    self.label_1.text = app_tables.static_content.get(paragraph_id=1)['content']
    
    self.label_2.text = app_tables.static_content.get(paragraph_id=2)['content']
    
    self.label_3.text = app_tables.static_content.get(paragraph_id=3)['content']

Here is the data table I set up for this:

This all works OK:

What I’m wondering is whether there’s a better way to do this. Essentially, I’d be building a rudimentary CMS in Anvil. :slight_smile:

(I can see that one option might be to mix the Anvil app with an external static site, but I want to keep the entire thing in Anvil.)

Thanks,

Rich

2 Likes

You might consider using a TextArea and mark it read-only.

The above is limited to plain, unformatted text. You might also look at Seeking a Rich Text Display.

4 Likes