Skip to Content Skip to Menu

CB Image Field, Setting Default Value

  • crashedfx
  • crashedfx
  • OFFLINE
  • Posts: 6
  • Thanks: 0
  • Karma: 0
13 years 4 months ago #166656 by crashedfx
CB Image Field, Setting Default Value was created by crashedfx
Hi Guys,

I need some help with the added image field in CB.


I wish to set default value for the image field that I've added.

I've taken value of another user from that very same field and i'm trying to add it to new users when they register.

I have 2 fields naturally, because its a image type:

cb_<image_field_name>
cb_<image_field_name>approved


'cb_<image_field_name>' field's value for ALL other users that I've set by hand is the name of the PNG file...

To change field values i use Incubator's CB Triggers and CB Queries plug-ins, and on 'afterUserConfirm' event i run a MySQL query with UPDATE instructions:

UPDATE jos_comprofiler SET cb_<image_field_name> = "cb_<image_field_name>_63_4d3a55462b292.png" WHERE user_id = [user_id];
(I don't set 'cb_<image_field_name>approved' field, 'cause it defaults to '1' without me needing to do it by hand)

Before anybody points out to me that this forum does not do support for Incubator plugins, let me assure you that I've tried to do this by HAND. I've ran MySQL command line client and executed this update query.

*** RESULT ***

When i edit new user's profile, that field's image points out to:
/components/com_comprofiler/plugin/templates/default/images/avatar/tnnophoto_n.png

Instead of DESIRED:
/images/comprofiler/tncb_<image_field_name>_63_4d3a55462b292.png


*** QUESTION ***

What am i doing wrong and how i can achieve desired effect of setting a default image of my choosing to the custom Image field for all new accounts?
(That or point me to a forum post that has this solution, 'cause I've tried doing the search but haven't found this problem's discussion)



THANK YOU SO MUCH IN ADVANCE!

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48435
  • Thanks: 8275
  • Karma: 1443
13 years 4 months ago #166722 by krileon
Replied by krileon on topic Re: CB Image Field, Setting Default Value
Please try the below settings for your query within CB Queries.

Trigger: onAfterUserRegistration
User: Automatic
Access: Everybody
Conditional: Blank
Query:
Code:
UPDATE `#__comprofiler` SET `FIELD_NAME` = 'FILE_NAME' WHERE `id` = [user_id];

Please ensure with the above you replace FIELD_NAME and FILE_NAME as necessary. Once done register a user from FRONTEND (the trigger specified above is for frontend) and confirm if working. Please ensure the query and the plugin it self are both published.


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 or Create an account to join the conversation.

  • crashedfx
  • crashedfx
  • OFFLINE
  • Posts: 6
  • Thanks: 0
  • Karma: 0
13 years 4 months ago #166791 by crashedfx
Replied by crashedfx on topic Re: CB Image Field, Setting Default Value
Dear Krileon,

Thanks for your reply. My bad, i kinda explained my problem badly. I should have specified couple more details...

See the update itself is not an issue. UPDATE actually works. Naturally after the trigger fires on user creation, i did run a query in command line MySQL client to make sure update was done as it supposed to.

SELECT cb_<image_field_name> FROM jos_comprofiler WHERE user_id = <new user's ID>;

And result shows the name of the file: 'blah_blah_blah.png'

I also run the query to take a look at admin account's field's value:

SELECT cb_<image_field_name> FROM jos_comprofiler WHERE user_id = <Admin's User ID>;

And result shows the name of the file: 'blah_blah_blah.png' (So the results are identical)

Only inside my profile in Admin's account that image displays properly. But new created user's field is showing this no-image placeholder when i log into the profile in front-end:

/components/com_comprofiler/plugin/templates/default/images/avatar/tnnophoto_n.png

Do you understand what i mean? So i kinda thought that you cannot set default file name to new records without doing something else too. Like telling CB to do some vital part about setting image type fields by hand that i am not familiar with.

'Cause how can same data in DB (on both accounts) show two different things in front-end profile display? Right?


Thank you for your help!

Cheers.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48435
  • Thanks: 8275
  • Karma: 1443
13 years 4 months ago #166864 by krileon
Replied by krileon on topic Re: CB Image Field, Setting Default Value
Don't understand; so the query is doing nothing for newly registered users on frontend? This would imply the query isn't configured right. You'd need to use the after registration trigger and ensure access is set to Everybody. If no image is in database then the no image image from CB is shown.


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 or Create an account to join the conversation.

  • crashedfx
  • crashedfx
  • OFFLINE
  • Posts: 6
  • Thanks: 0
  • Karma: 0
13 years 3 months ago - 13 years 3 months ago #168483 by crashedfx
Replied by crashedfx on topic Re: CB Image Field, Setting Default Value
Krileon,

Bro sorry, i totally missed your reply to me. For some reason this particular reply notification was never emailed to me... That OR i simply missed that email. I'm sorry!

Anyway, i think i totally confused you :) hehe

So it happens that i did solve this issue and found where the problem was. I was using another user's image field value and was trying to stick that into the same field for new users (on registration).

So let's say i was taking cb_<myimagefield>_63_4d3a55462b292.png value that i took from existing user (into who's image field the image was uploaded manually) and inserting into same field for new users using CB Queries plug-in.

HOW I SOLVED IT:

1. I uploaded file defaultimage.png into /images/comprofiler folder
2. On user confirmation event in CB Queries plug-in I set to run a query to update cb_myimagefield's value

QUERY: UPDATE `#__comprofiler` SET cb_myimagefield = "defaultimage.png" WHERE user_id = [user_id];

So basically all i needed is to upload an image that i wanted to be a default into /images/comprofiler folder and use that name in my UPDATE query.

SEEMS TO WORK (so far...)

Did i explain it OK this time? I have amazing gift of confusing people bro :) Somebody will bash me on the head 'cause of it one day :) heh

*** ADDED ***

Your two cents? Maybe there are easier way to do it?
Last edit: 13 years 3 months ago by crashedfx.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48435
  • Thanks: 8275
  • Karma: 1443
13 years 3 months ago - 13 years 3 months ago #168602 by krileon
Replied by krileon on topic Re: CB Image Field, Setting Default Value
That seams the appropriate method (easier with CB Fields however), but if someone deletes their avatar it will delete your image. It's best to supply your image as a gallery image so they can not delete it off your server. You'd simply place it in the gallery folder then update their database value with gallery/IMAGE. Ensure you've gallery enabled within CB configuration however or it won't display.


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.
Last edit: 13 years 3 months ago by krileon.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum