[SOLVED] Multiple queryfield templates?

4 years 4 months ago - 4 years 4 months ago #315365 by kdave321
[SOLVED] Multiple queryfield templates? was created by kdave321
I'm enabling my own Points & Stars system for CB users. I have the display of a custom point history table working great with a custom template in components/com_comprofiler/plugin/user/plug_cbqueryfield/templates.

I then set up an equivalent Stars table with it's own queryfield and its own custom template.

When I try to display both of these in the same Joomla article ( [cb_point_history] and [cb_stars_history] ) it is apparently using only the first of these to be referenced. ( I tried switching points to stars and it just loads the first one )

If that's not clear, in the article I put
[cb_point_history]
...
[cb_stars_history]

and it displays
[cb_point_history]
...
[cb_point_history]

where the last there is only an empty result with point_history template

Please Log in to join the conversation.

4 years 4 months ago #315375 by krileon
Replied by krileon on topic Multiple queryfield templates?
That shouldn't be possible unless both query fields use the same exact SQL as it caches by SQL to avoid duplicate calls. Are both fields using the same SQL? Please also keep in mind [FIELD_NAME] is a raw substitution and you'll need to use [cb:userfield field="FIELD_NAME" /] if you want formatted output.


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.

Please Log in to join the conversation.

4 years 4 months ago #315381 by kdave321
Replied by kdave321 on topic Multiple queryfield templates?
No, different SQL. I think I had to use raw to get the queryfield display template to work. I tried the "[cb:userfield..." just now and it displays nothing.

The first query field is
SELECT reward_date, points, reward_for FROM `#__user_points_history` WHERE `user_id` = '[user_id]';
and DISPLAY output is template pointing to my file under "table" ( a nicely formatted HTML table )

2nd query field is
SELECT star_date, stars, star_for FROM `#__user_stars_history` WHERE `user_id` = '[user_id]';
and DISPLAY output is template pointing to my file under "table2"

The nicely formatted HTML table has a heading with user-friendly column headings which are different between table and table2. That's how I can tell it is using the wrong one.

Please Log in to join the conversation.

4 years 4 months ago #315382 by krileon
Replied by krileon on topic Multiple queryfield templates?
If you're using [FIELD_NAME] you're not going to get the formatted results. You have to use [cb:userfield field="FIELD_NAME" /] and if that's not outputting anything then the field is either not accessible to the viewing user or the field isn't set to display on profile, which is required for formatted output but if you don't want it actually visible on profile you can move it to a tab that's in a not shown on profile position.


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.

Please Log in to join the conversation.

4 years 4 months ago #315383 by kdave321
Replied by kdave321 on topic Multiple queryfield templates?
Well I was getting nicely formatted results with just [cb_point_history] but I was not displaying the field on the profile.

So I tried enabling display on profile and indeed, the "[cb:userfield..." syntax works.

But when I do that, I get the same re-used template problem ( uses only the first template loaded ).

Curiously, if I have only the 2nd field enabled to display on the profile, its template seems to take precedence.

Please Log in to join the conversation.

4 years 4 months ago #315384 by kdave321
Replied by kdave321 on topic Multiple queryfield templates?
Wild guess what is happening -

All I did was copy and modify /com_comprofiler/plugin/user/plug_cbqueryfield/templates/default/display.php
to table/display.php, and the same for table2/display.php.

I suppose you are referring to the class HTML_queryfieldDisplay to render the page, so the class is not unique.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.230 seconds

Facebook Twitter LinkedIn