Transclusion of image field

Hello,

I’m trying to translate and customize the odin Recipe plugin. One thing I want to do is to add an image to each recipe.

I have been successful so far for new recipes but I do something wrong with the edit template.

In a few words the transclusion of my image doesn’t work, see below:

 {{$:/plugins/Odin/Recette/SelectRecetteEdit}}

<$button>
<$action-setfield $tiddler={{$:/plugins/Odin/Recette/Selection}} recipe-type={{$:/temp/Odin/Recette/NewRecette!!recipe-type}}/>
Enregistrer les changements
</$button>

Image de la recette:
    <$edit-text
        tiddler={{$:/plugins/Odin/Recette/Selection}}
        field=recipe-image
        class='recipesearchbar'
        tag=input
    />

<$transclude tiddler="$:/plugins/Odin/Recette/Selection">
<$image source={{!!recipe-image}} />
</$transclude>.

    Ingrédients:
    <$edit-text
		tiddler={{$:/plugins/Odin/Recette/Selection}}
        field=recipe-ingredients
        class='recipesearchbar'
        tag=textarea
    />
    Instructions:
    <$edit-text
		    tiddler={{$:/plugins/Odin/Recette/Selection}}
        field=recipe-instructions
        class='recipesearchbar'
        tag=textarea
    />
    Intro de la recette:
    <$edit-text
				tiddler={{$:/plugins/Odin/Recette/Selection}}
        field=recipe-quote
        class='recipesearchbar'
        tag=textarea
    />
...

The $:/plugins/Odin/Recette/Selection hold the title of the recipe tiddler currently being edited.

Any suggestion?

Thank you.

You need to “read” that Selection tiddler to get to the tiddler named there, then work with the fields that are in that tiddler…

<$tiddler tiddler={{$:/plugins/Odin/Recette/Selection}}>
<$image source={{!!recipe-image}} />
</$tiddler>

The curly brackets read and pass the value on, rather than opaquely saying “use this quoted string as a string.”

I’m using tiddler widget rather than transclude, because then you can do lots of stuff within that widget, like give it some text below from the caption field {{!!caption}} or whatever else you like. Within the “tiddler” widget space, everything you do behaves as if you were “in” that tiddler.

Thank you Springer, this works perfectly and this is very useful to know.

Today I found that

<$transclude $tiddler={{$:/plugins/Odin/Recette/Selection}} $field=recipe-image />

also works provided the field “recipe-image” contains [img[image-tiddler-name]], which is less elegant than your solution.

1 Like