Skip to Content
author's profile photo
Former Member

Including page fragments

I have lots of page fragments and I want to include only one of them on bsp based on a value of a variable.

How can I do this?

I wrote <%@ include file="pagefragment.htm"%> into a string and then put that string on the layout, but surprise, surprise, it doesn't work.

Can I somehow use

<%@ include file="pagefragment.htm"%>

and define the relative URL dynamically?

Any other ways to include a page fragment?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Posted on Dec 10, 2004 at 03:52 PM

    I don't know how dynamic you need it to be but you could always do a if check or case statement like the following:

     <%
      if content->design2002 is not initial.
            %>
            <%@include file="script2002.htm" %>
            <%
      else.
            %>
            <%@include file="script2003.htm" %>
            <%
      endif.
            %>
    

    Not its going to seem like I am really harping on the whole MVC thing this week, but if your situation is really that complex you are probably better off using MVC. You could call a generic controller with would then decide what View to include. View also have the advantage that they don't expand in place at runtime. They have their own class (and therefore avoid generation limits). You can also debug inside of an included view (unlike page fragments). You can also dynamically provide values to the BSP:call URL parameter.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Thomas Jung

      Not all of us are 100% converts yet - but you are gaining a greater control I think.

      That whole dark side of the force I think, I just won't comment on which side is the dark side 😉