Developer forum

Forum » Development » Error geting template loops

Error geting template loops


Reply

I'm trying to use a looping template but it doesnt seem to find the loops am I missing something?

 

im initialising a template like this:

 

Dynamicweb.Templatev2.Template master = new Dynamicweb.Templatev2.Template(moduleFolder + "/" + Properties.get_Value("master"));

 

when i write out Base.w(master.LoopExists("spots"));

i get a "false" and I cant instantiate a new template from the loop when i iterate through my items.

 

my master template looks like this:

 

<div align="center" style="width:100%;">
    <table id="galleryMain">
        <tr>
            <td align="left" valign="top">                   
            </td>        </tr>
       
         <!--@LoopStart(spots)-->
        <tr>
            <td align="left" valign="top" height="100%">              
                <table>                   
                    <tr style="cursor:pointer; margin-bottom:10px" onclick="location.href='<!--@galleryLink-->'">
                        <td align="left" valign="top">
                              <img width="60px" src="<!--@galleryFirstImage-->">
                        </td>   
                        <td align="left" valign="top" width="200px">
                              <strong><!--@galleryName--></strong> af: <!--@galleryUser--><br />   
                              <!--@galleryDescription-->
                        </td>         
                    </tr>
                </table>
            </td>     
        </tr>
        <!--@LoopEnd(spots)-->
    </table>
</div>
           


Replies

 
Nicolai Høeg Pedersen
Reply
sune@fonqi.dk wrote:

I'm trying to use a looping template but it doesnt seem to find the loops am I missing something?

 

im initialising a template like this:

 

Dynamicweb.Templatev2.Template master = new Dynamicweb.Templatev2.Template(moduleFolder + "/" + Properties.get_Value("master"));

 

when i write out Base.w(master.LoopExists("spots"));

i get a "false" and I cant instantiate a new template from the loop when i iterate through my items.

 

my master template looks like this:

 

<div align="center" style="width:100%;">
    <table id="galleryMain">
        <tr>
            <td align="left" valign="top">                   
            </td>        </tr>
       
         <!--@LoopStart(spots)-->
        <tr>
            <td align="left" valign="top" height="100%">              
                <table>                   
                    <tr style="cursor:pointer; margin-bottom:10px" onclick="location.href='<!--@galleryLink-->'">
                        <td align="left" valign="top">
                              <img width="60px" src="<!--@galleryFirstImage-->">
                        </td>   
                        <td align="left" valign="top" width="200px">
                              <strong><!--@galleryName--></strong> af: <!--@galleryUser--><br />   
                              <!--@galleryDescription-->
                        </td>         
                    </tr>
                </table>
            </td>     
        </tr>
        <!--@LoopEnd(spots)-->
    </table>
</div>
           

Seems like loopexists does not work. You can use t.TagExists("LoopStart(spots)") in stead.
 

 

Entire example:

 

Dim t As New Templatev2.Template("DwTest/test.html")

  Base.w("spots loop exists: " & t.TagExists("LoopStart(spots)"))
  Dim myLoop As Templatev2.Template = t.GetLoop("spots")
  For i As Integer = 1 To 5
   myLoop.SetTag("Counter", i)
   myLoop.CommitLoop()
  Next
  Return t.Output

 

 

You must be logged in to post in the forum