Page 1 of 1

[Solved] Do FEU user props still work in CGUserDirectory?

Posted: Wed Jan 13, 2016 4:27 pm
by Utter
Hi all,

I have just upgraded a fairly elderly site that used FEU and UserDirectory modules in tandem. On a user profile page, a UserDirectory detail template allowed a logged in user to view their profile details but rather than just dumping info to the page via the foreach I used this code:

Code: Select all

{capture assign="userid"}{$oneuser.id}{/capture}
{$feu_smarty->get_user_properties($userid,'userprops')}
to pipe specific FEU user properties into a table like this:

Code: Select all

<td class="profile-detail-value">{$userprops.email_address}</td>
After I updated the two modules and all the other main modules like CGExtension/SimpleSmarty etc. the profile page showed a blank.

The changelog of FEU at version 1.29 states:

Code: Select all

{$feu_smarty->get_user_properties($uid,'props')} must now be called like: {$props=feu_smarty::get_user_properties($uid)}
But when I rewrote my own code to

Code: Select all

{capture assign="userid"}{$oneuser.id}{/capture}
{$userprops=feu_smarty::get_user_properties($userid)}
it borked the page again and it's only when this piece of code is in the template that the problem occurs.

Have I made a mistake in rewriting this code or do FEU properties no longer work the same way in UserDirectory?

The Apache error logs were spectacularly unhelpful and I have not come across another query of this nature on the forums.

My relevant system data is:

CMS Version 1.12 / CGExtensions 1.50 / CGSimpleSmarty 1.9.1 / FrontEndUsers 1.30.6 / CGUserDirectory 1.5

Current PHP Version (phpversion) 5.5.9-1ubuntu4.14

Thanks in advance.

Re: Do FEU user properties still work in CGUserDirectory?

Posted: Thu Jan 14, 2016 12:31 am
by calguy1000
welcome back utter. I will Look at this tomorrow.

Re: Do FEU user properties still work in CGUserDirectory?

Posted: Thu Jan 14, 2016 10:50 am
by Utter
Thanks, Robert.

Re: Do FEU user properties still work in CGUserDirectory?

Posted: Thu Jan 14, 2016 1:29 pm
by Utter
Robert,

I had another bash at generating some errors for the log and got this which may help:

Code: Select all

[Thu Jan 14 07:36:10.449456 2016] [:error] [pid 3037] [client 91.108.183.34:51823] PHP Notice:  Trying to get property of non-object in /var/www/html/tpb/tmp/templates_c/1ed9b7e2d86c34f9dab8c572f920035e590a161e.tpl_body.27.php on line 179, referer: http://xxx.xxxxx.co.uk/my-profile
[Thu Jan 14 07:36:10.449469 2016] [:error] [pid 3037] [client 91.108.183.34:51823] PHP Stack trace:, referer: http://xxx.xxxxx.co.uk/my-profile
[Thu Jan 14 07:36:10.449484 2016] [:error] [pid 3037] [client 91.108.183.34:51823] PHP   1. {main}() /var/www/html/tpb/index.php:0, referer: http://xxx.xxxxx.co.uk/my-profile
[Thu Jan 14 07:36:10.449500 2016] [:error] [pid 3037] [client 91.108.183.34:51823] PHP   2. Smarty_CMS->fetch() /var/www/html/tpb/index.php:243, referer: http://xxx.xxxxx.co.uk/my-profile
[Thu Jan 14 07:36:10.449517 2016] [:error] [pid 3037] [client 91.108.183.34:51823] PHP   3. Smarty_Internal_TemplateBase->fetch() /var/www/html/tpb/lib/classes/class.Smarty_CMS.php:341, referer: http://xxx.xxxxx.co.uk/my-profile
[Thu Jan 14 07:36:10.449533 2016] [:error] [pid 3037] [client 91.108.183.34:51823] PHP   4. content_56978366d2a7a0_71279906() /var/www/html/tpb/lib/smarty/libs/sysplugins/smarty_internal_templatebase.php:182, referer: http://xxx.xxxxx.co.uk/my-profile

Re: Do FEU user properties still work in CGUserDirectory?

Posted: Thu Jan 14, 2016 2:56 pm
by calguy1000
Just tested the CGUD Detail view.

This code worked fine to view the user properties:

Code: Select all

{$props1=$oneuser.properties}
<p>First Name = {$props1.first_name}</p>
{debug_display($props1,'props1')}
As did this code (returned exactly the same results).

Code: Select all

{$props2=feu_smarty::get_user_properties($oneuser.id)}
<p>First Name = {$props2.first_name}</p>
{debug_display($props2,'props2')}
Note. I have a property called first_name in my setup. prolly different in your install.

Re: Do FEU user properties still work in CGUserDirectory?

Posted: Thu Jan 14, 2016 4:35 pm
by Utter
Robert,

thanks for that - page is back as it was now.

Can I conclude then that it's the Smarty {capture} syntax that's changed? I should have checked whether there was an update to capture but I just looked now and the syntax does seem different.

Now I just need to work out why none of the form fields appear on the Orders billing/shipping forms and I'm done :)

Thanks again.

Re: Do FEU user properties still work in CGUserDirectory?

Posted: Thu Jan 14, 2016 4:41 pm
by calguy1000
Can I conclude then that it's the Smarty {capture} syntax that's changed? I should have checked whether there was an update to capture but I just looked now and the syntax does seem different.
Well, no the capture syntax has not changed... but variable scoping has changed, depending on what you were upgrading from and how your templates are organized etc. various things that did work in very old versions of CMSMS will have to be adjusted for newer versions. Typically even those changes are minor once you wrap your head around them.

{capture} is slow, and by and large should not be used. Smarty3 has more optimal ways to copy data around.

{$myvar=$oneuser.id} would do the trick in your case. but again, wasn't really necessary in the example you provided as $oneuser.id works fine.