pressbooks / pressbooks-aldine

Aldine is the default root theme for Pressbooks.
https://pressbooks.org/
GNU General Public License v3.0
11 stars 7 forks source link

Allow network managers to specify title, URL, and simple custom content (text/URLs, etc) for catalog page #194

Closed mcgratay closed 2 years ago

mcgratay commented 4 years ago

Description

The Aldine theme creates its catalog page at anexampleurl.edu/catalog. If an administrator edits this url, the catalog page breaks. There are a couple of variations on this:

  1. User tries to edit the catalog page URL and adds letters to the end of /catalog. The template does not have to be set to Catalog but can be. Example: anexampleurl.edu/catalogue or anexampleurl.edu/catalogaosidfjso Result: The catalog displays, but not well Screen Shot 2019-11-14 at 1 42 36 PM

  2. User tries to edit the catalog page URL and changes it to something that does not start in 'catalog'. The template is set to Catalog. Example: anexampleurl.edu/definitelynotacatalog Result: the catalog disappears Screen Shot 2019-11-14 at 2 03 24 PM

Note: If the user has deleted the default catalog page and made a new one, results of the above are mostly the same with the caveat that the Page Attributes > Template must be set to Catalog in order for the warped Catalog to appear when the URL has added letters (ex: anexampleurl.edu/catalogue)

Desired changes

We add a new theme option to Aldine which allows an administrator to select the Catalog page, kind of like the WordPress option shown below:

Screen Shot 2022-08-17 at 4 58 02 PM

They should only be able to select pages which have the 'catalog' template applied.

See how WordPress does this: https://github.com/WordPress/WordPress/blob/431a8d54140d5514ff38b78c87d2beaea2672f2d/wp-admin/options-reading.php#L85-L148

The option could probably be added here: https://github.com/pressbooks/pressbooks-aldine/blob/7373a5a71031f7939d5242d50956e60251d575f9/inc/customizer/namespace.php#L170-L204

For whichever page is selected as the network catalog page -- we should render whatever user entered content has been produced at the top of the page, and then display the new catalog features below it.

Constructing the catalog in this way will mean that networks can only ever have one and only one catalog page, but that the catalog page can have whatever title/URL they desire. Because Aldine automatically creates an empty 'catalog' page when the theme is activated, we can probably safely set the generic 'catalog' page that already exists in Aldine as the default.

The link to the catalog displayed on the network home page should be updated from a hardcoded link to 'catalog' to dynamically use the URL for whatever page has been designated as the network's catalog page. The link to ‘view complete catalog’ is currently hard coded to point to network_home_url + /catalog/ (not good): https://github.com/pressbooks/pressbooks-aldine/blob/7373a5a71031f7939d5242d50956e60251d575f9/partials/content-front-page.php#L55-L77

We currently hide the visual editor for the ‘Catalog’ page: https://github.com/pressbooks/pressbooks-aldine/blob/7373a5a71031f7939d5242d50956e60251d575f9/inc/actions/namespace.php#L225-L243.

We do this by matching the title of the page (we look for a page title called ‘Catalog’). https://github.com/pressbooks/pressbooks-aldine/blob/7373a5a71031f7939d5242d50956e60251d575f9/inc/actions/namespace.php#L233-L234. We should remove this 'feature' and allow network admins to edit pages which use the 'catalog' page template (or are set as the network 'catalog' page, if we use the theme option method described above).

richard015ar commented 2 years ago

We decided to avoid the multiple selector pages (with catalog template) in the customizer. The reason was because the user would need to select the template in all pages he want to see in the selector, before finally, select the catalog page. Instead, the user would only select the 'Catalog' template in the page she wants to display the catalog and that's it.

I created a branch: pbald-345-catalogSupport, that:

richard015ar commented 2 years ago

We need to rollback this: https://github.com/pressbooks/pressbooks-aldine/blob/pbald-345-catalogSupport/inc/actions/namespace.php#L237 since we are allowing to add post content from the new plugin instead.

tw77 commented 2 years ago

Applying the 'Catalog' template to a root site page works as expected. I was able to add an additional page with this template at https://integrations.pressbooks.network/temporary-test-catalog/.