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.


$CPF_VALUE,Some Custom Field

Login / Search

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

Fan in action

The CPF_VALUE print challenge

I've been trying to print a custom member field.
{$CPF_VALUE,Some Custom Field} doesn't actually work as I expected.
{$CPF_VALUE,5,{$USER}} prints things, but what those printed things are doesn't seem to correlate to the member fields.
For instance, {$CPF_VALUE,LOCATION,{$USER}} doesn't print anything, even when the member's LOCATION field is filled in and {$USER} is echoing a valid user id with a valid LOCATION field.
I'm not sure what I'm doing wrong.
I'm comfortable with PHP and just accessing the database for the information.
The database table 
ocp_f_member_custom_fields might be where the custom profile fields are located.
The column mf_member_id inside table ocp_f_member_custom_fields is the member ID, I expect.
The remainder of the columns are field_1 through field_x.
How do I translate field_x to their real-names?
For instance, if I create a custom field called "Favorite Sport," how do I know which column in ocp_f_member_custom_fields it is?
When I create a custom field, it does allow me to set where it is in the series of custom fields. But this doesn't seem to associate with ocp_f_member_custom_fields. 
Ultimately what I want to do is print a picture from a custom member field that I created. The custom member field is a list of about 100 pictures and the member selects one of the 100 pictures as a radio button option.
The best case would be to use {$CPF_VALUE,FAVORITE SPORT,{$USER}}  but this doesn't seem to work.
What am I doing wrong?
Back to the top
 
Posted
Rating:
#105759
Avatar

Why capitalise the titles, like "FAVORITE SPORT"? Just write it as labelled, "Favorite Sport". That should work :).


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:
#105766
Avatar

Fan in action

okay I got it working now. I didn't enter it as pure source and I think that caused ocPortal to interpret it as a string of symbols.
There is one thing that I can't figure out, still, and thats this:

{+START,IF_EMPTY,{$CPF_VALUE,About me,{$USER}}}
<p><a href="http://example.com/site/index.php?page=members&type=view&id={USERNAME}">add your About Me information</a></p>
{+END}
This test for the content of the About Me field seems to crash the page on the spot.
{$CPF_VALUE,About me,{$USER}}
I
is that because this is a data type that shouldn't be compared to NULL or, how would I test if this is empty?
Back to the top
 
Posted
Rating:
#105769
Avatar

seems to crash the page on the spot

It renders okay to me. What do you mean exactly by "crash"? The web browser crashes? You get a white page? The page just spends forever 'loading'? The page is malformed/corrupted? When viewing the page, or when editing the page?

Regardless, {USERNAME} is not going to work, as there are no parameters passed into Comcode. You probably meant {$USERNAME
}
but actually you can just do http://example.com/site/index.php?page=members&type=view and it defaults.


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:
#105783
Avatar

Fan in action

Hey Chris thanks so much for replying. It's not common to get advice about software from the author, so I appreciate it a lot. my site is coming along pretty well. A lot of custom blocks. What I'm doing here is modifying the original BLOCK_SIDE_PERSONAL_STATS.tpl file so that if the user did not fill out some part of his/her profile, it will tell them. Kind of like a "Things to do" block. Basically I'm just checking for null values on the custom or regular member fields and printing a linked string to the user if they need to fill that part of the profile out.

Here's the code that I just ran a minute ago:

Code


<section class="box box___block_side_personal_stats"><div class="box_inner">
<h3>{USERNAME*}</h3>
{+START,IF_NON_EMPTY,{$PHOTO,{$USER}}}
<img style="height:100%;" src="{$PHOTO,{$USER}}" />
{+END}
{+START,IF_EMPTY,{$PHOTO,{$USER}}}
<img style="width:100%;" src="http://example.com/themes/Muchness/images/background_image.png" />
<p><a href="http://example.com/site/index.php?page=members&type=view&id={USERNAME}">add a profile picture</p></a>
{+END}
 
{+START,IF_NON_EMPTY,{$CPF_VALUE,Spiritual path,{$USER}}}
<hr>
<img src="http://example.com/themes/default/images/{$CPF_VALUE,Spiritual path,{$USER}}.png" width="100%" />
<hr>
{+END}
 
{+START,IF_EMPTY,{$CPF_VALUE,Spiritual path,{$USER}}}
<p><a href="http://example.com/site/index.php?page=members&type=view&id={USERNAME}">add a spiritual path</a></p>
{+END}
 
 
{$CPF_VALUE,About me,{$USER}}
 
 
{+START,IF_NON_EMPTY,{DETAILS}}
<ul class="compact_list">
{DETAILS}
</ul>
{+END}
 
{+START,IF_NON_EMPTY,{LINKS}}
<ul class="associated_links_block_group">
{LINKS}
</ul>
{+END}
</div></section>



Without the line {$CPF_VALUE,About me,{$USER}} the code runs fine.

If I put the string {$CPF_VALUE,About me,{$USER}} in the code (presuming it will echo the About me field in the profile, it crashes at that point. The source code that the browser received is this:

Code


   
   
  <div class="boxless_space">
   
  <div class="boxless_space"><section class="box box___block_side_personal_stats"><div class="box_inner">
  <h3>admin</h3>
   
  <img style="height:100%;" src="http://example.com/uploads/ocf_photos_thumbs/Link%2520to%252055947497.jpg" />
   
   
   
   
  <hr>
  <img src="http://example.com/themes/default/images/menu_items/paths_navigation/icon_taoist.png" width="100%" />
  <hr>
   
   
   
   
   
   



There is no other html received before or after that html in the browser. At the point that the browser stops printing, is where the line {$CPF_VALUE,About me,{$USER}} exists. That line of code crashes the browser. What the browser displays is the username at the top, and the users pic and then below that, the users "spiritual path" pic. 
If I change the code to say something like "About meee" or anything Other than "Aboud me" (a non-existing member field) it will not crash the browser and just doesn't print anything there. Oddly enough, there is no code that the browser receives before that block and no code received at the point of {$CPF_VALUE,About me,{$USER}}

I dunno why it crashes, except that the if-then in the comcode might not be able to interpret the data type in the About me field. 
Back to the top
 
Posted
Rating:
#105791
Avatar

Ah, okay sounds like a bug. What CPF field type is "About me"?


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:
#105792
Avatar

Oh it's a bundled CPF I think, okay…


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
 
Important!
Posted
Rating:
#105793
Avatar

Automated fix message

Chris Graham said

Oh it's a bundled CPF I think, okay…
This issue has been filed on the tracker as issue #1743, with a fix.


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.
Important!
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: