Talk about Hooks. Share Hooks you have made.
tessthepup
Certified Developer
Posts: 381 Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times
Post
by tessthepup » Tue Jul 16, 2024 9:53 am
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
burt
Core Team
Posts: 4550 Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
: Buy Me A Beverage
Has thanked: 252 times
Been thanked: 412 times
Post
by burt » 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.
I am not here to build for you.
I am here to build with you. Let's help each other.
tessthepup
Certified Developer
Posts: 381 Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times
Post
by tessthepup » Tue Jul 16, 2024 11:35 am
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'];
},
]]);
}
}
burt
Core Team
Posts: 4550 Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
: Buy Me A Beverage
Has thanked: 252 times
Been thanked: 412 times
Post
by burt » 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.
I am not here to build for you.
I am here to build with you. Let's help each other.
tessthepup
Certified Developer
Posts: 381 Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times
Post
by tessthepup » Wed Jul 17, 2024 3:19 pm
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
tessthepup
Certified Developer
Posts: 381 Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times
Post
by tessthepup » Wed Jul 17, 2024 3:19 pm
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
Post
by rupruprup » Sun Jul 28, 2024 12:10 pm
can you show the working hook pls ?
tessthepup
Certified Developer
Posts: 381 Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times
Post
by tessthepup » Sun Jul 28, 2024 12:25 pm
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')]]);
}
}
}