• REGISTRATION REQUIREMENTS:

    Your username here MUST MATCH your XenForo username (connected to your XF license).

    Once you have registered here, then you need to start a conversation at xenforo.com w/Bob and provide the following:
    1. Your XenForo License Validation Token
    2. The Domain Name associated with the License
    NOTE: Your account will be validated once ALL requirements are verified/met. Thank you for your patience.

Populating custom field values

petrolskin

Member
AMS Premium
Showcase
Hey Bob,

Im writing some customisation to automate the population of a custom field values and was wondering what the best approach would be for this?

I notice there is both regular expression and PHP callback options. Alternatively I could even write a bash script and use native SQL to do this on a regular basis.

Is there any documentation around this to explain how the PHP and regex options work?
 
To be honest, I've not once used those options. They are options that Mike and Kier added to both Custom User Fields and Custom Fields for the Resource Manager, so I've just included them with Showcase. Im sure there are some threads about usage on XF.com.

You can also look at the code itself (which is what I do when trying to figure things out). I've just never had the need (I usually just write something custom anyway).
 
To be honest, I've not once used those options. They are options that Mike and Kier added to both Custom User Fields and Custom Fields for the Resource Manager, so I've just included them with Showcase. Im sure there are some threads about usage on XF.com.

You can also look at the code itself (which is what I do when trying to figure things out). I've just never had the need (I usually just write something custom anyway).
I just wondered if there was a recommended approach or tutorial to bulk inject updates to custom fields? I could even write something in bash and use native SQL commands to update the custom field values, do you see any issues with that approach Bob?
 
The BEST thing to do is reverse engineer the item create&save and edit&save processing (its not something that I can just take 5 minutes to write up some documentation on). If you are coding something, you should have no problem reverse engineering the process. One thing to note, fields are not just stored in one location, they are also cached in each item record as well.

This is a fairly complex process (as you will see when you dig into the code).
 
If I could get this data and insert it directly into the relevant database field (externally to XF). What type of issues could this have with the mod?
 
Thats the thing, its not a simple insert data into a single field type thing. Custom Fields need to be inserted programatically as its involves writing data to multiple fields in multiple tables in different steps. You will run into all sorts of issues if you don't do it the correct way. Custom Fields are not a single field in a single record.
 
OK thanks Bob. I was going to create all the fields using the mod and was then hoping to automate population of these. I presumed it was a static field (once created) in the db schema.
 
Ya, I understand what you are wanting to do, but its a little more complex than that. It IS doable, its just that its not a simple insert, it HAS to be done programatically because of the way each field is stored, plus the processing of the field itself during preSave and postSave processing in the DataWriter (for each field). There are also sub routines that update field cache for the item that the field data is associated with.
 
Ya, I understand what you are wanting to do, but its a little more complex than that. It IS doable, its just that its not a simple insert, it HAS to be done programatically because of the way each field is stored, plus the processing of the field itself during preSave and postSave processing in the DataWriter (for each field). There are also sub routines that update field cache for the item that the field data is associated with.
Thanks mate, I dont suppose there is a manual way of invoking the subroutines and flushing field cache?
 
Just an update I have written something to pull in this data and also write the values directly into the custom fields for that item. Thats working a treat and querying the DB shows the new value.

Within the forum sidebar it still shows the old value which is what you mentioned Bob :)

I've rebuilt all sorts of caches but the original value is still there. Im so close if I can find something that can be run from the command line to automate in a cron job to force a sync I'll be clicking my heels. :D
 
You should probably try editing the item to see if the values were stored properly and then save the item again (which will force a cache rebuild). Also, if you are using any caching mechanizems, make sure those are also cleared while you are testing.
 
This is driving me mad haha. I do use a cache manager Bob but even after clearing this and even restarting apache, the current DB value is not being picked up in the mod.

I dont mind using a bit of brute force to kick the shit out of something to get these DB values showing in the mod. Like I said all the backend scripting is done and the values being populated. I just need the mod to pick them up.

Any more ideas? If you need access to my test site drop me a PM.
 
Sounds to me like you are not using the Item DataWriter to add the custom field data. You can not simply write to the 'xf_nflj_showcase_custom_field_value' table. That is NOT how the entire system works.

Show me your script where you are using the Item DW so that custom field cache is properly being stored in the item record (table: xf_nflj_showcase_item field:custom_item_fields).
 
Sounds to me like you are not using the Item DataWriter to add the custom field data. You can not simply write to the 'xf_nflj_showcase_custom_field_value' table. That is NOT how the entire system works.

Show me your script where you are using the Item DW so that custom field cache is properly being stored in the item record (table: xf_nflj_showcase_item field:custom_item_fields).
Correct Bob I am not using the Datawriter, its all external to XF and inserting into the DB field. I was hoping to use some brute force to make the mod refresh directly out of the database.

Can I call this externally on the server to make a call to the php script?
 
Correct Bob I am not using the Datawriter, its all external to XF and inserting into the DB field. I was hoping to use some brute force to make the mod refresh directly out of the database.

Can I call this externally on the server to make a call to the php script?

Replied to your inbox. And just for anyone else reading this, this is not something that can be accomplishing by envoking a method. It requires custom development OR using the DataWriter as intended.
 
Back
Top