3

If I had a structure representing the user guide of a product; is it possible to select a specific version of user guide entries from a URL?

http://www.example.com/myproduct/docs/v2.0/installation

Where the logic would be something like (pseudo-code):

craft.entries('myProductDocs').versionLowerOrEqual('2.0').slug('installation')

I see that Craft has some provision for versioning entries since you can select from the drop-down in the entry editor interface. Is there a way to tame this?

1
  • I realize this is 3+ years old, but stumbled upon it through a semi-related issue. Curious if anyone has come up with a solution, and if it involved (or, could involve) tags/categories. The join/relation might be more complicated, but creating categories or tags for your major/minor versions and "bumping" certain pages would create relation records for that specific entry version. If those are queryable, there might be some opportunity to build some routes and/or nav structures and fetch the appropriate entry versions? Just a thought! – August Miller Jan 11 '18 at 22:05
1

I don't know about searching by version ID natively — I don't think Craft has that capability out-of-the-box... but I can envision setting up such a user guide using a Matrix, where each Matrix block represents a revision of content: Each block would have a field denoting which version the content was written for, along with the content itself. By default, you'd display each entry's most recent content by sorting the blocks by version-update number, and selecting the single most recent block from the sorted set. However, you could also display the docs for a 'legacy' version by filtering out blocks where the version-update number is greater than the version of interest.

3
  • Thanks. This would be feasible if I could have nested matrix blocks, but I am using a matrix for the body content already. – Lea Hayes Dec 1 '14 at 2:29
  • Essentially I want to manually specify which revisions of an entry are major versions... or to somehow tag specific revisions (like one might do with Git). But like you say, currently Craft doesn't seem to offer a way to do this. – Lea Hayes Dec 1 '14 at 2:30
  • I suppose, if you don't have too many major versions, you could add a new field for each version, which in your templates could fall back to the older versions' field data... but that too seems very cumbersome. – Michael Rog Dec 1 '14 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.