[SOLVED] Print contents of single CB profile tab

2 years 11 months ago - 2 years 11 months ago #324206 by boyjahq
We have a CB profile tab of type Custom HTML. Included in the HTML are several CB and CBSubs substitutions (First Name, Last Name, Username, Subscription Start Date, Subscription Expiry Date, etc.). Access to this tab is limited to connected users (and the profile user). We are trying to find a way to allow viewing users (connected users) to print the contents of just that tab.

We have seen a few posts that seem to want something similar, but we are unable to apply the hints in those posts to achieve our goal.

We tried creating a content article with the same HTML/CB substitutions and then putting that into the tab, hoping that the print button associated with an article would do what we need. And that works IF the user clicking the print button is the user that the profile is associated with. However, if the viewing user (connected user) clicks the print, button, then, as would be expected, the substitutions in the new print window come from the viewing user and not the displayed user. And, as you have explained in other posts, changing the substitutions to include user="#displayed" does not work as there is no "displayed" user in a new window that is then "outside" of the CB profile.

We also saw reference to using CSS based on
@media print {
    /* any CSS here will only apply when printing the page */
}

but we don't understand how to combine this approach with adding a print button or link to the HTML inside the Custom HTML tab contents.

Is there some way to achieve what we are trying to do?

Please Log in to join the conversation.

2 years 11 months ago #324211 by krileon
Replied by krileon on topic Print contents of single CB profile tab
Using @media print won't have a print button. That works directly with the browsers print capabilities. What it does is apply CSS rules only to the print view of a page. So you can use that to hide whatever you like from the page or restyle things specifically for printing.

Is there some way to achieve what we are trying to do?

If you want a button for them to click that gives a more print friendly view of data then problem CB Auto Actions is your best option. Example as follows.

Global
Triggers: None
Type: Code
User: Automatic
Access: Everybody
Conditions
Field: Users
User: Viewing User
Operator: Is
Value: [user_id]
OR
Field: Connections
User: Viewing User
Operator: Is Connected
OR
Field: Moderators
User: Viewing User
Operator: Is
Action
Method: HTML
Code:
Username: [username]
Output
Display: Return

For the code part you can put whatever substitutions you like. Now within a Custom HTML field lets add the button to go to this auto action. Example as follows.

<a href="index.php?option=com_comprofiler&view=pluginclass&plugin=cbautoactions&action=action&actions=ACTION_ID_HERE&users=[user_id]">Print Details</a>

Be sure to replace ACTION_ID_HERE with the ID of the auto action created above. If you want the URL to also be a print window so it only has the contents of the Code output into a new window you can add the following to the URL.

&tmpl=component&print=1&layout=default

Next add target="_blank" so it opens in a new window. Example as follows.

<a href="index.php?option=com_comprofiler&view=pluginclass&plugin=cbautoactions&action=action&actions=ACTION_ID_HERE&users=[user_id]&tmpl=component&print=1&layout=default" target="_blank">Print Details</a>

If you need to style this page then go back to the Action tab and add another code row. Now set that row as follows.

Method: CSS (Inline)
Code: YOUR_CSS_HERE


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: boyjahq

Please Log in to join the conversation.

2 years 11 months ago - 2 years 11 months ago #324224 by boyjahq
Replied by boyjahq on topic Print contents of single CB profile tab
Thanks to your excellent guidance, I have gotten it to work...mostly. But I cannot get the CBSubs substitutions to work. In the form I call on 2:

[cbsubs:subscriptions user="#displayed" plan="2" output="signup_date"/]
[cbsubs:subscriptions user="#displayed" plan="2" output="expiry_date"/]

But the result is blank. Is there a different syntax I need to use in order to show this information from displayed user data? Using the exact same HTML in the Custom HTML field that displays in the user's profile tab, these substitutions work.

Please Log in to join the conversation.

2 years 11 months ago #324238 by krileon
Replied by krileon on topic Print contents of single CB profile tab
Remove user="#displayed" as that won't work there.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: boyjahq

Please Log in to join the conversation.

2 years 11 months ago #324255 by boyjahq
Replied by boyjahq on topic Print contents of single CB profile tab
I removed user="#displayed" so that now the substitutions are:

[cbsubs:subscriptions plan="2" output="signup_date"/]
[cbsubs:subscriptions plan="2" output="expiry_date"/]

But it still remains blank.

If I replace user="#displayed" with user="55285" (hardcoding the actual user id of the user being viewed), then the dates show up.

So I tried replacing user="#displayed" with user="[user_id]"

[cbsubs:subscriptions user="[user_id]" plan="2" output="signup_date"/]
[cbsubs:subscriptions user="[user_id]" plan="2" output="expiry_date"/]

Which did in fact grab the correct user id, but I guess the inner brackets from [user_id] broke the display of it somehow, as it now shows like this:

From [cbsubs:subscriptions user="55285" plan="2" output="signup_date"/]

Please Log in to join the conversation.

2 years 11 months ago #324260 by krileon
Replied by krileon on topic Print contents of single CB profile tab
Your issue is probably due to the CBSubs substitutions being a Joomla content plugin. This means the target user for the substitutions is typically always the viewing user. Try using the following.

[cbsubs:subscriptions user="[action_user]" plan="2" output="signup_date"/]
[cbsubs:subscriptions user="[action_user]" plan="2" output="expiry_date"/]

The [action_user] substitution is a special replacer that replaces the contents with the id of the user that triggered the action based off the User parameter. It replaces inline before substitutions are parsed so that should allow it to output as you're expecting. Normally you'd just be able to use user="[user_id]" there, but the CBSubs substitutions haven't been updated to support nesting yet.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: boyjahq

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.783 seconds

Facebook Twitter LinkedIn