route na specificky presenter pri viacerych routach

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
stewestw
Člen | 42
+
0
-

ahojte,
chcel by som poprosit o radu. potreboval by som vytvorit routeList, kde by sa uvodna stanka nacitavala v tvare <url>/shortcode jazyka> a dalsiu, ktora bude staticka a bude mat tvar <url>/<shortcode jazyka>/menu, ktora bude smerovat do specifickeho presenteru.
nedari sa mi to neako sprevadzkovat.
routy mam zadefinovane nasledovne:

//  front routes
           $router[] = $frontSubRouter = new RouteList('Front');



           //  link to menu
           $frontSubRouter[] = new Route('<lang=en>/menu', array(
               'module' => 'Ourfresh',
               'presenter' => 'Menu',
               'action' => 'default',
               'lang' => $this->locate->getLanguageShortCode()
           ));

           //  base front route
           $frontSubRouter[] = new Route('<lang=en>', array(
               'module' => 'Ourfresh',
               'presenter' => 'Homepage',
               'action' => 'default',
               'lang' => $this->locate->getLanguageShortCode()
           ));

           //  link to pages
           $frontSubRouter[] = new Route('<lang>/<id>', array(
               'module' => 'Ourfresh',
               'presenter' => 'Page',
               'action' => 'default',
               'lang' => $this->locate->getLanguageShortCode(),
               'id' => array(
                   Route::VALUE => 'gallery',
                   Route::FILTER_IN => function($id){
                       $return = $this->database->table('nette_content_lang')->where('seo_alias', $id)->where('lang_id', $this->locate->getLanguage())->fetch();

                       if(isset($return->content_id)){
                           return $return->content_id;
                       }
                       else{
                           return '';
                       }
                   },
                   Route::FILTER_OUT => function($id){

                       $return = $this->database->table('nette_content_lang')->where('content_id', $id)->where('lang_id', $this->locate->getLanguage())->fetch();
                       if(isset($return->seo_alias)){
                           return $return->seo_alias;
                       }
                       else{
                           return '';
                       }

                   }
               )

vopred dakujem za pomoc.

David Matějka
Moderator | 6445
+
+1
-

nedari sa mi to neako sprevadzkovat

prosim, trochu se snaz. Co to dela? ktera routa funguje, ktera ne? jak se to chova? dochazi k presmerovani.....?

stewestw
Člen | 42
+
0
-

ahoj,
trosku som sa s tym pokkrocil:

//  front routes
          $router[] = $frontSubRouter = new RouteList('Front');



          //  homepage
          $frontSubRouter[] = new Route('[<lang>]', array(
              'module' => 'Ourfresh',
              'presenter' => 'Homepage',
              'action' => 'default',
              'lang' => 'en'
          ));



          //  link to menu
          $frontSubRouter[] = new Route('<lang>/menu', array(
              'module' => 'Ourfresh',
              'presenter' => 'Menu',
              'action' => 'default'
          ));




          //  link to pages
          $frontSubRouter[] = new Route('<lang>/<id>', array(
              'module' => 'Ourfresh',
              'presenter' => 'Page',
              'action' => 'default',
              'id' => array(
                  Route::VALUE => 'gallery',
                  Route::FILTER_IN => function($id){
                      $return = $this->database->table('nette_content_lang')->where('seo_alias', $id)->where('lang_id', $this->locate->getLanguage())->fetch();

                      if(isset($return->content_id)){
                          return $return->content_id;
                      }
                      else{
                          return '';
                      }
                  },
                  Route::FILTER_OUT => function($id){

                      $return = $this->database->table('nette_content_lang')->where('content_id', $id)->where('lang_id', $this->locate->getLanguage())->fetch();
                      if(isset($return->seo_alias)){
                          return $return->seo_alias;
                      }
                      else{
                          return '';
                      }

                  }
              )
          ));

problem je v tom, ze mi routu <lang>/menu ignorovalo. potreboval by som, aby pri tejto route nasmerovalo na specificky presenter a namiesto toho stale bralo do uvahy len kratsiu variantu <lang>/ . neviem ci je toto dobre riesenie, ale teraz mi to zbehlo. budem velmi vdacny za vsetky rady.

Editoval stewestw (21. 5. 2015 11:07)