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

TOPIC:

Custom pages 1 year 9 months ago #1

  • Roel
  • Roel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 40
I could not find it, but is there a way to create my own custom pages, which i can refer to from Vytux_menu 2.

I think i need a 'emty' file (php), which only shows the header and footer and whre i can add my own (html or markdown) text and images.
I could use the Vytux_pages to create this pages, but they have some disadvantages, while they always link to the Vytux_pages menu and also display all files created by this module.

Does anybody know a solution for this or can help me with a "empty" file which i can use?
Roel - This email address is being protected from spambots. You need JavaScript enabled to view it. - www.roeljongman.nl
Windows10 - 64, Palemoon browser - webtrees 1.7.16 - Apache 2.2 - PHP 7.2.19 - MySQL 5.5.43 Community

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

Custom pages 1 year 9 months ago #2

  • bertkoor
  • bertkoor's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Greetings from Utrecht, Holland
  • Posts: 2240
Maybe write a Story, can you link to that?
stamboom.BertKoor.nl runs on webtrees v1.7.13

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

Last edit: by bertkoor.

Custom pages 1 year 9 months ago #3

  • Roel
  • Roel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 40
Hello Bert,

I did not miss the Vytux_pages; i use it on my website.

But as i wrote they have the disadvantage that they always refer to the Vytux_pages menu-title and that they show all the files that are created by this module.

If i could use the pages without these 2 disadvantages i would be happy.
Roel - This email address is being protected from spambots. You need JavaScript enabled to view it. - www.roeljongman.nl
Windows10 - 64, Palemoon browser - webtrees 1.7.16 - Apache 2.2 - PHP 7.2.19 - MySQL 5.5.43 Community

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

Custom pages 1 year 9 months ago #4

  • bertkoor
  • bertkoor's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Greetings from Utrecht, Holland
  • Posts: 2240
I guess you posted while I edited my answer ;-)
stamboom.BertKoor.nl runs on webtrees v1.7.13

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

Custom pages 1 year 9 months ago #5

  • fisharebest
  • fisharebest's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 14403
> help me with a "empty" file which i can use?

Creating a custom page is pretty easy.
Find a simple existing page and copy it.
The repository list is a good example.
github.com/fisharebest/webtrees/blob/1.7/repolist.php

Replace the filename on line 29.
Replace the page title on line 33.
Replace the content on lines 36-39 with whatever you want to appear on the page.
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

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

Custom pages 1 year 9 months ago #6

  • Roel
  • Roel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 40
Thank you Greg,

This is exactly what i ment.
Just figure out how to put HTML in the new page (my lack of php-experience).
Perhaps you could provide me with some basic code, that i can work out.
Roel - This email address is being protected from spambots. You need JavaScript enabled to view it. - www.roeljongman.nl
Windows10 - 64, Palemoon browser - webtrees 1.7.16 - Apache 2.2 - PHP 7.2.19 - MySQL 5.5.43 Community

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

Custom pages 1 year 9 months ago #7

  • fisharebest
  • fisharebest's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 14403
Replace lines 36 onwards with this
?>

<p>Your HTML goes here</p>
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

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

Last edit: by fisharebest.

Custom pages 1 year 9 months ago #8

  • Roel
  • Roel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 40
Thank you Greg,

Now i can work it out.
Roel - This email address is being protected from spambots. You need JavaScript enabled to view it. - www.roeljongman.nl
Windows10 - 64, Palemoon browser - webtrees 1.7.16 - Apache 2.2 - PHP 7.2.19 - MySQL 5.5.43 Community

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

Do you need a web hosting solution for your webtrees site?
If you prefer a host that specialises in webtrees, the following page lists some suppliers able to provide one for you: 

[SOLVED] Custom pages 1 year 9 months ago #9

  • Roel
  • Roel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 40
Problem solved.
Roel - This email address is being protected from spambots. You need JavaScript enabled to view it. - www.roeljongman.nl
Windows10 - 64, Palemoon browser - webtrees 1.7.16 - Apache 2.2 - PHP 7.2.19 - MySQL 5.5.43 Community

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

Custom pages 1 year 2 days ago #10

How to enable "Edit this page" option in "My pages" for that page?

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

Custom pages 10 months 1 week ago #11

  • Roel
  • Roel's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 40
Is there in Webtrees 2 a similar page which i could use to make my own content pages?
Roel - This email address is being protected from spambots. You need JavaScript enabled to view it. - www.roeljongman.nl
Windows10 - 64, Palemoon browser - webtrees 1.7.16 - Apache 2.2 - PHP 7.2.19 - MySQL 5.5.43 Community

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

Custom pages 4 weeks 2 days ago #12

  • conichonhaa
  • conichonhaa's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 9

Roel wrote: Is there in Webtrees 2 a similar page which i could use to make my own content pages?


I think I could be interested too
Is there a workaround?

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

Custom pages 4 weeks 2 days ago #13

  • fisharebest
  • fisharebest's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 14403
> Is there in Webtrees 2 a similar page which i could use to make my own content pages?

In the modules_v4 folder, there is an "example-footer".

