Developer forum

Forum » Development » Accessing template tags in a Header template tag

Accessing template tags in a Header template tag


Reply

Hi there,

Is it possible to use a template tag inside the EmptyLoopStart and EmptyLoopEnd tags?

I am trying this code:

<h2><!- -@CategoryName- -></h2>
<!- -@LoopStart(ItemsLoop)- ->
<!- -@EmptyLoopStart- ->No articles found in <!- -@CategoryName- -><!- -@EmptyLoopEnd- ->
 

  - - Other code here
 
<!- -@LoopEnd(ItemsLoop)- ->

And the name of the category appears correctly, but isn't parsed when the loop is empty.

Any way around this? Note: I replaced double dashes with dash space dash to make sure this code is not parsed by the forum.

Kind regards,

Imar


Replies

 
Nicolai Høeg Pedersen
Reply
That is not possible.

I do not even think you can make template tags available in the empty loop section. I've TFS'ed it as an enhancement request.
 
Nicolai Høeg Pedersen
Reply
Come to think of it...

You can do something ugly like this:

t = new template(...)
t2 = t.Getloop(...)
while something
t2.settag("")
t2.commit
end while

t3 = new template(t.output)
t3.settag("GlobalInLoopTemplateTag", "value")
return t3.output()
 
Reply
Ugly: maybe. A nice work around: certainly ;-)

Couln't find a constructor on Template that accepts the HTML (just a path), but it works when I directly assign the HTML:

Dynamicweb.Templatev2.Template t3 = new Templatev2.Template();
t3.Html = listTemplate.Output();
t3.SetTag("MyGlobalTag", "Some Value");
return t3.Output();

Now all I need to do is figure out how to do this in a nested loop where the inner loop may be empty....

Thanks,

Imar

 

You must be logged in to post in the forum