Prepending parent object's title in child object's caption for includes? #162
-
For includes that feature a child object, I'm looking for a way to prepend the parent's title as part of the caption. I've poked around in the code a bit but don't have much experience with Liquid/Ruby so struggling a bit with this... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@taliaperry that's a good question for that usecase! A couple thoughts (as related to CB-CSV, CB-Gh would be a bit different): First, this might come up regularly for "multiple" items just like you describe. Generally, in those cases in CB-CSV the parent record has a image_small and image_thumb that matches the images of the first child (think of a postcard front)--so people tend to just use the parent record. In your example, this would miss out of the "Front View" part, but have the full item title. Second, the quick way to do it, without customizing the code, would be to use the caption option and manually put the title you want, i.e. Finally, customizing the include is definitely possible if this is something that would regularly come up in your collection (and something we will think about in the template too). In the file "_includes/feature/image.html", look at line 38 which currently looks like:
We will replace that line with a bit more complicated logic:
This Liquid will first check if you manually set a caption (and use it), then if it is has a parent it will find the parent title and use it + the item title, otherwise just use the title title. |
Beta Was this translation helpful? Give feedback.
@taliaperry that's a good question for that usecase! A couple thoughts (as related to CB-CSV, CB-Gh would be a bit different):
First, this might come up regularly for "multiple" items just like you describe. Generally, in those cases in CB-CSV the parent record has a image_small and image_thumb that matches the images of the first child (think of a postcard front)--so people tend to just use the parent record. In your example, this would miss out of the "Front View" part, but have the full item title.
Second, the quick way to do it, without customizing the code, would be to use the caption option and manually put the title you want, i.e.
{% include feature/image.html objectid="example01a"…