Problem mit smarty und switch anweisung

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem mit smarty und switch anweisung

    So ich habe es nun mit dem switch hinbekommen, aber ein prob habe ich da trozdem noch. Er gibt es nicht richtig aus und zwar setzt er es oben hin aber soll es in die mitte anzeigen.
    So sieht es atm aus.
    Test Seite

    index.php
    PHP Code:
    switch($_GET['modul'])
    {
      default : 
    li();break;
      case 
    news :                     
        switch(
    $_GET['sub_modul']) 
           {
              default : 
    li();break;
              case 
    news news();break;
             };break;
    }
    function 
    news()
    {
    echo
    'news';
    }
    $smarty->display('index.tpl'); 
    index.tpl
    PHP Code:
    <table border="0" cellpadding="0" cellspacing="0" width="958" height="567">
      <
    tr>
        <
    td width="132" rowspan="4" height="567" valign="top">
    <
    A HREF='index.php?modul=news' >Home</a><br>
    <
    A HREF='index.php?modul=news&sub_modul=news' >Links</a><br>
    </
    td>
        <
    td width="693" height="38" >&nbsp;</td>
        <
    td width="133" rowspan="4" height="567" valign="top"></td>
      </
    tr>
      <
    tr>
        <
    td width="693" height="398"  align="center" valign="top">dd</td>
      </
    tr>
    </
    table
    da wo dd steht soll der inhalt von der switch anwesiung rein. Was müss ich nun ändern?
    Last edited by Victorious; 26-11-2005, 13:01.

  • #2
    bitte code formatieren und die umbrüche so setzen, dass man nicht scrollen muss!
    http://www.php-resource.de/forum/sho...threadid=50454
    INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


    Comment


    • #3
      Ist es so besser?Ich weiss auch das script so richtig arbeitet nur ich weiss nicht, wie ich die switch anweisung an die richtige stelle bringe. ich habe auch auf smarty.php.net nix gefunden was mir helfen könnte.

      Comment


      • #4
        du solltest in deinem template einen platzhalter einfügen, wo der content rein soll.

        dann kannst du mit smarty deinen content mit assign() und/oder append() dort einfügen.

        http://smarty.php.net/manual/en/api.assign.php
        http://smarty.php.net/manual/en/api.append.php
        INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


        Comment


        • #5
          hatte ich schon versucht so

          PHP Code:
          $index = switch($_GET['modul'])
          {
            default : 
          li();break;
            case 
          news :                     
              switch(
          $_GET['sub_modul']) 
                 {
                    default : 
          li();break;
                    case 
          news news();break;
                   };break;
          };


          $smarty->assign('index'$index); 
          aber es kommt eine fehlermeldung

          Comment


          • #6
            und was für einen meldung?
            und was stand in deinem template?
            INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


            Comment


            • #7
              Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /is/htdocs/wp1009673_FMKUCXMAF1/www/Link/index.php on line 12

              Das stand drin.
              Die Zeile ist das
              PHP Code:
              $index ="switch($_GET['modul'])
              {
              default : li();break;
              case news : 
              Und die tpl sah so aus
              PHP Code:
                <tr>
                  <
              td width="693" height="398"  align="center" valign="top">{$index}</td>
                </
              tr

              Comment


              • #8
                php grundlagen sind dir aber schon bekannt. oder?

                schaue dir doch mal genau an, was du da gepostet hast .....
                INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


                Comment


                • #9
                  Hm hab das jetzt mal geändert jetzt sagt er mir den fehler parse error, unexpected T_SWITCH in /is/htdocs/wp1009673_FMKUCXMAF1/www/Link/index.php on line 12

                  PHP Code:
                  $index = switch($_GET['modul'])
                  {
                    default : 
                  li();break;
                    case 
                  news :                     
                      switch(
                  $_GET['sub_modul']) 
                         {
                            default : 
                  li();break;
                            case 
                  news news();break;
                           };break;
                  }; 

                  Comment


                  • #10
                    immer noch php-grundlagen.

                    beschreibe doch einmal was dein code hier machen soll.

                    und dann beschreibe mal was er macht.
                    INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


                    Comment


                    • #11
                      Naja er soll zwischen den funktionen switchen. Die switch anweisung soll
                      in
                      PHP Code:
                      $smarty->append('index'$index); 
                      rein.

                      Comment


                      • #12
                        Ich komme nicht drauf, was ich falsch mache.

                        Comment


                        • #13
                          Original geschrieben von Abraxax
                          beschreibe doch einmal was dein code hier machen soll.

                          und dann beschreibe mal was er macht.
                          INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


                          Comment


                          • #14
                            über $_GET['modul'] bekommt er eine varriable übergeben. zb news dann wird die funktion news() aufgerufen.

                            Ich habe dann das mal versucht klapt aber auch nicht:
                            PHP Code:
                            switch($_GET['modul'])
                            {
                              default : 
                            $smarty->assign('index'li());break;
                              case 
                            news :                     
                                switch(
                            $_GET['sub_modul']) 
                                   {
                                      default : 
                            $smarty->assign('index',li());break;
                                      case 
                            news $smarty->assign('index',news());break;
                                     };break;

                            Comment


                            • #15
                              Ich versteh das nicht mehr den code den ich vorher gepostet hat funktioniert,aber nur wenn in dem assign keine funktion drin ist. Sobald ich eine funktion drin habe gibt er mir den wieder falsch aus.

                              Comment

                              Working...
                              X