Front End Users - template variable names?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Simon66
Power Poster
Power Poster
Posts: 250
Joined: Wed Aug 29, 2007 4:36 am

Front End Users - template variable names?

Post by Simon66 »

I'm trying to write a custom template for the 'Change Setting Template' in FEU.

The sample template loops through the controls with:

Code: Select all

{foreach $controls as $key=>$field}
But I'm trying to access them individually, and I've tried:

Code: Select all

$controls->username.prompt.value
$controls->username.prompt
$controls->fieldsbyname.username.prompt.value
$controls->fieldsbyname.username.prompt
$field->username.prompt.value
$field->username.prompt
$field->fieldsbyname.username.prompt.value
$field->fieldsbyname.username.prompt
Is there a method to working this out?
Different modules have different ways of defining individual variable names. Could this be unified across modules?
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: Front End Users - template variable names?

Post by JohnnyB »

This will give you the custom field's prop name.

$field->propname

So, if you have a "First Name" Prompt that was assigned a Name with first_name, you can do something like:

Code: Select all

{foreach $controls as $key=>$field}
		{if $field->propname == 'first_name'}
// Put tags/HTML for label and input fields
{/if}
{/foreach}
In one of my FEU change settings template that has over 100 property fields and somewhat complex form layout, I am using multiple {foreach $controls as $key=>$field} loops to control the layout and grouping of input fields.

Best way to know what template variables are available is to do something like

{foreach $controls as $key=>$field}
<pre>{$field|print_r}</pre>
{/foreach}
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
Simon66
Power Poster
Power Poster
Posts: 250
Joined: Wed Aug 29, 2007 4:36 am

Re: Front End Users - template variable names?

Post by Simon66 »

This is awesome, thanks. I was close to beating my head against a wall last night.

As I don't write code I don't know if this is a stupid question. But would it be possible to unify individual variable calls so they're the same across all modules?

Like this:

Code: Select all

$image->fieldname.value
$entry->fieldname.value
$item->fieldname.value
Simon66
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: Front End Users - template variable names?

Post by JohnnyB »

No, not a stupid question. I suppose it could be somewhat possible, but not probably not realistic. I just usually do the {$the_module_var|print_r} or use {get_template_vars} when using a module for the first time to see what data is available and how to access it from the arrays.
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
Post Reply

Return to “Modules/Add-Ons”