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.

Template Questions

All forms shall use, but not the cms. How ?


6 Posts   2272 Views


1 May 2009 at 12:46pm Community Member, 27 Posts

I have modified the and copied my modified version into my templates folder.
Now this is used for the login form, for the password forgotten and the user defined form. But also in the cms, which produces strange effects.

Is there a way to solve this ? I mean it shall be used everywhere in the frontend, but simply not in the cms, thats all.
I see that this kind of thing has been discussed several times, but each time the problem was slightly different.

Thanks for help in advance

PS: I know, that I can change $Form in my to
<% if Form %>
   <% include myForm %>
<% end_if %>
But the login form comes with $Content, which doesn't seem to be an object, so that I can't stop it using the default Which again is either not my desired or my own which than again is used by the cms too :(

Nathan Cox

31 May 2009 at 1:47pm Community Member, 99 Posts

Hi, I realise this is an old post but I just spotted it and thought I'd share my solution to this problem.
I basically made a form extension that has an isFrontend() method that checks the URL to see if we're in admin. There's probably a much better way to do that bit but it works for now. Anyway, then I overwrote and put in an if statement - if isFrontend(), then include (which goes in your theme's includes folder) else use HTML I copied and pasted from the original

Not perfect I'm sure but so far it seems to work. I've attached a zip of the relevant files, but you still need to make your own with whatever layout code you want.

Attached Files

4 June 2009 at 6:07am Community Member, 27 Posts

Hey thanks, that helped.
There were some defects in your code and I had to modify and add some code.
However, your idea is a great solution :D more than enough for me :D

Also my Silverstripe didn't want to take the from your Includes-Directory, but it works fine when my modified and the default(/cms) are in my themes/Includes directory.

Hope others will find this helpfull, too


Nathan Cox

4 June 2009 at 9:49am Community Member, 99 Posts

Glad it helped, and yes in this case my line of thinking was better than my code :)

I'm not sure why it wasn't reading for you though, it works fine for me keeping in the form_template module...


4 June 2009 at 11:09am Community Member, 27 Posts

I use the user defined form module, too. Maybe that's interfering somehow ?!

Nathan Cox

4 June 2009 at 1:48pm Community Member, 99 Posts

Actually I'm thinking the problem is the name of the module - SS reads through the modules alphabetically, so since form_template comes before sapphire, sapphire's is overriding it.

I didn't have this problem because I extracted this code from a larger module called if you renamed this to template_forms or something that comes after "s" it should work.