I am starting to working with theming in DNN and I have set up three files ASCX files that assemble content from a database.
I have a main template that contains a ContentPane like this.
<main role="main" class="main-body main-template-main-body">
<div id="ContentPane" class="content-pane" runat="server"</div>
</main>
Then, I have another container that is pulled by this ContentPane.
<div class='container'>
<div class='col-3'>
<div id ="carddeck" class="carddeck" runat="server" ></div>
</div></div>
Finally, I have another file that pulls the data from the server.
<div class="card h-80" style="height: 18rem;">
<div class="card-body">
<h3 class="card-title"><%# Eval("Name")%></h3>
<p class="card-text"><%# Eval("description")%></p>
</div>
</div>
With this structure. I was thinking that I could "loop" the third code block through all the entries in the database. At this point I don't have this working and I think it must have something to do with making the second and third code block more dynamic. Any help with this? thank you in advance.
This would typically be done via a MODULE placed onto a page, rather than in the Skin itself.
That being said, Skin/Theme files are ASCX User Controls so you can treat them with code as much as you like.
Something like an asp:repeater would probably work best
<asp:Repeater ID="rptSomething" runat="server">
<ItemTemplate>
<div class="card h-80" style="height: 18rem;">
<div class="card-body">
<h3 class="card-title"><%# Eval("Name")%></h3>
<p class="card-text"><%# Eval("description")%></p>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
Then in the code behind file for the ASCX (ascx.cs) you can load the data source and bind it to the repeater control.