@boonebgorges
Boone,
An update on the prior post. I tried experimenting with a modification to the single-doc.php template and modified the code to look as follows:
`
__( ‘
Pages: ‘, ‘buddypress’ ), ‘after’ => ‘
‘, ‘next_or_number’ => ‘number’)); ?>
`
This essentially works the same as on a regular WP page, so that at the ‘truncated’ portion of the document I now get:
`Pages: 1 2`
which serves as the multi-page link fields and is what I wanted. However, if I use the link to page 2, just like using the TOC links, I get a ‘white page.’ What I mean is that I get all the contextual information for the document page, but no actual document page output. As in WP, the URL in the link is the same as the base document URL with a /n/ suffix, where n is the page number. It seems to me that the URL is not being handled to drive back to the document production code asking for ‘page n,’ or its getting there and not being understood in terms of what to produce.
Any ideas on where I might go next, or, as I mentioned earlier, is this a possible enhancement?
What I’m playing with here is trying to figure out how to configure a publication scheme for a new community site I am trying to put together. The ability to split a document published as a single page object over multiple view-able pages with a TOC across the page content looks like a nice WP feature. I’m trying to be able to do the same general scheme for BP Group Docs that would use your BPDocs plugin.
Thanks again,
Joe
@joevansteen Thanks for all your experimentation!
I’ve opened a ticket at https://github.com/boonebgorges/buddypress-docs/issues/128 so that I can keep track of this issue.
Your hypothesis that `/n/` is not being caught is probably correct. BP generally handles URL arguments in a way that is different from WP, and BP Docs depends on the WP implementation. So it’s not a surprise that it doesn’t work out of the box. If I were going to implement this in BP Docs, I would probably start by looking at includes/query-builder.php. In particular, you might be able to use some of the filters in setup_item() to specify the page that you’re on. You could also put a “listener” of sorts right into build_query() that looks in $bp->action_variables to see if a page number is defined, and if so, then to show only a certain portion of the document. (Right now there’s no filter in build_query() to help you do this, but I’ll put one in https://github.com/boonebgorges/buddypress-docs/issues/129)
As for implementing this myself, I’ll look into it if I get a chance, though I’m a bit swamped right now. If you find an implementation that works (ideally one that uses `` instead of requiring edits to the template), let me know and I’d be happy to put it into Docs itself.
Also, a quick note about editing single-doc.php. You should be able to copy that template into your child theme (in a directory called /docs/) and edit it there; it should override the one in Docs itself. That way you won’t lose your changes when you upgrade.
@boonebgorges – Thanks for the feedback!
I think this only works as well as it does because of the strategy you used to make as much of BP Docs as possible work by leveraging native infrastructure. I like that philosophy and approach.
Some of what you are talking about is still over my head, but I’ll use your comments as a breadcrumb trail to look into making it work. I think it would be a nice feature to have as part of Docs. I’m also thinking that any solution should probably map as closely as possible to how this is done and handled in WP for native posts and pages. That would keep with the design philosophy and minimize changes in the future. I guess this may also give me a focused reason to do some closer examination of your code. I hear someone said it’s awesome …
Re: single-doc.php. If you’re going to implement a version of this into Docs over time, the single-doc.php change (one line, one function call) should probably be made in the native template file (without the extra parameters,just let it default). That function doesn’t do anything if there is no paging. It only outputs the Page n n+1 n+2 … series if there are multiple pages. A template override should only be needed if special parameters were desired. The parms I used in my sample were just a quick cut-and-paste from another template.
If I find something that seems to work, I’ll pass it along.
Thanks again. I thought you’d be interested.