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.

Form Questions /

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

Custom Loginform


Go to End


10 Posts   3601 Views

Avatar
SilverPeed

Community Member, 22 Posts

11 September 2015 at 12:39am

Hello Everybody,

I'm stuck with what i thought would be really simple but i can not figure out how to do this. I'm working on a multi language website but i'm stuck on the loginform. The only things thad have to change in the loginform are the lables. So in English it woul be "Name" and "Password" but in Dutch it would be "Naam" and "Wachtwoord". So how can i render a loginform/template where i have control over labels?

http://www.ssbits.com/tutorials/2009/custom-login-form-with-group-based-redirection/
http://tamethebackbutton.blogspot.nl/2009/09/customize-your-own-silverstripe-login.html
http://www.silverstripe.org/community/forums/customising-the-cms/show/17277

Ive tried these but thad does not help me any further because i get the error "Passed invalid authentication method". I hope someone can help me on this. Thanks in advanced.

Avatar
swaiba

Forum Moderator, 1899 Posts

11 September 2015 at 12:52am

Hi SilverPeed,

After reading the title I was going to recommend... http://www.silverstrip.es/blog/admin-login-styling
But really what you want to do is change the language strings... which can be achieved by creating custom yml files for the language - here is a quick example of using it for changing a CMS menu value... http://www.silverstrip.es/blog/changing-the-name-of-settings-aka-siteconfig

Avatar
SilverPeed

Community Member, 22 Posts

11 September 2015 at 1:09am

Thanks Swaiba for your quick response.

It looks like the YML solution is static for the whole CMS and user. I'm working with Language holders. So every language has its own Holder and within that holder is a new tree. When a user clicks on English the website knows it has to pick the loginform within that holder. At-least i thought that would be i nice setup.

I will have a look at the admin-login-styling. Hope it does the trick.
Thanks again

Avatar
swaiba

Forum Moderator, 1899 Posts

11 September 2015 at 1:11am

I understand, remember yml values can be updated for each request, e.g. in _config.php you can set a language string based on what you know about the request (e.g. if locale is part of URL or known some other programmatic way).

Avatar
SilverPeed

Community Member, 22 Posts

11 September 2015 at 1:28am

Thad would be a solution i think.

Do you have an example code of how i could set thad up in _config.php?
For example if i know thad the language is french www.mysite.eu/french-holder/home

Avatar
swaiba

Forum Moderator, 1899 Posts

11 September 2015 at 1:45am

OK, so I was a little wrong... but after some checking this should work for you...

in _config.php

i18n::set_locale($locale);//determine from your URL

and then continue to setup the custom language strings, if this doesn't 100% solve it anyway

Avatar
SilverPeed

Community Member, 22 Posts

11 September 2015 at 2:02am

Thank you swaiba,

I tested it and it works.

Avatar
SilverPeed

Community Member, 22 Posts

11 September 2015 at 3:56am

It looks like i was a bit premature. I can not figure out how i can get the a url parameter in config.php.

As far is my research went, it is not possible to write a function in config.php
I tried writing a class for each language witch extends controller, But than the controller of the specific page is not being used.
I tried setting the locale in each page controller but thad does nothing.

Somehow i need to know how to read a URL parameter inside config.php
Sorry for being such a newbie in this kind a stuff.

Go to Top