We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

In $TMPL->var_single the key includes formatting parameter

Development and Programming

Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

HI,

According to docs

The Template class array for single variables is $TMPL->var_single, where the keys are the variable’s name and the the values are the full variable including brackets and any formatting parameters (i.e. for dates).

But the code

foreach ($TMPL->var_single as $key => $val)
{
  echo '['.$key.']['.$val.']';
}

for the variables

{entries_list_entry_date date_format="%Y-%m-%d"}
{previous_entry_date date_format="%Y-%m-%d"}
{next_entry_date date_format="%Y-%m-%d"}

outputs these strings

[entries_list_entry_date date_format="%Y-%m-%d"][entries_list_entry_date date_format="%Y-%m-%d"]
[previous_entry_date date_format="%Y-%m-%d"][previous_entry_date date_format="%Y-%m-%d"]
[next_entry_date date_format="%Y-%m-%d"][next_entry_date date_format="%Y-%m-%d"]

instead of these

[entries_list_entry_date][entries_list_entry_date date_format="%Y-%m-%d"]
[previous_entry_date][previous_entry_date date_format="%Y-%m-%d"]
[next_entry_date][next_entry_date date_format="%Y-%m-%d"]

It seems that including parameters into key does not conform to docs, isn’t it?

Also the value does not include brackets, as it should according to docs.

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
16 years ago
Lisa Wess's avatar Lisa Wess

Laisvunas - is this in regards to a module you’re developing? I’m not familiar with those tags and want to make sure I get you the right assistance.

Thanks!

       
Laisvunas's avatar
Laisvunas
879 posts
16 years ago
Laisvunas's avatar Laisvunas

Hi Lisa,

Single variables

{entries_list_entry_date}
{previous_entry_date}
{next_entry_date}

belong to my Entries List plugin.

I’m coding a new version of this plugin; in the new version I want to add possibility to use “date_format” parameter inside these variables, as here:

{entries_list_entry_date date_format="%Y-%m-%d"}
{previous_entry_date date_format="%Y-%m-%d"}
{next_entry_date date_format="%Y-%m-%d"}

I tried to parse these variables by looping through $TMPL->var_single array and found that its features seems to be different from description in docs.

In all cases I checked in $TMPL->var_single array keys and values are the same. Seeing this I do not understand the reason why $TMPL->var_single array is associative.

Contrary to description keys include parameters; also contrary to description values do not include brackets.

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
16 years ago
Lisa Wess's avatar Lisa Wess

Hi, Laisvunas - thanks for clarifying; I’ve moved your post to a more appropriate forum. =)

       
Nathan Pitman's avatar
Nathan Pitman
531 posts
15 years ago
Nathan Pitman's avatar Nathan Pitman

Hi all, did anyone find a solution to this???

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.