cancel
Showing results for 
Search instead for 
Did you mean: 

Including page fragments

Former Member
0 Kudos

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 <i><%@ include file="pagefragment.htm"%></i> 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?

Accepted Solutions (0)

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate

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.

Former Member
0 Kudos

Unfortunately simple <%if...endif%> won't do since I ran into that stupid 'jump too long' dumb.

I guess it's time to dig into MVC...

Former Member
0 Kudos

Solved the problem by converting a part of the page to MVC, which was surprisingly easy for a first timer. Gonna be using MVC a lot more from now on.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

It warms my heart to see how many MVC converts we've had in just the last few weeks. Happy Data Binding!

Former Member
0 Kudos

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