Web based family history software

Question Custom pages

More
4 years 8 months ago #1 by Roel
Custom pages was created by Roel
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 - stamboom@roeljongman.nl - www.roeljongman.nl
Windows10 - 64, Firefox browser - webtrees 1.7.19 - Apache 2.2 - PHP 7.2.19 - MySQL 5.5.43 Community

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

  • bertkoor
  • Offline
  • Platinum Member
  • Platinum Member
  • Greetings from Utrecht, Holland
More
4 years 8 months ago - 4 years 8 months ago #2 by bertkoor
Replied by bertkoor on topic Custom pages
Maybe write a Story, can you link to that?

stamboom.BertKoor.nl runs on webtrees v1.7.13
Last edit: 4 years 8 months ago by bertkoor.

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

More
4 years 8 months ago #3 by Roel
Replied by Roel on topic Custom pages
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 - stamboom@roeljongman.nl - www.roeljongman.nl
Windows10 - 64, Firefox browser - webtrees 1.7.19 - Apache 2.2 - PHP 7.2.19 - MySQL 5.5.43 Community

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

  • bertkoor
  • Offline
  • Platinum Member
  • Platinum Member
  • Greetings from Utrecht, Holland
More
4 years 8 months ago #4 by bertkoor
Replied by bertkoor on topic Custom pages
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.

More
4 years 8 months ago #5 by fisharebest
Replied by fisharebest on topic Custom pages
> 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 - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net

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

More
4 years 8 months ago #6 by Roel
Replied by Roel on topic Custom pages
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 - stamboom@roeljongman.nl - www.roeljongman.nl
Windows10 - 64, Firefox browser - webtrees 1.7.19 - Apache 2.2 - PHP 7.2.19 - MySQL 5.5.43 Community

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

More
4 years 8 months ago - 4 years 8 months ago #7 by fisharebest
Replied by fisharebest on topic Custom pages
Replace lines 36 onwards with this
Code:
?> <p>Your HTML goes here</p>

Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Last edit: 4 years 8 months ago by fisharebest.

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

More
4 years 8 months ago #8 by Roel
Replied by Roel on topic Custom pages
Thank you Greg,

Now i can work it out.

Roel - stamboom@roeljongman.nl - www.roeljongman.nl
Windows10 - 64, Firefox browser - webtrees 1.7.19 - Apache 2.2 - PHP 7.2.19 - MySQL 5.5.43 Community

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

More
4 years 8 months ago #9 by Roel
Replied by Roel on topic [SOLVED] Custom pages
Problem solved.

Roel - stamboom@roeljongman.nl - www.roeljongman.nl
Windows10 - 64, Firefox browser - webtrees 1.7.19 - Apache 2.2 - PHP 7.2.19 - MySQL 5.5.43 Community

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

More
3 years 11 months ago #10 by mrqd
Replied by mrqd on topic Custom pages
How to enable "Edit this page" option in "My pages" for that page?

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

More
3 years 9 months ago #11 by Roel
Replied by Roel on topic Custom pages
Is there in webtrees 2 a similar page which i could use to make my own content pages?

Roel - stamboom@roeljongman.nl - www.roeljongman.nl
Windows10 - 64, Firefox browser - webtrees 1.7.19 - Apache 2.2 - PHP 7.2.19 - MySQL 5.5.43 Community

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

More
3 years 6 days ago #12 by conichonhaa
Replied by conichonhaa on topic Custom pages

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?

Webtrees 2.0.19

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

More
3 years 6 days ago #13 by fisharebest
Replied by fisharebest on topic Custom pages
> 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 - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net

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

More
3 years 5 days ago - 3 years 5 days ago #14 by conichonhaa
Replied by conichonhaa on topic Custom pages
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

Webtrees 2.0.19
Last edit: 3 years 5 days ago by conichonhaa.

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

More
3 years 1 day ago #15 by conichonhaa
Replied by conichonhaa on topic Custom pages
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 ?

Webtrees 2.0.19

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

More
3 years 1 day ago #16 by fisharebest
Replied by fisharebest on topic Custom pages
> 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 - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net

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

More
2 years 11 months ago - 2 years 11 months ago #17 by conichonhaa
Replied by conichonhaa on topic Custom pages
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?

Webtrees 2.0.19
Last edit: 2 years 11 months ago by conichonhaa.

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

More
2 years 11 months ago #18 by ric2015
Replied by ric2015 on topic Custom pages

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.1.17 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.

More
2 years 11 months ago #19 by conichonhaa
Replied by conichonhaa on topic Custom pages
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 ?

Webtrees 2.0.19

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

More
2 years 11 months ago #20 by ric2015
Replied by ric2015 on topic Custom pages
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.1.17 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.

Powered by Kunena Forum
}