Problem generating tiddler from form and template

Hello everyone.

I usually create the most common tiddlers using a button and an associated template, that works perfectly for me.

The fact is that I am trying to make a form for cooking recipes, and probably for other things that require entering data that I may have in lists, but I can’t get it to work.

The form is this:

Nombre de la receta:
    <$edit-text
        tiddler='$:/temp/modelo/recetas/NuevaReceta'
        field=receta_nombre
        class='recipesearchbar'
    />

Tipo de receta:
<$select tiddler='$:/temp/modelo/recetas/NuevaReceta' field='receta_tipo' tooltip='Cambia el tipo de receta'>
<option value=''>-</option>
<option value='Acompañamiento'>Acompañamiento</option>
<option value='Cena'>Cena</option>
<option value='Desayuno'>Desayuno</option>
<option value='Entrante'>Entrante</option>
<option value='Merienda'>Postre</option>
<option value='Plato principal'>Plato principal</option>
<option value='Postre'>Postre</option>
<option value='Otros'>Otros</option>
</$select>

Categoría:
<$select tiddler='$:/temp/modelo/recetas/NuevaReceta' field='receta_categoria' tooltip='Elige la categoría de la receta'>
<option value=''>-</option>
<option value='Aperitivos y tapas'>Aperitivos y tapas</option>
<option value='Arroces y cereales'>Arroces y cereales</option>
<option value='Aves y caza'>Aves y caza</option>
<option value='Carne'>Carne</option>
<option value='Consejos de cocina'>Consejos de cocina</option>
<option value='Cócteles y bebidas'>Cócteles y bebidas</option>
<option value='Ensaladas'>Ensaladas</option>
<option value='Guisos y Potajes'>Guisos y Potajes</option>
<option value='Huevos y lácteos'>Huevos y lácteos</option>
<option value='Legumbres'>Legumbres</option>
<option value='Mariscos'>Mariscos</option>
<option value='Pan y bollería'>Pan y bollería</option>
<option value='Pasta'>Pasta</option>
<option value='Pescado'>Pescado</option>
<option value='Postres'>Postres</option>
<option value='Salsas'>Salsas</option>
<option value='Sopas y cremas'>Sopas y cremas</option>
<option value='Verduras'>Verduras</option>
</$select>

Foto:
<$edit-text
	tiddler='$:/temp/modelo/recetas/NuevaReceta'
	field=foto
	class='recipesearchbar'
	placeholder='Introduce la foto de la receta'
	tag=textarea
    />

Pie de foto:
<$edit-text
	tiddler='$:/temp/modelo/recetas/NuevaReceta'
	field=foto_pie
	class='recipesearchbar'
	placeholder='Introduce el texto para el pie de la foto'
	tag=textarea
    />

Keywords:
<$edit-text
	tiddler='$:/temp/modelo/recetas/NuevaReceta'
	field=keywords
	class='recipesearchbar'
	placeholder='Introduce las palabras clave para la receta'
	tag=textarea
    />

<$button>
<$action-createtiddler 
        $basetitle={{$:/temp/modelo/recetas/NuevaReceta!!receta_nombre}} 
            tags='Recetas'
            icon='$:/images/fa5/solid/utensils'
            receta_tipo={{$:/temp/modelo/recetas/NuevaReceta!!receta_tipo}}
            receta_categoria={{$:/temp/modelo/recetas/NuevaReceta!!receta_categoria}}
            receta_modococinado={{$:/temp/modelo/recetas/NuevaReceta!!receta_modococinado}}
			foto={{$:/temp/modelo/recetas/NuevaReceta!!foto}}
			foto_pie={{$:/temp/modelo/recetas/NuevaReceta!!foto_pie}}
			keywords={{$:/temp/modelo/recetas/NuevaReceta!!keywords}}
			caption={{$:/temp/modelo/recetas/NuevaReceta!!caption}}
/>

<$action-setfield
            $tiddler='$:/temp/modelo/recetas/NuevaReceta'
            receta_nombre=''
            receta_tipo=''
            receta_categoria=''
            receta_modococinado=''		
            foto=''
            foto_pie=''
            keywords=''
            caption=''
            tags=''
/>


Añade receta
</$button>

And the model I want for the recipes is this:

\define createNewItem()
  <$action-sendmessage 
	$message="tm-new-tiddler" 
	title=<<unusedtitle """New $(new-item-title)$""">> 
	tags="[[$(currentTiddler)$]]"
	foto="$:/plugins/kookma/thinkup/images/mr_avatar"
	foto_pie="Nombre de la foto" 
	caption="nombre de la receta"
	text=<<content>>
	keywords=""	
	receta_categoria=""		
	receta_modococinado=""
	receta_tipo=""
    />

\end


\define content()

