Blog Sections Open

Passing the Current Ditto Resource into a Video Snippet

A Ditto scope lesson about passing the current resource id into a helper snippet that reads video TVs.

A classic Ditto gotcha appears when a template renders a helper snippet that expects the current resource id, but the snippet ends up seeing the surrounding page instead of the Ditto item. That is exactly what happened in this historical video-output case.

The setup

A sidebar listed news teasers, while the center of the page rendered the latest news resource in full via Ditto. Inside the item template, another snippet was expected to read TVs and output a matching video block.

<div class="new-main">
  <h2>[+pagetitle+]</h2>
  [+content+]
  [[addvideofile]]
</div>

Why the video did not appear

The helper snippet was not receiving the Ditto item context. Instead, it fell back to the current page context, which meant it read TVs from the listing page rather than from the resource being rendered by Ditto.

The practical fix

Pass the Ditto row id explicitly into the helper and let the helper load TVs for that resource instead of assuming the current document is the right one. In older Evo projects, making the current item id explicit was usually the cleanest way to avoid scope confusion.

Why this belongs in the archive

This is a small but very reusable Ditto lesson: once a template starts calling extra snippets, document scope is no longer obvious. Making the active resource explicit is often the difference between a reliable template and a debugging session.

Related posts

Using a TV Value as the documents Source for Ditto
Using Snippet Output as the Source for a TV Value

Why this belongs in the timeline

This post matters because it shows how Evolution CMS teams solved real project problems with small, explicit patterns instead of heavy abstractions. That practical, incremental style is one of the clearest through-lines in the old Evo ecosystem.

Newer post

Google Translate TV Output in Evolution CMS: An Early Automation Idea

A historical experiment in automatically translating TV content through an external service.

Older post

Returning a Real 404 for Missing Shopkeeper Products in External Tables

A practical pattern for avoiding empty 200 pages when a requested product record does not exist.