Hello -
I have a controller function "services" that uses template "services.html"
I also have a table in the database called "services" that I can reference as "db.services".
I would like to dynamically build an unordered-list in the template using the list of services so I somehow need to iterate over the "services" table in the database & create a list of the field "svcname" & then pass that list to the template where I can dynamically display the list of services("svcname"). I hope I am explaining myself properly.
I have this for my table in models.py:
db.define_table(
'services',
Field('svcname'),
Field('svcshort'),
Field('svccat'),
Field('svcdesc'),
Field('svcrate'),
Field('svcunit'),
format='%(svcname)'
)
I have this so far for the action in my controller, this is knowingly incomplete because I am stuck as to how to build the list I need from the database table "db.services":
@action("services")
@action.uses("services.html", db, auth, T)
def landing():
page="Landing page! - hopefully soon a dynamic list of services from the db"
return dict(page=page)
And this is my template:
[[extend 'layout.html']]
<link rel="stylesheet" href="css/custom-styles.css>
<div class="services">
[[=page]]
</div>
I am hoping for some direction for how to iterate over the services database for the "svcname" field and then pass that list on to the template where I could then use a for-loop to spit out a styled-formatted list of the services.
Please let me know if I didn't explain it well.
Thanks -