Como crear Modal emergente al iniciar seccion

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

  • Como crear Modal emergente al iniciar seccion

    Saludos, no supe bien poner el nombre del tema jaja

    A ver mi idea, es como puedo hacer que al usuario cuando inicie sección y entre al juego, le salga una ventana con X información..... y claro, una vez que la cierre se guarde la información que ya la ha leído.
    Me ayudan.... Gracias por adelantado. :thumbsup:
  • Hello, what did you want to do is during each action carried out on the game or only on certain action before the popup is opened? Also you want to put what in this popup and what information because the code depends on what you need.

    Because the code JS + Ajax + COOKIE and it's good after you can also put it in BDD if you wanted
  • A ver.
    Lo que quiero es que cuando el usuario inicie sección y entre al juego active esa ventana emergente.
    Ahora que se mostraría pues podría variar, digamos que la podría usar para mostrar el inicio de algún evento en el juego, alguna noticia y no hacerlo como mensajes privados como suele suceder.

    RRecuerdo que en el xterium hay algo parecido para mostrar el inicio del tutorial (si la memoria no me falla) .
    Ahora me podría ayudar con el código de cómo sería y así veo si es lo que necesito.
  • Here is the code you requested. It's up to you to use it as you want for the content of the popup page

    the cookie is currently 1 hour in life but to delete it you have plenty of possibilities. Example when disconnecting or when adding a new ect...

    addon

    Smarty-Template: main.footer.tpl

    1. {if $bodyclass != "popup"}
    2. <script type="text/javascript">
    3. $(document).ready(function() {
    4. if($.cookie('news') != 1) {
    5. $.cookie('news', '1', { expires: 1 });
    6. setTimeout(function() {
    7. Dialog.promos();
    8. }, 1000);
    9. }
    10. });
    11. </script>
    12. {/if}
    Display All

    addon in var Dialog = {}


    JavaScript Source Code: base.js

    1. promos: function() {
    2. return Dialog.open('game.php?page=promos', 960, 900);
    3. },
    create new pages


    PHP Source Code: ShowPromosPage.class.php

    1. <?php
    2. class ShowTestPage extends AbstractGamePage
    3. {
    4. public static $requireModule = 0;
    5. function __construct()
    6. {
    7. parent::__construct();
    8. }
    9. public function show()
    10. {
    11. global $LNG, $USER;
    12. $this->setWindow('popup');
    13. $this->initTemplate();
    14. $db = Database::get();
    15. $sql = "SELECT * FROM %%NEWS%% ORDER BY date";
    16. $result = $db->select($sql);
    17. $NewsList = [];
    18. foreach($result as $news) {
    19. $NewsList[] = array(
    20. 'title' => $news['title'],
    21. 'content' => $news['text'],
    22. 'date' => _date($LNG['php_tdformat'], $news['date'], $USER['timezone']),
    23. 'user' => $news['user'],
    24. );
    25. }
    26. $this->assign([
    27. "title" => "Page de test",
    28. "result_list" => $NewsList,
    29. ]);
    30. $this->display('page.promos.default.tpl');
    31. }
    32. }
    Display All
    create tpl page


    Smarty-Template: page.promos.default.tpl

    1. {block name="title" prepend}Promos{/block}
    2. {block name="content"}
    3. <div class="content_page_popup">
    4. <div class="title_popup">
    5. Promos
    6. </div>
    7. <div class="content_popup" style="padding: 20px;">
    8. {foreach from=$result_list item=$newsList}
    9. <div>
    10. <h2>Titre : {$newsList.title}</h2>
    11. <p>{$newsList.content}</p>
    12. </div>
    13. <small style="display: flex; flex-direction: row-reverse; font-weight: bold;"><em>{$newsList.user}</em></small>
    14. <small style="display: flex; flex-direction: row-reverse;"><em>{$newsList.date}</em></small>
    15. </div>
    16. <hr>
    17. {foreachelse}
    18. <div>
    19. <p>Il y a pas de nouvelle actuellement</p>
    20. </div>
    21. {/foreach}
    22. </div>
    23. </div>
    24. {/block}
    Display All
    enjoy ^^
  • Bueno ahora trato de entrar a la administración para crear una noticia (a ver si es como debe funcionar) y me da este error.

    Message: count(): Parameter must be an array or an object that implements Countable
    File: /includes/pages/adm/ShowNewsPage.php
    Line: 68
    URL: localhost/2moons/admin.php?page=news
    PHP-Version: 7.2.30
    PHP-API: apache2handler
    2Moons Version: 2.0.git
  • skynet wrote:

    Bueno ahora trato de entrar a la administración para crear una noticia (a ver si es como debe funcionar) y me da este error.
    patch

    PHP Source Code: ShowNewsPage.php (ADMIN)

    1. $CountList = $NewsList == [] ? 0 : count($NewsList);
    2. $template->assign_vars(array(
    3. 'NewsList' => $NewsList,
    4. 'button_submit' => $LNG['button_submit'],
    5. 'nws_total' => sprintf($LNG['nws_total'], $CountList),
    6. 'nws_news' => $LNG['nws_news'],
    7. 'nws_id' => $LNG['nws_id'],
    8. 'nws_title' => $LNG['nws_title'],
    9. 'nws_date' => $LNG['nws_date'],
    10. 'nws_from' => $LNG['nws_from'],
    11. 'nws_del' => $LNG['nws_del'],
    12. 'nws_create' => $LNG['nws_create'],
    13. 'nws_content' => $LNG['nws_content'],
    14. ));
    Display All
  • Danter14 wrote:

    skynet wrote:

    Bueno ahora trato de entrar a la administración para crear una noticia (a ver si es como debe funcionar) y me da este error.
    patch

    PHP Source Code: ShowNewsPage.php (ADMIN)

    1. $CountList = $NewsList == [] ? 0 : count($NewsList);
    2. $template->assign_vars(array(
    3. 'NewsList' => $NewsList,
    4. 'button_submit' => $LNG['button_submit'],
    5. 'nws_total' => sprintf($LNG['nws_total'], $CountList),
    6. 'nws_news' => $LNG['nws_news'],
    7. 'nws_id' => $LNG['nws_id'],
    8. 'nws_title' => $LNG['nws_title'],
    9. 'nws_date' => $LNG['nws_date'],
    10. 'nws_from' => $LNG['nws_from'],
    11. 'nws_del' => $LNG['nws_del'],
    12. 'nws_create' => $LNG['nws_create'],
    13. 'nws_content' => $LNG['nws_content'],
    14. ));
    Display All
    Ok el problema de las noticias solucionado.

    Pero no se como hacer funcional lo de la ventana emergente?
  • Hello @Danter14


    Can you add this tutorial from the admin panel and add more than one addition, I wrote you a private picture before, or if you make the task system, it would be great, people can do their own tasks and present them.

    Yours truly
  • Bonjour la vous parlez pas du même mod que celui du topic.
    Oui j'ai vu c'est la liste de mods que vous voudrais voir faite pour intégration à la version 2.0
    -----------------------------------------------------
    Hello, you are not talking about the same mod as the one in the topic.
    Yes I saw this is the list of mods you would like to see made for integration into version 2.0
  • Danter14 wrote:

    skynet wrote:

    Ok el problema de las noticias solucionado.

    Pero no se como hacer funcional lo de la ventana emergente?
    WoW ya ahora si, al fina fue que copie dos cosas fuera de lugar, o sea en el mismo archivo pero no en el lugar correcto. Gracias por tomarte la molestia de hacer el video.