Hi Sebloders
Question
How would you call a single value stored by FieldX, using either $cck, $fields and $config?
Answer
"$cck->get('my_fieldx')->value[0]->value" // $cck used in template file ie index.php
"$fields[ 'my_fieldx' ]->value[0]->value; // $fields used in fields ie beforeRender Field
"$config['storages'][$table][$name] = $result; // See
Config Explained for a glimpse of usage
The
answer was courtesy of
posokhoff who is now officially 'Today's Living Legend"!!
Example of Usage
If am viewing an Article with the Content View, using seb_one template, I can find the data available by placing in the seb_one template index.php file the following
print_r() code:
<?php print_r($cck) and die; ?>
(you might be able to use the extension J!Dump, but I can not figure out how to get $cck data from it yet):
If I tidy up the code and search for the
fieldx data, I can see the following
[my_fieldx_name] => stdClass Object (
[id] => 5023 [title] => My FieldX
[name] => my_fieldx_name // etc... ...
[value] => Array ( // value of fieldx field is an Array
[0] => stdClass Object ( // first in Array
[id] => 5022 // I can call this
[title] => Cool Things // or this
[storage_table] => #__cck_store_form_my_content_type_table // or this etc...
...
[value] => My Funky Value
[html] => My Funky Value
I can access required
fieldx data like this:
$cck->get('my_fieldx_name')->value[0]->value
$cck->get('my_fieldx_name')->value[0]->html
$cck->get('my_fieldx_name')->value[0]->storage_table etc...
Syntax Note
This syntax:
$cck->get('my_field')->value
$cck->get('my_field')->storage_table
$cck->get('my_field')->html
can be exchanged with:
$cck->getValue('my_field')
$cck->getHtml('my_field')
$cck->getStorage_table('my_field')
However:
$cck->get('my_fieldx_name')->value[0]->value
$cck->get('my_fieldx_name')->value[0]->html
$cck->get('my_fieldx_name')->value[0]->storage_table etc...
can
not become:
$cck->getValue('my_fieldx_name')->value[0]
$cck->getHtml('my_fieldx_name')->value[0]
$cck->getStorage_table('my_fieldx_name')->value[0] etc...
My
original question is has been removed as I now have the answer, funky!