This creates:
1 a footer
2 a page
3 a link to the page.

You can copy this, and edit to suit your requirements.
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

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

Custom pages 4 weeks 1 day ago #14

  • conichonhaa
  • conichonhaa's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 9
Thanks a lot
I made a copy from example-footer
I edited it a bit

But how I reach this new created page
I look in all modules in settings to see if I had to enable it but nothing found

Problem solved
The module.php file doesn't have to be renamed

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

Last edit: by conichonhaa.

Custom pages 3 weeks 3 days ago #15

  • conichonhaa
  • conichonhaa's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 9
I used your example-footer successfully, i just got a few more questions
When used it loads page.phtml stored in resources/views and i edited a bit with html and php code
It's a page with buttons and they do a few tasks

When i press on it i see a message This Form as expired
I read in your forum that it's related with CSRF token but i don't uderstand how to implement it in my code.

I tried to use this footer as a list (i removed ModuleFooterInterface and replaced it with ModuleListInterface and ModuleListTrait) in order to manage who has right to view this special page
And that works. I find the page in the list view but when i load it i got the error Method getListAction() not found in "mymodule"

I'm a bit noob and i don't understand how to link this list to the page.phtml in resources/views
Is it possible to explain me ?

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

Custom pages 3 weeks 3 days ago #16

  • fisharebest
  • fisharebest's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 14403
> I read in your forum that it's related with CSRF token but i don't uderstand how to implement it in my code.

When you submit a form, you must include a security token ("CSRF").

It is easy to add this - just one line.
Just look at any other form. e.g.
github.com/fisharebest/webtrees/blob/2.0...clean-data.phtml#L25

> i got the error Method getListAction() not found in "mymodule"

When you vist the URL "/module/mymodule/List/..."

webtrees will call the function getListAction() in the module "mymodule".

You can generate URLs with lots of different actions, and each can be created by a different function.

NOTE that if you post data to the server (e.g. with an HTML form), then your function should be postXxxxAction() instead of getXxxxAction()
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

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

Custom pages 3 weeks 2 days ago #17

  • conichonhaa
  • conichonhaa's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 9
I succeed a bit, it works thanks a lot but I think I can improve that
I set my form like this in page.phtml
<form method="post" action="/path from file/page.phtml">
When press my buttons I get my results correctly but it loads my page page.phtml without any formating like the previous page
The previous page looked like webtrees interface, the second not.
And I can't call back the module.php page.

Is it possible to load interface back in the phtml file?

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

Last edit: by conichonhaa.

Custom pages 3 weeks 1 day ago #18

  • ric2015
  • ric2015's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 239

conichonhaa wrote: I set my form like this in page.phtml
<form method="post" action="/path from file/page.phtml">
Is it possible to load interface back in the phtml file?


That's not how to do it - You should never call view files directly. Always use urls pointing to your module instead (or use a registered route, but that's a more complex topic).

Anyway Greg already described how to do this:

fisharebest wrote: When you vist the URL "/module/mymodule/List/..."

webtrees will call the function getListAction() in the module "mymodule".

You can generate URLs with lots of different actions, and each can be created by a different function.

NOTE that if you post data to the server (e.g. with an HTML form), then your function should be postXxxxAction() instead of getXxxxAction()


We should probably have an example module for this. In general, it is always a good idea to look at existing (main or custom) modules and understand how they do it. Although note that most of them now use registered routes and implement RequestHandlerInterface directly, rather than using the get/postXxxxAction approach.
Richard

webtrees 2.0.15 at cissee.de/webtrees2
Vesta custom modules (Classic Look & Feel, Gov4Webtrees, Shared Places, Extended Relationships) available at cissee.de

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

Custom pages 3 weeks 1 day ago #19

  • conichonhaa
  • conichonhaa's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 9
I don't really understand where I have to put my getListAction() and how. Do I have to call back the module.php file or the page.phtml with the form ?

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

Custom pages 3 weeks 23 hours ago #20

  • ric2015
  • ric2015's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 239
There are several modules in webtrees that have a 'getListAction' - Have you done this

ric2015 wrote: In general, it is always a good idea to look at existing (main or custom) modules and understand how they do it.


at all?

Earlier you wrote that you have modified the example-footer module: The module does exactly what you're looking for (so we do have an example for this after all)!

The example module defines a url (in getFooter) to be used for subsequent actions. This url is passed to the initial view (footer.phtml). The url has a query parameter ('action' => 'Page'), which name matches the 'getPageAction' in the module - therefore that is the method that is called via the url. From this method, you can then (evaluate query or form parameters and) call another view (page.phtml in the example).

In your case, you have to use a similar url in your form action, and define a postXxxxAction, rather that a getXxxxAction, because forms are POSTed. The (middle part of the) name of the action is up to you, 'getListAction' was just an example.
Richard

webtrees 2.0.15 at cissee.de/webtrees2
Vesta custom modules (Classic Look & Feel, Gov4Webtrees, Shared Places, Extended Relationships) available at cissee.de

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

  • Page:
  • 1
  • 2
Powered by Kunena Forum