Basics of mobile development

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Basics of mobile development

      Hi
      This is the mobile development method I am working on.
      These are basic changes.
      There may be errors in translation.


      Add to the contents of the ./includes/GeneralFunctions.php

      PHP Source Code

      1. //Mobile check
      2. function isMobile(){
      3. $sAgent = $_SERVER['HTTP_USER_AGENT'];
      4. $sMobile = '/(Android|iPhone|iPod|iemobile|ipaq|j2me|BlackBerry|SymbianOS|Opera Mini|Opera Mobile|Windows CE|Nokia|SonyEricsson|webOS|mobile.+firefox|PalmOS|wos)/i';
      5. if(preg_match($sMobile, $sAgent)){
      6. # is Mobile
      7. return true;
      8. }else{
      9. return false;
      10. }
      11. }
      Display All


      Modify to the contents of the ./includes/pages.game/AbstractGamePage.class.php

      Find


      PHP Source Code

      1. protected function getNavigationData()
      2. {
      3. global $PLANET, $LNG, $USER, $THEME, $resource, $reslist;
      4. $config = Config::get();
      5. $db = Database::get();
      6. ..
      7. ..
      8. $this->assign(array(
      9. 'PlanetSelect' => $PlanetSelect,
      10. 'urrl' => $urrl,
      11. 'new_message' => $USER['messages'],
      Display All


      Add mobile function

      PHP Source Code

      1. 'isMobile' => isMobile(), //Mobile Check


      Find line


      PHP Source Code

      1. $this->display('error.default.tpl');
      Modify mobile check


      PHP Source Code

      1. if(isMobile()){
      2. $this->display('error.default_mobile.tpl');
      3. }else{
      4. $this->display('error.default.tpl');
      5. }




      Find line

      PHP Source Code

      1. $this->tplObj->display('extends:layout.'.$this->getWindow().'.tpl|'.$file);
      Modify mobile check

      PHP Source Code

      1. # Mobile check
      2. if(isMobile()){
      3. $this->tplObj->display('extends:layout.'.$this->getWindow().'_mobile.tpl|'.$file);
      4. }else{
      5. $this->tplObj->display('extends:layout.'.$this->getWindow().'.tpl|'.$file);
      6. }

      The addition of the basic mobile connection environment has been completed.

      And modify the ***Page.class.PHP of includes/game to be mobile recognized as follows.
      ./includes/pages/game/******Page.class.php file


      ex)
      All Find line the .tpl

      PHP Source Code

      1. $this->display('page.banList.default.tpl');
      All Modify


      PHP Source Code

      1. # Mobile check
      2. if(isMobile()){
      3. $this->display('page.banList.default_mobile.tpl');
      4. }else{
      5. $this->display('page.banList.default.tpl');
      6. }



      Then copy all tpl files and rename them to _mobile.tpl.
      styles/templates/game/****.tpl
      ex)

      page.galaxy.default.tpl copy
      page.galaxy.default_mobile.tpl




      Just change _mobile.tpl to fit the mobile content size.


      When connecting to a mobile device, layout.full_mobile is recognized for the first time.

      You can develop it one by one by modifying the head and foot parts of layout.full_mobile.
      We hope you have a nice mobile page and great results.
      --------------------------------------------------------------------------------------

      The post was edited 1 time, last by noonn ().

    • Linkin wrote:

      Creo que si el objetivo de esto es hacer un diseño que se adapte a los móviles les sería mas fácil editando sus hojas de estilos. Se ahorrarían bastante
      Good idea :thumbup: :thumbup:
      --------------------------------------------------------------------------------------
    • You can do this in two different ways.
      either by mediaQuery in the base css file
      or either directly with a mobile.css CSS file for example
      and you choose one or the other depending on the platform in your tpl file.