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.

General Questions

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

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

[solved] limit of silvertripe


Go to End
Reply

19 Posts   2278 Views

Avatar
astate

30 March 2009 at 9:00am (Last edited: 1 April 2009 2:59pm), Community Member, 35 Posts

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

31 March 2009 at 2:35pm Community Member, 35 Posts

Do I speak well?

Sorry i don't speak english very well.

Avatar
UncleCheese

31 March 2009 at 4:17pm (Last edited: 31 March 2009 4:18pm), 4085 Posts

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

1 April 2009 at 5:19am Community Member, 35 Posts

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

1 April 2009 at 5:49am (Last edited: 1 April 2009 5:49am), 4085 Posts

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

1 April 2009 at 7:44am (Last edited: 1 April 2009 7:58am), Community Member, 35 Posts

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

1 April 2009 at 7:50am 4085 Posts

Changez:

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

a

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

Avatar
astate

1 April 2009 at 8:05am (Last edited: 1 April 2009 8:19am), Community Member, 35 Posts

it's ok thanks :)

Now i test this

Go to Top