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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

[solved] limit of silvertripe


Go to End


19 Posts   4395 Views

Avatar
astate

Community Member, 35 Posts

30 March 2009 at 9:00am

Edited: 01/04/2009 2:59pm

I need a city search feild case.

when the client write the city, the client need to be redirected to a contact page the agent of this city.
The agent have many city in this list.

How i can do it with silverstripe ? It's possible ?

Avatar
astate

Community Member, 35 Posts

31 March 2009 at 2:35pm

Do I speak well?

Sorry i don't speak english very well.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

31 March 2009 at 4:17pm

Edited: 31/03/2009 4:18pm

Yes, you can do this. There are a few pieces to it, though. Can you give a little bit more detail and I'll write something up for you tomorrow when I'm not typing on my iPhone? :)

Avatar
astate

Community Member, 35 Posts

1 April 2009 at 5:19am

ok :)

All Agents have a contact page différent.
All Agents serve many Postal Code (canada) (G6C 1E2, G2E 4W9, J01 2T0, etc). The Agents can be have more then 20 postal code.

i need only one search field

Your Postal Code : __________

When the visitor type the postal code, the contact page of the Agent who have this postal code open.

Thanks for your help

Avatar
UncleCheese

Forum Moderator, 4102 Posts

1 April 2009 at 5:49am

Edited: 01/04/2009 5:49am

Est-ce que ta langue preferrée est francais? Je peux essayer de l'éxpliquer en francais si tu veux... J'ai remarqué que tu viens de Canada. (Desolé, je ne peux pas trouver tous les accents sur mon ordinateur). :)

D'accord... je vais assumer que tu veux la forme sur aucune page, n'importe ou. Mettons alors le function dans la classe Page_Controller:


function AgentSearchForm()
{
return new Form(
$this,
"AgentSearchForm",
new FieldSet(new TextField('Zip')),
new FieldSet(new FormAction('doAgentSearch','Search')
);
}

function doAgentSearch($data, $form)
{
// Ici je vais deviner un peu, puisque je ne connais pas ton modele data.


$zip = $data['Zip'];
if(is_numeric($zip)) {
if($agent = DataObject::get("Agent", "Zip = '$zip'"))
Director::redirect($agent->Link());
else Director::redirect('agent-not-found'); // un page que tu as deja crée..
}
else Director::redirect('agent-not-found');

}

Sur la template:

$AgentSearchForm

Sans voir tous tes PHP classes pertinentes, c'est loin de parfait, mais j'éspére que cette code t'assiste un peu. Laisse-moi savoir si tu as des questions.

Peut-etre tu peux m'assiste avec mon fraincais en retour. :) Ca fait des années que je n'ai pas parler francais. Depuis.... le lycée, je crois..

Avatar
astate

Community Member, 35 Posts

1 April 2009 at 7:44am

Edited: 01/04/2009 7:58am

merci.

sorry, i am a beginner.

I have a error a this line

new FieldSet(new FormAction('doAgentSearch','Search')
);

Silverstripe don't want a ";"

Avatar
UncleCheese

Forum Moderator, 4102 Posts

1 April 2009 at 7:50am

Changez:

new FieldSet(new FormAction('doAgentSearch','Search')

a

new FieldSet(new FormAction('doAgentSearch','Search') )

Avatar
astate

Community Member, 35 Posts

1 April 2009 at 8:05am

Edited: 01/04/2009 8:19am

it's ok thanks :)

Now i test this

Go to Top