The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Conditionals on Serialized fields...
Has anyone had issues with conditionals on serialized fields
The condition works for one value... but not another... i tried deleting the record and resubmitting the value... and still no luck... I don't think its an issue with spaces cuz the char count is always the same i:7;s:8:"xxxxxxxx" but there other values that work... and i even have the display on to print/show exactly what the variables are being compared to within the conditional. |
#2
|
|||
|
|||
What is your expression you are using? It is probably easier to do conditionals on un-serialized arrays rather than serialized strings.
|
#3
|
|||
|
|||
I actually do that...
I use the unserialize function on the customfield first and then i perform the following condition against the array value: <if condition="$customfields[7]==$name"> However... the condition doesn't work all the time... If it works on one variable value... it doesn't for another... eg) $name = Sam works but $name = Kevin doesn't work... even though there is a value for "Kevin" the customfield array and the value being passed is "Kevin"... i checked for spacing, different lengths... I can PM anyone specific examples if interested in the exact context |
#4
|
||||
|
||||
How are you defining your comparison variables, are you sure they exist where you are using them?
|
#5
|
|||
|
|||
Yes... i have both the unserialized and comparison value being displayed... on the page as output as i debug... and they both look fine...
the comparison value is actually coming in as a request from another link and it looks like this filename.php?show=1&name=Kevin i don't think i have to trim the value cuz i am %99 certain that there are no trailing spaces in the records with the serialized value because i show both variables and i actually had both variables displayed with no space in between... the other funny thing is that... if the serialized value is two words... it still works... the filter shows all the records that match the two words |
#6
|
|||
|
|||
Forget about the serialized variables. Serializing is done to store an object (often an aray) as a single value. You do not perform operations on a serialized field.
You restore the original object (an array in your case) using unserialize() and perform your operations on the restored object. To troubleshoot your problem please provide a var_dump of the (unserialized) array. |
#7
|
|||
|
|||
No offense Marco but I don't think you read the whole thread... I am using unserialize() and then performing the operation with the conditional statement... i mention serialized cuz maybe there is a problem when i use unserialize.
I also do a var_dump on $customfields[7] and it shows the value that want... again ... it works for one value and not the next... |
#8
|
|||
|
|||
Run this PHP code:
PHP Code:
|
#9
|
|||
|
|||
Ahh... that var_dump satement is a good debugger... i ended up being still more puzzled tho... not sure where else to check... cuz where both cases are true... only one case displays properly.... i skipped through a few values with "...."
array(11) { [1]=> string(1) "E" ......... [7]=> string(5) "Kevin" ..... [11]=> string(0) "" } string(5) "Kevin" bool(true) array(11) { [1]=> string(1) "F" ..........[7]=> string(3) "Sam" ....... [11]=> string(0) "" } string(3) "Sam" bool(true) Hmm... i will check my other templates see if i am losing something somewhere... unless you guys see something obvious |
#10
|
|||
|
|||
Post your code, this might lead to a much faster solution.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|