Caption rotation: multiple template variants per service #155

Open
opened 2026-06-23 13:33:56 +00:00 by jmiller · 2 comments
Owner

Summary

Allow multiple caption variants per template. When cross-posting (especially evergreen re-shares), rotate through variants to avoid repetitive posts. Revive Old Posts (WordPress) pioneered this.

Implementation

Database

Add variant_group column to #__mokosuitecross_templates:

  • Templates with the same service_type and variant_group are rotation candidates
  • Dispatcher picks one at random (or round-robin) per post

Alternative (simpler)

Use the existing template body with a {random:opt1|opt2|opt3} placeholder syntax:

{random:Check out|Don't miss|New post:} {title}

{url}

This avoids schema changes and is more intuitive.

Acceptance Criteria

  • {random:opt1|opt2|opt3} placeholder resolved at render time
  • Random selection per post (not per placeholder instance in same template)
  • Works with evergreen re-shares for variety
  • Documented in template editor help text
## Summary Allow multiple caption variants per template. When cross-posting (especially evergreen re-shares), rotate through variants to avoid repetitive posts. Revive Old Posts (WordPress) pioneered this. ## Implementation ### Database Add `variant_group` column to `#__mokosuitecross_templates`: - Templates with the same `service_type` and `variant_group` are rotation candidates - Dispatcher picks one at random (or round-robin) per post ### Alternative (simpler) Use the existing template body with a `{random:opt1|opt2|opt3}` placeholder syntax: ``` {random:Check out|Don't miss|New post:} {title} {url} ``` This avoids schema changes and is more intuitive. ## Acceptance Criteria - [ ] `{random:opt1|opt2|opt3}` placeholder resolved at render time - [ ] Random selection per post (not per placeholder instance in same template) - [ ] Works with evergreen re-shares for variety - [ ] Documented in template editor help text
Author
Owner

Implemented in commit 7e5ff12. {random:opt1|opt2|opt3} placeholder resolved in renderTemplate() via preg_replace_callback. Uses array_rand() for selection. Resolved after standard placeholders but before custom field lookup, so you can combine: {random:Check out|Read|New:} {title}.

Implemented in commit `7e5ff12`. `{random:opt1|opt2|opt3}` placeholder resolved in `renderTemplate()` via `preg_replace_callback`. Uses `array_rand()` for selection. Resolved after standard placeholders but before custom field lookup, so you can combine: `{random:Check out|Read|New:} {title}`.
Author
Owner

Testing Checklist

Migrated from #173

Test Steps

  • {random:opt1|opt2|opt3} in template resolves to one of the options
  • Different posts pick different options (not always the same)
  • Multiple {random:} placeholders in same template each pick independently
  • Works alongside other placeholders: {random:Check out|Read} {title}
  • Pipe character inside options handled correctly
  • Single option {random:only} returns "only"
  • Empty placeholder {random:} handled gracefully (no PHP error)

Related

  • #155 (implementation, closed)
## Testing Checklist _Migrated from #173_ ## Test Steps - [ ] {random:opt1|opt2|opt3} in template resolves to one of the options - [ ] Different posts pick different options (not always the same) - [ ] Multiple {random:} placeholders in same template each pick independently - [ ] Works alongside other placeholders: {random:Check out|Read} {title} - [ ] Pipe character inside options handled correctly - [ ] Single option {random:only} returns "only" - [ ] Empty placeholder {random:} handled gracefully (no PHP error) ## Related - #155 (implementation, closed)
jmiller reopened this issue 2026-06-23 17:20:12 +00:00
Sign in to join this conversation.
No labels
Priority Medium
Type Feature
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MokoConsulting/MokoSuiteCross#155