21
3lr0n
Re: data from custom user fields on forums
  • 2009/5/13 12:45

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


Hmmz, dont work :(

Wouldnt be easy to set it as a function on functions.php and call it from the php file that construct the post structure?, the you you can assing it to a smarty vble and print it like <{$data}>,

but i dont know how to set it :(

any help?

Spanish Overclocking Community xoops based site : http://www.overclocking.es

22
mboyden
Re: data from custom user fields on forums
  • 2009/5/13 19:01

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


Did you read this post which links to a tutorial on custom info in smarty templates? Yes, since it's custom code for your site, and you didn't give the exact variables, it's tougher to answer exactly, rather members have provided examples from which you can learn to adapt it to your specific needs.

Based on your original request:Quote:
I need to check if the field has data. If it has, i show the processor (the data from the textfield) and if it dont i will show a link to inform the benefits of filled the fields.
I'll give it a try.... Based on your notes, it seems they must be a user, so you you must test for the user first and then if so, get the data or the link. Insert this into your template (but modify with your specific needs:
<{if $xoops_isuser}>
<{
php}>
// Add a Smarty Constant from $xoopsUser
define("MYUNIQUE_FIELDNAME", ($GLOBALS['xoopsUser']->getVar('fieldName')) ? $GLOBALS['xoopsUser']->getVar('fieldName') : "The Benefits of Filled the Fields" ;
<{/
php}>
<{/if}>
<
p>Here is the output: <$smarty.const.MYUNIQUE_FIELDNAME}>p>

Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

23
3lr0n
Re: data from custom user fields on forums
  • 2009/5/13 21:19

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


Sry, I think must made a mistake in my explain.

I need to show to all users that are looking the forums some fields of each posting users. I mean, for example, you mboyden have a field in the db that is the location, for you Austin . I need to show in the post some poster information that is stored in profile custom fields.

I dont care is the person who is searching my website is a logged user or not, the info must be avaible to all visitors, like the "from" field of your profile is.

Do you understand me now?

I feel really sry for this mistake, all of you are putting a lot of effort on help me, and Iam really grateful

Spanish Overclocking Community xoops based site : http://www.overclocking.es

24
pablo103
Re: data from custom user fields on forums
  • 2009/5/13 23:50

  • pablo103

  • Not too shy to talk

  • Posts: 181

  • Since: 2008/2/3 1


This is useful, i will also be happy to implement this hack. can anyone please spent 10 minutes to write down the code for us?
greatings

25
pablo103
Re: data from custom user fields on forums
  • 2009/5/14 17:52

  • pablo103

  • Not too shy to talk

  • Posts: 181

  • Since: 2008/2/3 1


is anyone reading this forum?

26
mboyden
Re: data from custom user fields on forums
  • 2009/5/14 18:43

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


Of course we read the forums. While I don't always monitor the forums daily myself, I have recently.

Also, we can't always do custom coding for everyone -- what your request essentially is. XOOPS does a lot, but there is always room for more. I suspect that no one has yet done what you are asking -- I haven't pulled from the extended profile data via smarty outside of the profile module. The example I provided did a bit but doesn't load new data.

I suspect your solution will require some custom code, and probably a hack into the include/common.php file or something like that that checks if the profile class is loaded, then loads the profile info (assuming a user), then assigns the data to some variable. Likely best would be for there to be a method in XOOPS to auto-magically make that data available in your templates/themes.

Hmmmm. Sounds like another rainy day task. Actually, though, I do have an upcoming project that this would be good for, but I'm behind on another at the moment as well as going off the grid for a couple of days.

So, if I understand correctly your "task":
Load the data from the custom profile fields and add that to a smarty tag that can be used in the themes and templates by profile field_name, while realizing that your templates would become custom because the custom profile fields are all custom fields and can change at anytime (thus "breaking" your templates).
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

27
3lr0n
Re: data from custom user fields on forums
  • 2009/5/14 21:11

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


Hi,

thats it. I need to add some custom profile fields (not all of them) to some smarty vbles.

The "problem" I guess, as you said, the newbb use member handler, not the profile module. My first idea was add some data retreaving in the same part the usual fields are got (from, etc...), but as the profile handler is not created I cant.

Thks in advance!
Spanish Overclocking Community xoops based site : http://www.overclocking.es

28
mboyden
Re: data from custom user fields on forums
  • 2009/5/14 21:36

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


Should be easy as hacking it somewhere (either in the module, or in XOOPS) to see if it's a user, if so, then load (once) the profile handler object, then instantiate the object using the user id, then do a loop to make all the variables available as smarty variables. includes/common.php could be a good place to do that and make available in all your modules. So, just some code and some testing.
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

29
trabis
Re: data from custom user fields on forums
  • 2009/5/14 21:38

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


This works for me:
<{php}>
      global 
$xoopsTpl$xoopsUser;

      
$myField '';
      if (
is_object($xoopsUser)) {
        
$profile_handler xoops_getmodulehandler('profile''profile');
        
$profile $profile_handler->get($xoopsUser->getVar('uid'));
        
$myField $profile->getVar('myfield');
      }
      
$xoopsTpl->assign('myField'$myField);
<{/
php}>
<{
$myField}>

30
pablo103
Re: data from custom user fields on forums
  • 2009/5/14 22:37

  • pablo103

  • Not too shy to talk

  • Posts: 181

  • Since: 2008/2/3 1


Where shoud I put this code in order to diplay custom profile fields in newbb (CBB 3.08) module?

Login

Who's Online

285 user(s) are online (243 user(s) are browsing Support Forums)


Members: 0


Guests: 285


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits