Lesson 4.3: Offset, limit and pinning
Two small settings and one trick turn dynamic lists into editorial tools. Offset and limit cut one query into a lead story and a list below it. Pinning puts a hand-picked item at a fixed place in a list that otherwise looks after itself.
At a glance
| Course | Exponential Layouts |
| Module | Module 4: Collections |
| Duration | 45 minutes (15 presenting, 30 exercise) |
| Level | Intermediate |
| Audience | Editors and site builders |
| Prerequisites | Lesson 4.2 |
Learning objectives
After this lesson, learners can:
- set offset and limit on a collection;
- build a lead-plus-list from two blocks with the same query;
- pin a manual item at a position of a dynamic collection;
- note the reason for a pin in the block's name.
Trainer's notes
How to present it
Sources: Collections and Pinning: mixing hand-picked and dynamic content.
- Offset and limit (4 minutes). They apply after the query has run: offset skips items from the start, limit shows at most that many. A "featured" block with limit 1 and a "more stories" block with offset 1 and limit 6 make the familiar lead-plus-list from one ordering.
- Pinning (5 minutes). Manual items added to a dynamic collection become pinned overrides: each keeps its stored position, and the query fills the slots around it. A pin at position 0 is first, whatever the query returns. Pinned positions are absolute within the collection.
- Advice (2 minutes). Pin as little as possible, and write why in the block's Name, or the next editor will not understand why position 3 never changes.
- Messages (2 minutes). The editor may report items skipped or out of range (for example 2 manual items out of range) when a pin sits beyond the limit.
Common questions
Why does my pinned item not show? Its position is beyond the limit.
Can the same article appear in the lead and the list? Not when the list's offset skips the lead's items and both use the same query and order.
How do I unpin? Remove the manual item from the collection.
Pitfalls
- Different sorting in the two blocks. Offset only works when both blocks use the same query and order.
- Forgotten pins. A pin stays until removed. The name note helps.
- Positions counted from zero or one. Check how your installation numbers positions before the exercise.
Hands-on exercise
Use the training installation and your course layout with the Newest articles block from lesson 4.2.
- Open your course layout with Open (continue your draft if asked).
- Duplicate Newest articles with Duplicate block. Rename the first
Lead articleand the secondMore articles. - In Lead article, set the limit to 1 and the view type to
grid_featured(or another view type that stands out). - In More articles, set the offset to 1 and the limit to 4.
- Check in the editor: the lead shows the newest article, the list the next four.
- In More articles, press + Add items and pick one of your own articles; put it at the first position with Set position.
- Rename the block
More articles (pinned: course article, until end of course). - Set the limit of More articles to 2 and watch what happens to the pinned item and the others; set it back to 4.
- Choose Save draft and close.
Expected result
- The draft has a lead block with one article and a list of four below it, without duplicates.
- One pinned item sits at the first place of More articles, with the reason in the block's name.
- The trainer checks by opening one learner's draft on the projector.
Quiz
- What do offset 1 and limit 6 do?
- How do you build a lead-plus-list from one query?
- What is a pinned item? A. A hidden item B. A manual item at a fixed position of a dynamic collection C. A deleted item D. A shared block
- Why write the reason for a pin in the block's name?
- A pinned item does not appear. What is the most likely reason?
Answers
- Skip the first item and show at most six after it.
- Two blocks with the same query and order: the first with limit 1, the second with offset 1 (Exponential Layouts).
- B.
- So the next editor knows why that position never changes.
- Its position is beyond the collection's limit.
Further reading
Related pages
- Module 4: Collections
- Exponential Layouts: course overview
- Trainers: start here
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.