HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


how to get 'location' from a users profile

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#79219 (In Topic #16145)
Avatar

Community saint

Want to add it in the box with name,avatar,group in posts.

It seems it is a custom field.  And I think I have done this before, pulling custom fields, but I am drawing a blank.

Paul

Paul
Back to the top
 
Posted
Rating:
#79220
Avatar

Community saint

Do you have the ocUserMap add-on installed? I know it adds lat and long, and I think it uses the Google maps API to determine location. Not certain and Chris or temp1024 will be the one's who know for sure.

Bob
Back to the top
 
Posted
Rating:
#79221
Avatar

Community saint

I assume you are referring to one or more of these:

   (Address) Street address
   (Address) City
   (Address) State
   (Address) Post code / Zip code
   (Address) Country

and not lat/long fields.

In any case, to display any given Custom Profile Field, use {$CPF_VALUE,Some Custom Field} in your template and replace Some Custom Field with the field name or ID, as per documentation:
Find the value of a custom profile field (pass in the ID number of a custom profile field, which can be found from the URL of where you to edit it – or pass in the human-readable name of the field; if you pass a name it can also interpret translated/Comcode text fields properly)


Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#79222
Avatar

Community saint

No, I just am going by if they fill out 'Location'  in their profile.   So they can keep it blank if they want.

I remembered how I pulled the custom field info for the gallery thing I did before, so I edited

OCF_TOPIC_POST.tpl

Code

<br /><td class="ocf_topic_post_member_details"><div class="ocf_topic_poster_name">{POSTER}</div><div class="ocf_topic_poster_more">{POST_AVATAR}<div class="ocf_topic_poster_title">{POSTER_TITLE*}</div>{+START,IF_NON_EMPTY,{POSTER_LOCATION}}<div class="ocf_topic_poster_title">Location: {POSTER_LOCATION*}</div>{+END}{+START,IF_NON_EMPTY,{RANK_IMAGES}}<br /><div>{RANK_IMAGES}</div>{+END}</div></td> 


Obviously added the poster_location bit, so if it exists, print it out, otherwise do not.

Then in OCF_POSTS2.php

up near the top:

Code (php)

[semihtml]<br />if (!is_null($primary_group)){if (addon_installed('ocf_member_titles')){$poster_title=$GLOBALS['OCF_DRIVER']->get_member_row_field($row['p_poster'],'m_title');if ($poster_title=='') $poster_title=get_translated_text(ocf_get_group_property($primary_group,'title'),$GLOBALS['FORUM_DB']);} else $poster_title='';$avatar=$GLOBALS['FORUM_DRIVER']->get_member_avatar_url($row['p_poster']);$posters_groups=$GLOBALS['FORUM_DRIVER']->get_members_groups($row['p_poster'],true);                $poster_location=$GLOBALS['SITE_DB']->query('SELECT field_5 FROM '.get_table_prefix().'f_member_custom_fields WHERE mf_member_id='.$row['p_poster']);} else{$poster_title='';$avatar='';$posters_groups=array();                $poster_location='';} [/semihtml]


then further down sending it to the template:

Code (php)

[html]<br />'POSTER'=>$poster,'POSTER_DETAILS'=>$poster_details,'POST_AVATAR'=>$post_avatar,'RANK_IMAGES'=>$rank_images,'BUTTONS'=>'','SIGNATURE'=>'','UNVALIDATED'=>'','DESCRIPTION'=>'','PREVIEWING'=>true,'USER_ONLINE'=>'','START_PT'=>'',                                'POSTER_LOCATION'=>$poster_location, [/html]


no errors so to speak, but on the top line when reading the forums, I get:

"A parameter, POSTER_LOCATION, is referenced in the template, OCF_TOPIC_POST, but not passed"


Huh??


Last edit: by Arbo

Paul
Back to the top
 
Posted
Rating:
#79223
Avatar

Community saint

I see what you are saying about that, but that shows the current users information, not that of the person that made the post.

Paul
Back to the top
 
Posted
Rating:
#79224
Avatar

Community saint

man, even my cut and past above didn't come out right.  arch

Paul
Back to the top
 
Posted
Rating:
#79225
Avatar

Community saint

ok, in OCF_TOPIC_POST.tpl  I added in {PL*}  as the location.

In ocf_posts2.php   I even went directly to the part that passes data to the template and added:

'PL'=>'unknown',

and it still tells me 'PL' is referenced in the template but not used.   and of course it doesn't show up on the screen.

Paul
Back to the top
 
Posted
Rating:
#79226
Avatar

Community saint

I see what you are doing now!

Arbo said

man, even my cut and past above didn't come out right.  arch
No kidding! I had to unescape them before they were legible (even without the formatting).

I can't see any obvious problems. You added 'POSTER_LOCATION'=>$poster_location to the right array as far as I can tell, and there is only one exit point for OCF_TOPIC_POST.

Have you tried placing 'PL'=>'unknown',  in an earlier location, say after 'TOPIC_FIRST_POSTER'=>'',. That would tell you if you have any funny characters that may have snuck in somewhere when you first added the code.


 


Last edit: by temp1024

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#79227
Avatar

Assuming it is in CPF ID#4…

{$CPF_VALUE,4}

in template.

Job done ;).


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#79229
Avatar

Community saint

Chris Graham said

Assuming it is in CPF ID#4…

{$CPF_VALUE,4}

in template.

Job done ;).
I thought Arbo wanted to do it the $CPF_VALUE way also at first (hence my first post), but apparently that's not what he's after.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#79231
Avatar

Community saint

temp,  yeah, I moved it around in terms of where in the array it was.  Didn't seem to make a difference.

Chris, yeah, I am looking to show the 'location'  of the person that posted the message, not the person online.

Paul
Back to the top
 
Posted
Rating:
#79241
Avatar

Community saint

figured it out, the template was being called by forum/modules_custom/topicview.php not the other one.  

All a bit confusing.

Paul
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: