Eval not working (for me)

billvv

Member
I'm sure it's something simple.....

I have a 'field' plugin element in my table.

Capture3.JPG

I save it, then go to my table (which has a single row). The text does not appear in either the list or form view. Is it correct that by placing this code in an eval box that it should run the PHP code for the element on each row of the table?

I want to add some PHP, but unless I can get this to work I can't move on.

BTW, I've tried replacing 'echo' with 'return' but no luck.
 
- It has to be return
- Default is used ONLY in new records (for setting a default value)
- I think you are looking for the calculation element
 
- It has to be return
- Default is used ONLY in new records (for setting a default value)
- I think you are looking for the calculation element

I see. I knew it was something simple; for my simple mind. Thank you!

I tried the calc plugin and here's my feeble attempt:
PHP:
$id_element = '{oc_awards_small____id}';
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = "SELECT field_value FROM jos_osmembership_field_value WHERE field_id = 31 AND subscriber_id =1";
//$query = "SELECT field_value FROM jos_osmembership_field_value WHERE field_id = 31 AND subscriber_id =" . $db->quote($id_element);
$db->setQuery($query);
$value=$db->loadResult();
return $value;
The first query works, and extracts the value from the foreign table. Of course it will always extract the same value for every table row. The second (commented) query does not work. I've tried it without the brackets and quotes around oc_awards_small____id ,(which is the table name and field name that I assume holds the id value for the current record). I think if I could figure out how to reference the value of a field in the current record I'd have what I need.

Thanks!

EDIT: Had too many underscores in the placeholder. Only works with three underscores. RTFM!
 
We are in need of some funding.
More details.

Thank you.
Back
Top