Page 1 of 1

how 2 display the news id in news detail content??

Posted: Sat Nov 30, 2024 2:47 pm
by map_1961
how 2 diplay the news id in news article deatail content??
i.e if id is 65 dispay: "ID: 65"

thanks


MAP

Re: how 2 display the news id in news detail content??

Posted: Sat Nov 30, 2024 3:34 pm
by DIGI3
A good way to see what's available in something like a news detail template is to print_r the variable in your template, e.g. add this line to the top:

Code: Select all

<pre>{$entry|print_r}</pre>
This tells us that

Code: Select all

{$entry->id}
will output the ID.

Re: how 2 display the news id in news detail content??

Posted: Sat Nov 30, 2024 4:54 pm
by map_1961
thank you ❤️

Re: how 2 display the news id in news detail content??

Posted: Sat Nov 30, 2024 6:17 pm
by map_1961
The ID call using {$entry->id} works proper - perfect!!!

May i ask if there is also a way to insert this unique news ID automaticly in a formbuilder form - called in the news detail template .
I use this form as a request form for this specific news...?? The automatic insertion into the formbuilder form would facilitate the request and avoid errors.
I set up a UDT and insert: $entry->id; -- then i called this udt in formbuilder as a UDT field - but the result is empty

Thx

MAP

Re: how 2 display the news id in news detail content??

Posted: Sat Nov 30, 2024 6:21 pm
by DIGI3
Look under the Advanced tab in the Formbuilder help, it tells you how to pass a default value to a form. Essentially, you would have a hidden (or not) field in your form, and the call would be something like:

Code: Select all

{FormBuilder form='my_form' value_myfieldname='$entry->id'}

Re: how 2 display the news id in news detail content??

Posted: Sat Nov 30, 2024 8:10 pm
by map_1961
Calling this tag {FormBuilder form='my_form' value_myfieldname='$entry->id'} into formbuilder confirmation template results in an page error.
I lik to gt the news id result nto the form or into the confirmation after sending.

THX

MAP

Re: how 2 display the news id in news detail content??

Posted: Sat Nov 30, 2024 8:24 pm
by DIGI3
I think you've misunderstood a fair bit here. I'll try to break it down, but make sure to also read the documentation I suggested.

The value_myfieldname='$entry->id' parameter goes into your initial FormBuilder tag. The myfieldname part gets changed to the name of your field (usually a hidden field within your form). By adding this parameter, it will set the default value of that field to the value of $entry->id

You don't call FormBuilder a second time, especially from your submission template. By setting the value of this hidden field, you'll have it as a variable to use in your submission template, email templates, etc., just as if the visitor had entered that value into a field.