I get a mistake when I created my own mod

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

    • I get a mistake when I created my own mod

      I want to write a mod like cdk mod.
      I have completed the admin to generate cdk through the background.
      But when I finished writing ShowCdkPage.class.php
      I imported it into incldes/pages/game
      But there is a ERROR

      Source Code

      1. Message: Class 'ShowCdkPage' not found
      2. File: /game.php
      3. Line: 41
      4. URL: http://114.118.92.180:8080/game.php?page=cdk
      5. PHP-Version: 7.2.1
      6. PHP-API: cgi-fcgi
      7. 2Moons Version: 1.8.git
      8. Debug Backtrace:
      9. #0 {main}
    • the 'wrap' of your script should look as follows, seems like you didn't defined the class

      Source Code

      1. class ShowCdkPage extends AbstractGamePage
      2. {
      3. public static $requireModule = 0;
      4. function __construct()
      5. {
      6. parent::__construct();
      7. }
      8. function show()
      9. {
      10. //include your script here.
      11. }
      12. }
      Display All
    • mimikri wrote:

      the 'wrap' of your script should look as follows, seems like you didn't defined the class

      Source Code

      1. class ShowCdkPage extends AbstractGamePage
      2. {
      3. public static $requireModule = 0;
      4. function __construct()
      5. {
      6. parent::__construct();
      7. }
      8. function show()
      9. {
      10. //include your script here.
      11. }
      12. }
      Display All
      THX, my bro
      I fixed it by using your method.
    • Source Code

      1. Message: Unable to load template 'file:page.cdk.default.tpl'
      2. File: /includes/libs/Smarty/sysplugins/smarty_internal_template.php
      3. Line: 163
      4. URL: http://114.118.92.180:8080/game.php?page=cdk
      5. PHP-Version: 7.2.1
      6. PHP-API: cgi-fcgi
      7. 2Moons Version: 1.8.git
      8. Debug Backtrace:
      9. #0 /includes/libs/Smarty/sysplugins/smarty_internal_templatebase.php(199): Smarty_Internal_Template->render(false, 1)
      10. #1 /includes/libs/Smarty/sysplugins/smarty_internal_templatebase.php(114): Smarty_Internal_TemplateBase->_execute(Object(Smarty_Internal_Template), NULL, NULL, NULL, 1)
      11. #2 /includes/classes/class.template.php(130): Smarty_Internal_TemplateBase->display('page.cdk.defaul...')
      12. #3 /includes/pages/game/ShowCdkPage.class.php(41): template->show('page.cdk.defaul...')
      13. #4 /game.php(57): ShowCdkPage->show()
      14. #5 {main}
      Display All


      my tpl

      HTML Source Code

      1. {block name="title" prepend}{$LNG.lm_cdk}{/block}
      2. {block name="content"}
      3. <table>
      4. <tbody>
      5. <tr>
      6. <td><input type="text" name="username" size="80" value="{$username}"></td>
      7. </tr><tr>
      8. <td><input type="text" name="cdk" value="{$cdk}" ></td>
      9. </tr><tr>
      10. <td colspan="2"><input type="submit" value="{$cdk_encript}"></td>
      11. </tr>
      12. </tbody>
      13. </table>
      14. {/block}
      Display All
    • you have to assign the values you use in the templatefile
      the end of your php script shpuld look like this

      PHP Source Code

      1. $this->assign(array(
      2. 'cdk_encrypt' => $cdk_encrypt,
      3. 'cdk' => $cdk,
      4. 'username' => $username
      5. ));
      6. $this->display('page.cdk.default.tpl');
      7. }//function/method show end
      8. }//class cdk end
    • mimikri wrote:

      you have to assign the values you use in the templatefile
      the end of your php script shpuld look like thisi

      PHP Source Code

      1. $this->assign(array(
      2. 'cdk_encrypt' => $cdk_encrypt,
      3. 'cdk' => $cdk,
      4. 'username' => $username
      5. ));
      6. $this->display('page.cdk.default.tpl');
      7. }//function/method show end
      8. }//class cdk end
      i have been finished it,
      and could you please to help me with my other subjects called multi universe