Add model under product name in admin

Talk about Hooks. Share Hooks you have made.
User avatar
tessthepup
Certified Developer
Posts: 381
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Add model under product name in admin

Post by tessthepup »

burt wrote: Mon Jul 15, 2024 5:07 pm You could also add in a new column to the display table, with a Hook.
So (eg) model could be in between the "name" and the "red/green status" columns.
@burt
Hi Gary, thanks for this idea it has germinated a seed lol

I would like to add the hook to display the date last modified in between the "name" and "red/green status" columns

I have had a look through the code but can not see where the hook is called to allow this, am I missing something obvious?

Thanks
Mark


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4546
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Add model under product name in admin

Post by burt »

listen_constructPaginator

viewtopic.php?t=2257

Obv that is example code for customers page, but the concept is more or less the same.
I am not here to build for you.
I am here to build with you. Let's help each other.
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Add model under product name in admin

Post by heatherbell »

Forum searches are often helpful and save time:
search.php?keywords=add+column+to+table
User avatar
tessthepup
Certified Developer
Posts: 381
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Add model under product name in admin

Post by tessthepup »

burt wrote: Tue Jul 16, 2024 10:33 am listen_constructPaginator

viewtopic.php?t=2257

Obv that is example code for customers page, but the concept is more or less the same.
@burt

Thank you Gary

Not sure I understand the table_definition part with being a hack lol

This does not show anything, should I be referencing the category column?

Code: Select all

<?php
class hook_admin_catalog_productsmodel {

   public function listen_constructPaginator($param) {
           global $table_definition;
   
           array_splice($table_definition['columns'], 1, 0, [[
               'name' => "Last Modfied",
               'class' => 'text-center',
               'function' => function ($row) {
                   return $row['products_last_modified'];
               },
           ]]);
       }
}
User avatar
burt
Core Team
Posts: 4546
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Add model under product name in admin

Post by burt »

I forgot that the catalog page does not (yet) use the paginator to make the table of contents :-\
At the moment you would not be able to use a hook to do a column, therefore.

Sorry to send you on a wild goose chase.
I am not here to build for you.
I am here to build with you. Let's help each other.
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: Add model under product name in admin

Post by raiwa »

It can be injected via JavaScript
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
User avatar
tessthepup
Certified Developer
Posts: 381
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Add model under product name in admin

Post by tessthepup »

burt wrote: Wed Jul 17, 2024 10:26 am I forgot that the catalog page does not (yet) use the paginator to make the table of contents :-\
At the moment you would not be able to use a hook to do a column, therefore.

Sorry to send you on a wild goose chase.
Thanks Gary. Everyday is a learning day :)
User avatar
tessthepup
Certified Developer
Posts: 381
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Add model under product name in admin

Post by tessthepup »

raiwa wrote: Wed Jul 17, 2024 12:30 pm It can be injected via JavaScript
Thanks Rainer.
rupruprup
Member
Posts: 44
Joined: Thu Nov 05, 2020 7:39 pm
Phoenix Version: v1.0.9.10
Has thanked: 6 times
Been thanked: 3 times

Re: Add model under product name in admin

Post by rupruprup »

can you show the working hook pls ?
User avatar
tessthepup
Certified Developer
Posts: 381
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: Add model under product name in admin

Post by tessthepup »

rupruprup wrote: Sun Jul 28, 2024 12:10 pm can you show the working hook pls ?
The hook shows the model number above the date added

Code: Select all

<?php
class hook_admin_catalog_catalogmodel{
   public function listen_infoBox($parameters) {
     global $product;
      if (isset($product) && ($product Instanceof Product)) {
       array_splice($parameters['contents'], 1, 0, [['class' => 'style', 'text' => TEXT_CATALOG_PRODUCTS_MODEL . ' ' . $product->get('model')]]);
    } 
  }
}


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply