Before asking for help please read "Requesting Help and Suggestions" by clicking on that tab above here.
  • Page:
  • 1
  • 2

TOPIC:

Custom pages 3 weeks 14 hours ago #21

  • conichonhaa
  • conichonhaa's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 9
I looked in all examples in module_v4
I've got problems to understand perfectly every settings

I saw in the footer
public function getPageAction(ServerRequestInterface $request): Response$    {
        return $this->viewResponse($this->name() . '::page', [
            'title' => $this->title(),
            'tree'  => $request->getAttribute('tree'),                               ]);
    }

with the ::page and I understood that it's forwarded to the page.phtml because resources and views folder are also declared

I try to use it in a list page (I'm not sure if it's the best place to use it) to to load my page.phtml
And there I've got the getListAction() or whatever getxxxAction()
I have to had an action to my form, that I understood but I do not understand how to do that

What I use is from the theme module (without CSS stuff)
public function boot(): void
    {
        // Register a namespace for our views.
        View::registerNamespace($this->name(), $this->resourcesFolder() . 'v$
        // Replace an existing view with our own version.
        View::registerCustomView('::page', $this->name() . '::page');
    }

I don't need tree, i don't need database stuff, that's just a page with buttons to correct email problem (i disable certificate check on my private mail server in EmailService.php)

I could do it manually in 2 minutes after every webtrees update but my challenge is to create a page to do that
And it takes me a few weeks :)))

Please Log in or Create an account to join the conversation.

Last edit: by conichonhaa.

Custom pages 1 week 5 days ago #22

  • conichonhaa
  • conichonhaa's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 9
I used another method, creating menu is too complicated for me
I use the jc-simple-menu module to create new menu and i'm allowed to insert code in the new created page
So what i'm going to do works, but i'm trying to have the result of the request in the same page without luck
I tried php stuff, ajax too without success

Here is my code for my menu page
<!DOCTYPE html>
<html>
    <head>
<!-- Include the JQuery library !-->
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>  
    </head>
        <body>
        <form method="POST" id="updateForm" action="action.php">
        <input type="submit" value="Check des fichiers" name="button2">
        </form>
        <div id="ajaxResponse"></div>

        
        <script>
            <!-- Add a listener. This will be invoked when the form is submitted, 'submit' is the action, and '#updateForm' is the context it is listening !-->
            $(document).on('submit','#updateForm',function(e){

                <!-- This stops the original event. So that's the original submit action of the form. !-->
                e.preventDefault();

                <!-- Get the form data and serialize it into an array. !-->
                var data = $('#updateForm').serializeArray();

                <!-- The AJAX request. '.post' indicates that it should be a POST request. 'data' add the serialized array in the POST request. 'htmlResponse' is the response you get from the POST request, in your case your echo rules.  !-->
                $.post('action.php',data,function(htmlResponse){
                    <!-- The POST request is finished and the response is putted in the htmlResponse variable. So display this by setting the content(html) of the ajaxResponse div to the htmlResponse variable  
                    $('#ajaxResponse').html(htmlResponse);
                });
            });
        </script>

        </form>
        </body>
        </html>

and here is my action.php page
<?php
if(isset($_POST['button2'])) {
        $lines1 = file('/var/www/html/EmailService.php', FILE_IGNORE_NEW_LINES);
        $lines2 = file('/var/www/html/EmailServicecopy.php', FILE_IGNORE_NEW_LINES);
        $result = array_diff( $lines1, $lines2 );
        print_r( $result );
        }
?>

This works perfectly as i'm comparing 2 files and print differences
But with this ajax method it loads a new page

I tried
<form method="POST" action=" ">
or
<form method="POST" action="#">
too

That doesn't work

Please Log in or Create an account to join the conversation.

Last edit: by conichonhaa.
  • Page:
  • 1
  • 2
Powered by Kunena Forum