[RFC] Global template variable for user avatar

Note: We are moving the topics of this forum and it will be deleted at some point

Publish your own request for comments/change or patches for the next version of phpBB. Discuss the contributions and proposals of others. Upcoming releases are 3.2/Rhea and 3.3.
User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] Global template variable for user avatar

Post by callumacrae »

Code: Select all

<div>
<!-- BEGIN somerow -->
   <ul>
      <li>{somerow.VAR1}</li>
      <li>{somerow.VAR2}</li>
   </ul>
<!-- END somerow -->
</div>

Code: Select all

// Loop twice
for ($i = 0; $i < 2; $i++)
{
   $template->assign_block_vars('somerow', array(
      'VAR1' => "Just a string with the value of \$i: $i",
      'VAR2' => ($i * 4),
   ));
}
That's an array, no?
Made by developers, for developers!
My blog

User avatar
psoTFX
Registered User
Posts: 1984
Joined: Tue Jul 03, 2001 8:50 pm
Contact:

Re: [RFC] Global template variable for user avatar

Post by psoTFX »

That's an array you can loop over accessing the elements it contains. This RFC adds the following capability:

Code: Select all

<!-- BEGIN somerow -->
   <ul>
      <li>{somerow.VAR1[element1]}</li>
      <li>{somerow.VAR1[element2]}</li>
   </ul>
<!-- END somerow -->

Code: Select all

// Loop twice
for ($i = 0; $i < 2; $i++)
{
   $template->assign_block_vars('somerow', array(
      'VAR1' => array(
         'element1' => 'Hey, this is block  ' . ($i + 1),
         'element2' => 'How you doing?'
      )
   ));
}
Awful example but you get the idea. As per the OP the original intent was to allow quick access to large data sets in vars like $user->data, e.g.

Code: Select all

<p>Hello {USER_DATA[username]} this is your avatar {USER_DATA[avatar_img]}</p>
Again awful example but that's the idea. You can't iterate over {USER_DATA}, you need to specify the element you wish to access.

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] Global template variable for user avatar

Post by callumacrae »

That's *really* ugly, though. (at least, in my opinion).
Made by developers, for developers!
My blog

Senky
Extension Customisations
Extension Customisations
Posts: 315
Joined: Thu Jul 16, 2009 4:41 pm

Re: [RFC] Global template variable for user avatar

Post by Senky »

callumacrae wrote:That's *really* ugly, though. (at least, in my opinion).
I share your opinion, however as mentioned above, we probably should not use dot (.), so maybe find another separating character? Any ideas?

User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: [RFC] Global template variable for user avatar

Post by imkingdavid »

callumacrae wrote:That's *really* ugly, though. (at least, in my opinion).
So the options we are looking at are:
<p>Hello {USER_DATA[username]} this is your avatar {USER_DATA[avatar_img]}</p>
<p>Hello {USER_DATA->username} this is your avatar {USER_DATA->avatar_img}</p>
<p>Hello {USER_DATA.username} this is your avatar {USER_DATA.avatar_img}</p>

I personally like the first one, or the second if we can't go with the first. I still don't think we should use a dot.
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

drathbun
Registered User
Posts: 72
Joined: Wed Feb 15, 2006 6:40 pm
Location: Texas
Contact:

Re: [RFC] Global template variable for user avatar

Post by drathbun »

To me USER_DATA[username] seems the most natural of the three options provided.
Sometimes you're the windshield, sometimes you're the bug.

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: [RFC] Global template variable for user avatar

Post by MichaelC »

imkingdavid wrote:
callumacrae wrote:That's *really* ugly, though. (at least, in my opinion).
So the options we are looking at are:
<p>Hello {USER_DATA[username]} this is your avatar {USER_DATA[avatar_img]}</p>
<p>Hello {USER_DATA->username} this is your avatar {USER_DATA->avatar_img}</p>
<p>Hello {USER_DATA.username} this is your avatar {USER_DATA.avatar_img}</p>

I personally like the first one, or the second if we can't go with the first. I still don't think we should use a dot.
I personally like the dot - Looks neater, but the [] are more standardised.
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] Global template variable for user avatar

Post by callumacrae »

The dot is more common on the client side, too.
Made by developers, for developers!
My blog

User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: [RFC] Global template variable for user avatar

Post by naderman »

I think this is just fine now. It works and we should move on to more important problems rather than bikeshedding over this ;-)

Post Reply