Using Database Fields in Comcode Page


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!


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 Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- 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.


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!






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 Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- 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.


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!


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- 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.


{$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.


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 Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- 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.


As for field_47, which is "a paragraph of text (no comcode support)"…..
{$CPF_VALUE,47,{$MEMBER},1} did not display anything.


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 Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- 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.


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!


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 Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- 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.


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!!!