Special Page Mapping

  1. iLobster

    Sometimes, A link to a special page required by a plugin or theme is required to be hardcoded. An example for this is a link to a cart/help/faq/tos page etc.
    Publicly distributed plugins and themes each have their own implementation for this problem, adding a bit of confusion to the end user. And when developing sites for private clients, I ofter find myself hard-coding page id's, which is obviously not optimal.

    Here is my suggestion:

    1. register_page_type('slug', 'Title', 'Description', 'callback_if_doesnt_exist');
      This will allow a plugin/theme to declare it used the 'tos' page type for example, and an optional callback if the page does not exist, allowing for it to be created.
    2. get_page_type_permalink('slug');
    3. is_page_type('slug');
      simillar to is_page()
    4. page-[type].php in template loading hierarchy (after regular page and before custom template)

    The backend of this would be similar to the navigation menu mapping option, where users can select the page for each page type from a dropdown.

    I would love to contribute this feature to the core if the idea gets approved.

    Posted: 5 years ago #
  2. Ipstenu (Mika Epstein)
    Lead Plugin Wrangler

    I think that would cause too much confusion with http://codex.wordpress.org/Function_Reference/register_post_type

    Especially since this isn't a page 'type' at all, but just a normal page.

    I'm not 100% clear on what you're trying to solve... Can you give a real-world example?

    Posted: 5 years ago #
  3. iLobster

    The terminology might me confusing, but this is totaly different. I'm not talking about a custom post type, but rather a centralised place for mapping one-of special pages with ids from existing pages.

    For example: a theme might want to automaticaly link to the contact page in different places, and in this interface you can define which page is actually the contact page.

    You can also see WooCommerce's custom implementation for choosing the pages for cart/checkout/thank you etc.

    Posted: 5 years ago #
  4. Unsal Korkmaz

    I understand your point but its not belong to core imo. I didnt check WooCommerce's custom implementation but why dont you use it for your self if you liked it?

    Posted: 5 years ago #
  5. iLobster

    Here are the reasons I thing it should be in the core:

    1. The user can find and manage all pages from the same place. If woocommerce Pages are managed within woocommerce, plugin pages within plugins and theme pages in yet another panel, it causes great confusion.

    2. It creates a universal safe and quick way for developers of themes and plugins to require pages, without messing with messy code of libraries they need to include

    3. The biggest use is for custom sites. Usually when you need to create a hard-coded link to a page, it would be done by page ID, which is dangerous if the client accidentally removes that page.

    Posted: 5 years ago #
  6. Ipstenu (Mika Epstein)
    Lead Plugin Wrangler

    Themes and plugins can actually create pages, and pseudo pages. BbPress does it, as does BuddyPress, so I think the logic is there, I'm just not sure how its done. That said, I know that BBPress had fake pages that I could override by making real ones.

    Posted: 5 years ago #

RSS feed for this topic


You must log in to post.

  • Rating

    2 Votes
  • Status

    This idea is under consideration