Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Insection(page-url) control block


Go to End


3 Posts   3701 Views

Avatar
a-tech

Community Member, 39 Posts

20 June 2007 at 3:57pm

Hey guys, I want to be able to limit a form to a specific page, without having to create a seperate page type I assume the best way is to use a control block that shows the form depending on what page the user is on.

I tried
<% if InSection("formpage") %>
$someForm
<% end_if %>

but I get a parse error complaining about a missing } in the tmp file.

Its not the code in the controller that the parse error is complaining about I have checked that.

Avatar
elijahlofgren

Google Summer of Code Hacker, 222 Posts

21 June 2007 at 2:45am

You can do an if statement based on the "Page Name" field like this:

<% if Title = Home %>
WELCOME HOME! :)
<% end_if %>

That syntax is explained here under "If blocks": http://doc.silverstripe.com/doku.php?id=templates#template_syntax

Hope this helps,

Elijah

Avatar
Sam

Administrator, 690 Posts

21 June 2007 at 10:31pm

You shouldn't have quotes around formpage in the insection bit

<% if InSection(formpage) %>