Advertisement:

Author Topic: [SOLVED] Show custom field data on admin area manage listing table  (Read 1262 times)

praneeth219

  • Newbie
  • *
  • Posts: 7
Hi,

I have a requirement to display the custom field data on admin - manage listing table. I have created a new column and mapped the new data base table column in ItemsDataTable.php. But it doesn't display the data.

Custom fields saved data in a new table. Is it require to define this table somewhere?

Regards,
Praneeth
« Last Edit: July 29, 2015, 05:40:42 pm by praneeth219 »

teseo

  • Hero Member
  • *****
  • Posts: 6168
Re: Show custom field data on admin area manage listing table
« Reply #1 on: July 29, 2015, 02:14:41 pm »
Hi,

Quote
I have created a new column and mapped the new data base table column in ItemsDataTable.php

You don't need to modify Osclass core. I will give you the base procedure, you need to adapt it to your case:

Add this at the very bottom of your theme functions.php:
Notes:
1.- Take care not to leave blank lines after this.
2.- If your theme functions.php doesn't end with ?> skip first line of my code.

Code: [Select]
<?php
function cust_admin_my_custom_items_column_header($table) {

    
$table->addColumn('my_custom_items_column''<span>' __('My custom data name:' '</span>''my_theme'));
}

function 
cust_admin_my_custom_items_column_data($row$aRow) {

    
$conn getConnection();
    
$item $conn->osc_dbFetchResult("SELECT my_custom_db_field FROM my_custom_db_table WHERE fk_i_item_id = '%d'"$aRow['pk_i_id'] );

    
$row['my_custom_items_column'] = $item['my_custom_db_field'] ;
    return 
$row ;
}

osc_add_hook('admin_items_table''cust_admin_my_custom_items_column_header');
osc_add_filter('items_processing_row''cust_admin_my_custom_items_column_data');
?>


Of course you need to understand the logic under this generic example to adapt it to your case.

Regards

praneeth219

  • Newbie
  • *
  • Posts: 7
[SOLVED] Show custom field data on admin area manage listing table
« Reply #2 on: July 29, 2015, 05:30:18 pm »
It works. Thanks a lot teseo for your kind help. Really appreciated.

Regards,
Praneeth

teseo

  • Hero Member
  • *****
  • Posts: 6168
Re: Show custom field data on admin area manage listing table
« Reply #3 on: July 29, 2015, 05:39:12 pm »
Your welcome. :) Please add [SOLVED] to the title of this thread (edit the first post).

Regards

webhostpune

  • Newbie
  • *
  • Posts: 4
Re: [SOLVED] Show custom field data on admin area manage listing table
« Reply #4 on: September 09, 2019, 02:48:08 pm »
 I am trying to add this code and want to show Ad ID

<?php
function cust_admin_pk_i_id_items_column_header($table) {

    $table->addColumn('pk_i_id_items_column', '<span>' . __('Ad ID' . '</span>', 'osclasswizards_theme'));
}

function cust_admin_pk_i_id_items_column_data($row, $aRow) {

    $conn = getConnection();
    $item = $conn->osc_dbFetchResult("SELECT pk_i_id_db_field FROM oswc_t_item_db_table WHERE fk_i_item_id = '%d'", $aRow['pk_i_id'] );

    $row['pk_i_id_items_column'] = $item['pk_i_id_db_field'] ;
    return $row ;
}

osc_add_hook('admin_items_table', 'cust_admin_pk_i_id_items_column_header');
osc_add_filter('items_processing_row', 'cust_admin_pk_i_id_items_column_data');
?>

but no any ad id showing ! 

whats wrong -