Using Database Fields in Comcode Page

Post

Posted
Rating:
#6415 (In Topic #1629)
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’

Adding from the cms_f_member_custom_fields table

I am trying my hand on my first Comcode Page.  I want to pull some fields from the cms_f_member_custom_fields table. 

The tempcode {$CPF_VALUE,Some Custom Field} works on the f_members table.  I also want to pull from the cms_f_member_custom_fields table.  The custom profile fields are in a different table than what the $CPF_VALUE tempcode works on.

I know how to program a php page to do this, not inside Composr.  What is the proper way to do this with a Comcode Page?

Thanks so much!
 
Online now: No Back to the top

Post

Posted
Rating:
#6418
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
f_member_custom_fields holds CPF values, and CPF_VALUE was originally designed to use them.
It being able to get f_members fields is a bonus feature for it.
Try passing the field ID number, or the field name.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

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 Composr whenever you see the opportunity or support me on Patreon.
  • 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 Composr 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.
Online now: No Back to the top

Post

Posted
Rating:
#6422
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
Thanks Chris!

I tried to use the CPF_VALUE tempcode, but it does not pull the f_member_custom_fields values (unless I am doing this incorrectly).  I want to let members print out a stylized page, based upon their database custom field inputs.  I thought Composr's WYSIWYG editor was a great option, because I can add the Comcode page to their panel, use the custom fields, and the Comcode pages have a link at the bottom of the page for printing. 

I haven't been able to figure out how to use a Comcode page to do what I am trying to do.  Is this possible with a Comcode page?  

Am I better off creating a php page without the WYSIWYG editor?   Can the page still be linked in the member's Menu dropdowns?

Thanks again!
Online now: No Back to the top

Post

Posted
Rating:
#6424
Avatar
Site staff
Adam is in the usergroup ‘Super-moderators’
Perhaps a mini-block would work? You can then include these on your Comcode page like any other block.
Online now: No Back to the top

Post

Posted
Rating:
#6426
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
Thank you Adam, for trying to help me!
Online now: No Back to the top

Post

