Page Type showing "Home page" or "page" randomly - wagtail

I followed Official Wagtail Docs to integrate freshly installed Wagtail into existing Django project.
I added customized HomePage class in existing Django's models.py.
# myDjangoProject/models.py
class HomePage(Page):
template = "homepage.html"
content = RichTextField()
content_panels = Page.content_panels + [
FieldPanel("content")
]
Q1: In above screenshot, Why system default page Welcome to Wagtail is of Page TYPE, while newly created New Page is of Home page TYPE automatically ?
Q2: In above screenshot, Why Newly-created child page under system default page Welcome to Wagtail is of Home page surprisingly without any manual configuration ?
Q3: In above screenshot, why all newly-created pages automatically (no manual configuration required) inherited from my customized HomePage class in MyDjangoProject/models.py ? How is this reflected on source code level ?

The Page class is the base class of all page types in Wagtail, but normally it wouldn't be desirable to let users create pages that are of the type Page rather than something more specific, because there's no way to add new content fields to it. For this reason, the is_creatable attribute is set to false on Page, which means that new pages of that type can't be created through the admin interface. (This attribute is not inherited by subclasses, so any new page types you create will be is_creatable = True by default.)
The initial "Welcome" page is created as part of the migrations in the wagtail.core app. At this point, Page is the only page type that exists (since your HomePage model hasn't been defined yet), so that's the one Wagtail uses. It might seem a bit weird that the default page is not one that you can create yourself through the admin, but there's no real alternative (other than not providing a default page at all, which would make it harder for developers to see if their installation has worked).
(When setting up a brand new Wagtail project through wagtail start, the project template includes migrations to replace the initial Page instance with an instance of the supplied HomePage model, so in this case it's less confusing.)
After you defined your HomePage model, this became the only page type with is_creatable = True, and so the admin interface automatically selects this page type on adding a new page. When you add another page model alongside HomePage, you'll find that it prompts you to select a page type.

Related

How to edit Default.Page.Template Content in DotNetNuke?

How to change home page content in DNN while creating a site itself.
I need to change different page. I created a new page and created Template. And I replaced inside Templates folder named (Default. page. template). But it is not working out. Provide me a better solution.
Probably the easiest way to do this is to create a site using the default template, edit that site to create your own site, and then save that as a site template (suitable named). You can then use that site template to create sites with the page structure that you want.
The default page template (I believe) is used when you create new pages using the the Pages UI. I don't believe that the default page template is used by the default site template.
If you have created a page and would like to apply a specific page template to the new page retroactively. To do this, go to the page that you want to change and append ?ctl=ImportTab to the url. That will bring up a dialog that allows you to change the emplate for a page with lots of options. It

Wagtail: how to change the default root and/or home page

How do I create my custom home page at the root level for my site?
I'm integrating wagtail to my django project. As documented I try to plug my custom homepage model and create a new site record
... You’ll probably want to replace this with your own HomePage class -
when you do so, ensure that you set up a site record (under Settings /
Sites in the Wagtail admin) to point to the new homepage.
When I try to update my site's root settings, page explorer doesn't list my custom home page. And I'm unable to create a page from my model at the root level. When I delete the existing root page, then I'm totally stuck.
Any guidance will be appreciated. Thanks.
Update (resolved)
Thinking that my custom home page will be the root of my side, I had this setting parent_page_types = [] in my model. Removing it lets me add it as child to existing root, which I can point in my site as the root.
Note: This was answered in the question via an update, pasting below for future readers.
On the page model, setting parent_page_types = [] meant that this page could not be put under other pages. As the root page is also a page, it meant the home page could not be set correctly.
Removing it lets you it as child to existing root, which I can point in my site as the root.
Docs - Page.parent_page_types

How do I modify Drupal's Admin Screens?

I'm looking to edit Drupal's admin pages.
Some of the things I'm trying to achieve:
Remove is the the filter setting on the Content page/node/view. In other words, if I go to to the Content page and I filter by a certain type of node, then I leave that page, then come back, the filter setting is saved, I'd like it to reset each time I visit the Content page.
I would like to modify some of links associated with these pages, as an example on that Same Content page, the titles of the pages are linked to their 'front-end' views, I'd rather have them link to their 'edit' screens.
While I have been successful in modifying the front-end theme of Drupal, by editing the actual php files. I can't find the the same php files for the Admin theme. In our case we are using Seven (7.21). I've read something about views, and thought maybe the entire Admin theme is built as views, aka there no php files involved like the front-end theme has, but under the Views section I did not find any either. I'm still pretty new at this and coming from the Wordpress world, this is a Drupal is a lot different.
The logic for that section of the admin area is at (from the public root):
/modules/node
Specifically "node.admin.inc"
That being said, I don't recommend editing core scripts, as they will be overwritten when you update the core.
You could explore making your own module to supplement that page, or your own view or explore some pre-made modules, such as "Admin Views"
Find de view displayed and go to its configuration :
1 - Edit configuration view like suggested here : https://drupal.stackexchange.com/questions/44440/how-to-remember-exposed-filter-choices
2 - Rewrite output views to rewrite link : field https://www.drupal.org/node/1578524
Another option is to create and use your own dashboard/views to achive like you want http://definitivedrupal.org/suggestions/creating-custom-administrator-view-content
also you can see contrib module : https://www.drupal.org/project/admin_views
You don't have to use that default content overview page at all. Make your own instead:
Make a page view (you have to install views module if you already did not: https://www.drupal.org/project/views) and use table layout. Make sure that page paths starts with "admin" so it will use admin theme. Also pay attention about permissions, so only specific set of users (admins) can use it.
For that view you can freely select what columns you what to show. You can also allow ordering by any column and action if you click on some field.
Use exposed filters to add filtering form, again add any filters you need. You can even set the form to use AJAX, to do auto-submit when some filter field is changed, include reset button and more. Also for every exposed filed you can select (at fields settings) should it remember it's value or not.
At end, edit admin menu and add your new page to it so it will look and act as default one but will offer much more functionality. You can even totally remove default one from the admin menu.
Views module is very powerful, not only for front-end but also for back-end content handling.

Wagtail: how to restrict all pages to logged in users only

I am using Wagtail for an internal knowledge base. I would like all pages to default to 'Accessible to logged in users'.
This is possible on a page-by-page basis using the 'privacy' setting: http://docs.wagtail.io/en/v1.8.1/advanced_topics/privacy.html
How can I make this the default for all pages?
The privacy settings are inherited by all child pages so if you make your Homepage accessible to logged in users then all its children (i.e all pages) will also have the same privacy setting! Notice that by "Homepage" I mean the root page of your wagtail tree ie the first page that you see to its right after you click "Explorer" in wagtail admin (on single site wagtail setups).

How do I link a Wagtail custom form to its output?

When a custom form is created in Wagtail, I can see that it stores in the DB. What I'm not clear on is how to make it so that the admin UI contains the results in some manner. (A new link which lets you download a CSV would be fine, but I don't see how to do that)
How do I allow admin users the ability to see the results of the custom forms? Is this library the only way?
Once you create your first form page (i.e. a page of any page type that subclasses AbstractForm), a 'Forms' item will automatically appear in the left menu of the Wagtail admin. This provides a listing of all the form pages that exist on the site, allowing you to access the results of each one and download them as a CSV.

Resources