21278 Posts in 5728 Topics by 2599 members
| Go to End | Next > | |
| Author | Topic: | 1897 Views |
-
[solved] limit of silvertripe

30 March 2009 at 9:00am Last edited: 1 April 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 ?
-
Re: [solved] limit of silvertripe

31 March 2009 at 2:35pm
Do I speak well?
Sorry i don't speak english very well.
-
Re: [solved] limit of silvertripe

31 March 2009 at 4:17pm Last edited: 31 March 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?
-
Re: [solved] limit of silvertripe

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
-
Re: [solved] limit of silvertripe

1 April 2009 at 5:49am Last edited: 1 April 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.. -
Re: [solved] limit of silvertripe

1 April 2009 at 7:44am Last edited: 1 April 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 ";"
-
Re: [solved] limit of silvertripe

1 April 2009 at 7:50am
Changez:
new FieldSet(new FormAction('doAgentSearch','Search')
a
new FieldSet(new FormAction('doAgentSearch','Search') )
-
Re: [solved] limit of silvertripe

1 April 2009 at 8:05am Last edited: 1 April 2009 8:19am
it's ok thanks
Now i test this
| 1897 Views | ||
| Go to Top | Next > |

