Jump to:

23454 Posts in 18904 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » [solved] limit of silvertripe

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

Page: 1 2 3
Go to End
Author Topic: 2231 Views
  • astate
    Avatar
    Community Member
    35 Posts

    [solved] limit of silvertripe Link to this post

    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 ?

  • astate
    Avatar
    Community Member
    35 Posts

    Re: [solved] limit of silvertripe Link to this post

    Do I speak well?

    Sorry i don't speak english very well.

  • UncleCheese
    Avatar
    4085 Posts

    Re: [solved] limit of silvertripe Link to this post

    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?

  • astate
    Avatar
    Community Member
    35 Posts

    Re: [solved] limit of silvertripe Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: [solved] limit of silvertripe Link to this post

    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..

  • astate
    Avatar
    Community Member
    35 Posts

    Re: [solved] limit of silvertripe Link to this post

    merci.

       
    sorry, i am a beginner.

    I have a error a this line

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

    Silverstripe don't want a ";"

  • UncleCheese
    Avatar
    4085 Posts

    Re: [solved] limit of silvertripe Link to this post

    Changez:

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

    a

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

  • astate
    Avatar
    Community Member
    35 Posts

    Re: [solved] limit of silvertripe Link to this post

    it's ok thanks

    Now i test this

    2231 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.