No announcement yet.

Showing Header Conditionally

  • Filter
  • Time
  • Show
Clear All
new posts

  • #16

    Perhaps this JSFiddle I created will help. In this example, buttons would simulate events in your application. Here I am displaying a new image source, but I see from your latest post that you might wish to display textual information instead. What you would need to do is replace the code that changes the image source and substitute jQuery code to update a text element. In the example, I update a <span> with the maximum seconds to wait for an image change. You could do something similar perhaps using the number of records. This example is all on the client side, but if you need to send information from a server process, AJAX is your friend. This is where I defer to others more knowledgeable in Scriptcase. Let me know if you need some vanilla PHP as an example.



    • #17
      Hi ARTHUR

      I found a solution for your problem, cause I did have the following issue:
      Inside the menu bottom line, I wanted to show the info, when (what time) the active Session is expired. This expired date should be refreshed every time when the user clicks anything in the menu. In my case every menu opens a new tab (but doesnt matter for this example).
      Solution overview is:
      After the user logged in, I do set the footer line to the desired content:
      Logged in as: admin(Administrator) at 3:37 pm, Session expires at: 04:01:55 pm
      When the user clicks a menu item, I do refresh only all text which is after "at:"
      I do this by calling an external PHP-file, which is called by AJAX. Problem was that the Menu in SC is not supporting Ajax, so I had to find a solution for this.

      What you have to do to achieve this refreshment:
      1. Menu, Layout, Header and Footer: ROD_LIN1_COL2, Value

      2. Menu, onApplicationInit:
      $session_will_expire_at = date("h:i:s a", time() + ini_get('session.gc_maxlifetime'));
      [footer_bottom_line_right] = "Logged in as: " .[usr_login] ."(" .[group_name] .") at " .[login_time] .", Session expires at: " .$session_will_expire_at;
      3. Menu, onLoad: I add JavaScript, which will calls the PHP file by Ajax everytime when the user clicks on a Menu item. I am searching for the Element 'rod_col2', get the current content, make the Ajax call and modify the current line

      window.onload = function() {
      $(document).on('click', 'li > a', function() { /* calls this function whenever an "a" object inside a "li" object is clicked */
      /* links each menu item to a different image, in case your "id" is empty or does not exists it does */
      function changemyfooter(id_menu)
      var span = document.getElementById("rod_col2");
      var current_content = document.getElementById("rod_col2").innerHTML;
      current_content = current_content.substring(0, current_content.indexOf('at:')+3);
      // Call Ajax to adjust the line
      complete: function (response) {
      span.textContent = current_content + response.responseText;
      error: function () {
      span.textContent = 'There was an error calling the function';
      4. I create a PHP-file as follows, the file I put inside the main folder of my Project: (not inside the Menu-folder, cause it will be deleted, once you generate the App)
      File get_footer.php:
      echo date("h:i:s a", time() + ini_get('session.gc_maxlifetime'));
      This solution works, but its not an elegant solution of course. Especially cause the additional file "get_footer.php" is not managed by Scriptcase
      If anyone has an idea how to put that file into ScriptCase, would be fine. I did upload the file to the internal Libraries, but then I dont know where I can find it, i mean what is the URL to access it

      Hope it helps you
      Last edited by reto.peter; 01-31-2016, 05:46 AM.


      • #18
        reto.peter - This is interesting solution - thanks for sharing. I'm working on another part of the project at the moment and I'm still considering coming back to this because I need to show some variable info which will remain on the screen all the time. I will get back to this in a few weeks and will test your solution to see how this works.