phpBB

Development Discussion Board

phpBB's testing ground of bleeding edge code
Advanced search

[RFC] Global template variable for user avatar

Publish your own request for comments or patches for the next version of phpBB. Discuss the contributions and proposals of others. Upcoming releases are 3.1/Ascraeus and 3.2/Arsia.

Re: [RFC] Global template variable for user avatar

Postby callumacrae » Mon Jul 23, 2012 3:05 pm

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?
"In JavaScript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders"
—Douglas Crockford

View my MOD, phpBB Mobile
User avatar
callumacrae
Website Team
Website Team
 
Posts: 883
Joined: Tue Apr 27, 2010 9:37 am
Location: England

Re: [RFC] Global template variable for user avatar

Postby psoTFX » Mon Jul 23, 2012 3:16 pm

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
psoTFX
Registered User
 
Posts: 1984
Joined: Tue Jul 03, 2001 8:50 pm

Re: [RFC] Global template variable for user avatar

Postby callumacrae » Mon Jul 23, 2012 5:36 pm

That's *really* ugly, though. (at least, in my opinion).
"In JavaScript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders"
—Douglas Crockford

View my MOD, phpBB Mobile
User avatar
callumacrae
Website Team
Website Team
 
Posts: 883
Joined: Tue Apr 27, 2010 9:37 am
Location: England

Re: [RFC] Global template variable for user avatar

Postby Senky » Mon Jul 23, 2012 6:14 pm

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?
Senky
Registered User
 
Posts: 222
Joined: Thu Jul 16, 2009 4:41 pm

Re: [RFC] Global template variable for user avatar

Postby imkingdavid » Mon Jul 23, 2012 6:17 pm

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.
User avatar
imkingdavid
Development Team
Development Team
 
Posts: 905
Joined: Thu Jul 30, 2009 12:06 pm

Re: [RFC] Global template variable for user avatar

Postby drathbun » Mon Jul 23, 2012 6:27 pm

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
drathbun
Registered User
 
Posts: 72
Joined: Wed Feb 15, 2006 6:40 pm
Location: Texas

Re: [RFC] Global template variable for user avatar

Postby MichaelC » Mon Jul 23, 2012 6:50 pm

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.
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
MichaelC
Website Team
Website Team
 
Posts: 798
Joined: Thu Jan 28, 2010 6:29 pm

Re: [RFC] Global template variable for user avatar

Postby callumacrae » Mon Jul 23, 2012 7:14 pm

The dot is more common on the client side, too.
"In JavaScript, there is a beautiful, elegant, highly expressive language that is buried under a steaming pile of good intentions and blunders"
—Douglas Crockford

View my MOD, phpBB Mobile
User avatar
callumacrae
Website Team
Website Team
 
Posts: 883
Joined: Tue Apr 27, 2010 9:37 am
Location: England

Re: [RFC] Global template variable for user avatar

Postby naderman » Tue Jul 24, 2012 1:40 pm

I think this is just fine now. It works and we should move on to more important problems rather than bikeshedding over this ;-)
www.naderman.de
Move your forum to Forumatic - we'll take care of maintenance & spam
User avatar
naderman
Development Team Leader
Development Team Leader
 
Posts: 1650
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany

Previous

Return to [3.x] RFCs

Who is online

Users browsing this forum: Marc, Octopus2 and 17 guests