<table class="table-borderless source">
<tr><td>{{$:/plugins/timit/iconos/knife-fork-fill}}</td><td>{{!!receta_tipo}}</td><td>{{!!receta_modococinado}}</td><td>{{!!receta_categoria}}</td></tr>
</table>

: <<.lorem>>

<$macrocall $name=image-pretty img={{!!foto}} align="right" caption={{!!foto_pie}} tooltip={{!!foto_pie}} alt=""/>

;Ingredientes
: """ 
<<.lorem>>
 """
;Preparación
"""<p>

#<<.lorem>>

</p>"""

;Consejos
: """
<<.lorem>>
"""

\end

But I can’t get them to work. I took the form model from a cooking wiki a long time ago but I don’t understand how it works. I have tried several combinations but the only thing I get is that a tiddler is generated with the name of the recipe and the fields filled with the data entered in the form, but the design of the recipe does not appear…

I have tried the template by putting it in a tiddler called: $:/temp/model/recipes/NuevaReceta or importing it but it doesn’t work for me.

Maybe some of you have dealt with a similar problem or can tell me how to correctly connect those two tiddlers.

Thank you so much.

The template here is just some macros that are not being invoked. They may be used by a template, but I don’t think they are the template.

In your original recipe, look for the actual template – things tagged $:/tags/ViewTemplate . To do this, go to the advanced search, filter tab. Paste in:

[all[tiddlers+shadows]tag[$:/tags/ViewTemplate]]

I’m guessing that there will be a recipe template that renders your new recipes.

1 Like

Hi @Mark_S.

Well, I don’t have any viewtemplate. I had simply saved the tiddler with the form a long time ago and now I was trying to adapt it to my needs but I wasn’t able to.

In the end I got it. :sweat_smile: The entries of the different values of the cooking recipes are stored in a temporary tiddler, but in the text field I tell it to look for the tiddler where I have the template and it now takes it well.

Now I have a more complicated question, at least for me who doesn’t have enough programming knowledge like me.

How can I take text from the form, such as the steps to cook a recipe, and put it in the indicated place on the template?

Let me explain, I don’t want to have a field with the preparation of the recipe, I want it to appear as part of the tiddler text. But I have no idea how that could be done… :roll_eyes:

Thank you so much.

Hello Xabrina,

When you use a template, you control what appears in the body of the tiddler, in the very place where the text field usually appears. (But the text field of the recipe tiddler is not actually affected; it remains empty, OR you could decide to use the text field for something like the directions or overview.)

I should say, also, that I think there are various models for recipe tiddlywikis floating around. I don’t recall where, but I think if your thread had “recipes” in the title, people would be more likely to notice while scanning messages here…

Anyway, here’s a setup that loosely models what you’re talking about, with a basic view template:

https://quick-demo.tiddlyhost.com/#template%20for%20recipes:[[template%20for%20recipes]]%20[[Sopa%20de%20lentejas]]%20[[recipe%20input]]

I haven’t tried to add the additional fields into the “new recipe” form. I also haven’t tried to make an edit template – which would be ideal eventually.

Take a look, and see how you want to modify what’s there to fill out your ideal!

Generally there’s two different approaches.

One is that you make ViewTemplate for displaying each recipe, e.g. You tag all your recipes “Recitas” and create a view template and tag it $:/tags/ViewTemplate. Then you use your regular TW tools to search for recipes, but the view template for viewing them. It might have text like this:

<$list filter="[all[current]tag[Recetas]]">

<$macrocall $name="thumbnail-right" 
  link="Recipes" image={{!!foto}} caption={{!!caption}} 
  icon={{!!icon}} color="red"/>

!! {{!!caption}}

''Categoria'': {{!!receta_categoria}}

''Tipo'': {{!!receta_tipo}}

''Direcciones'' :

{{!!receta_modococinado}}

</$list>

(I’m doing this on TiddlyWiki.com to leverage its macros, you would want to use your own macros).

So a recipe you created with fields like this:

image

Might appear like this:

The other common approach would be to make a “Dashboard” for searching and viewing all your recipe tiddlers. I guess I would start with the view template approach first, and then decide how much value there would be in a more dedicated approach.

Hello @Springer.

What I will put in the text field will be the ingredients; the preparation and surely advice on how to prepare the recipe along with a sample photo.

You are right about that. I didn’t put it in since I wanted to learn how the form and template worked and then use it for other things besides cooking recipes.

Thanks for the example. Last night, after thinking about it a lot, I arrived at that same template configuration. I already understand how it works, it was difficult for me but I understood how everything worked.

I don’t understand what you mean by that. Are you referring to a template to edit the recipe once created???

Thank you so much.

Hi @Mark_S.

I thank you for your explanations on this matter. I think I’ll go for the first option. For what I want, that gets me.

In the future, as I learn more about Tw, and according to my needs, I may take the step to the next level.

Thank you so much.