Posted
Rating:
#6432
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
CPF_VALUE is working fine for me. If I do this on my test site, after setting the default First name field to test on my admin account (account #2)…

Code

{$CPF_VALUE,First name}
{$CPF_VALUE,firstname}
{$CPF_VALUE,42}
{$CPF_VALUE,First name,2}
{$CPF_VALUE,firstname,2}
{$CPF_VALUE,42,2}

I get…

Code

test
test
test
test
test
test

If you're not able to get it working, please provide full details on what is not working for you (name of the CPF, how it is configured, the Tempcode you are using), and we will try and help.

Here I'm using 3 different syntaxes the CPF_VALUE symbol accepts for looking up CPFs (written name, internal codename, field ID), and testing both for the current user and with an explicit member ID.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

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 Composr whenever you see the opportunity or support me on Patreon.
  • 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 Composr 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.
Online now: No Back to the top

Post

Posted
Rating:
#6479
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
Sorry, I've been away.  Thanks for responding Chris.

I found that if I refer to the name of the field in the cms_f_member_custom_field database (ex: field_59) it does not display the field.  If I refer to the field by the number (ex: 59), it does display.

It looks like a comcode page won't work for me as such, as I have some fields that are "a paragraph of text (no comcode support)".  The parapgraph contents of those fields therefore do not display.

I could create the php page the way I want it and embed it into a comcode page, possibly using an iframe.  Does this sound reasonable?  Is it good practice to only use all comcode pages, even embedded ones?

Thanks again!

 
Online now: No Back to the top

Post

Posted
Rating:
#6489
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Try {$CPF_VALUE,59,{$MEMBER},1}


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

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 Composr whenever you see the opportunity or support me on Patreon.
  • 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 Composr 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.
Online now: No Back to the top

Post

Posted
Rating:
#6495
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
Thanks so much for responding, Chris.  I apologize for not being clear.  

{$CPF_VALUE,59} works.  Thanks for your help.

A different field (field_47) is "a paragraph of text (no comcode support)".  I am unable to display the contents of this field.
 
Online now: No Back to the top

Post

Posted
Rating:
#6496
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Ok, try {$CPF_VALUE,47,{$MEMBER},1}

The '1' should make it parse the Comcode.

Last edit: by Chris Graham



Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

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 Composr whenever you see the opportunity or support me on Patreon.
  • 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 Composr 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.
Online now: No Back to the top

Post

Posted
Rating:
#6497
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
Thanks for trying to help me, Chris!

As for field_47, which is "a paragraph of text (no comcode support)"…..

{$CPF_VALUE,47,{$MEMBER},1} did not display anything.
 
Online now: No Back to the top

Post

Posted
Rating:
#6511
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Odd, it should work, and does in my tests.

I should clarify, the final '1' isn't actually for Comcode specifically, it determines to show the 'rendered' value of a field. That can mean many things based on field types. For Comcode fields, that means rendered Comcode.

But I see now you said "a paragraph of text (no comcode support)" (I misread).

"No Comcode support" is not saying it won't work on a Comcode page, it's saying the contents of the field can't be Comcode (so no tags etc).

It really should just work in a very straight-forward way, with or without the final 1.

Make sure the user you are testing really does have something in the actual field ID you are referencing.

You should also have an asterisk if using in a page without the final ",1".
{$CPF_VALUE*,47,{$MEMBER}}
I don't want to get into a long discussion on how HTML escaping works here, but it's important to convert non-HTML to HTML when putting it into a page for security reasons, and without the final ",1" the symbol is not going to be returning HTML.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

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 Composr whenever you see the opportunity or support me on Patreon.
  • 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 Composr 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.
Online now: No Back to the top

Post

Posted
Rating:
#6517
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
Thanks Chris!

I couldn't get things to work the way I wanted so I decided to create a php page, in a folder not inside Composr.  I then used an iframe to insert that page into a Comcode page.  I did get an error message at one point:

Uncaught SecurityError: Blocked a frame with origin XXXX://XXXXXX.XXX from accessing a cross-origin frame.
XXXX://XXXXXX.XXX/XXXXXX/cms/index.php?page=cms-comcode-pages

I need users to be able to print out this page.  What is the best way to add this page to Composr?

Thanks again!
Online now: No Back to the top

Post

Posted
Rating:
#6518
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Well, I don't know if that error message corresponds to your frame, or something else. I see Facebook producing this kind of stuff a lot. I doubt you are writing cross-frame JavaScript code in what you're doing. And I doubt you have embedded your iframe from a different origin.

I would not recommend messing around with frames anyway though. They're very clunky in a number of ways. It's hard to get them to size correctly. They load separately to the main page, causing for example flicker, or at least slow loading. Unless styled very carefully they look disjunct from the rest of the page with their own border etc.

A mini-block is a lot more straight-forward. You just create a sources_custom/miniblocks/whatever.php file with your PHP code then include it into a page with [block]whatever[/block].


Become a fan of Composr on Facebook or add me as a friend. Add me on on Twitter. Follow me on Minds (where I am most active). Support me on Patreon

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 Composr whenever you see the opportunity or support me on Patreon.
  • 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 Composr 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.
Online now: No Back to the top

Post

Posted
Rating:
#6521
Avatar
Standard member
starfish is in the usergroup ‘Fan in action’
Thank you for everything, Chris!

I created a miniblock as you suggested, using the tutorial on Composr entitled Hardcore Blocks.  I was able to use an iframe in a block.  The Comcode page makes it very easy for the user to print the information, and automatically adds the link to the user's menu.

Hope this helps someone else.

Thank you again!!!
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Users online:

gabriel58, ManojSree, Salman, mytracker, deepu_ms, amit.nigam

Forum statistics:
  • 1,252 topics, 5,782 posts, 6,945 members
  • Our newest member is Darren
Birthdays:
Back to Top