tessthepup wrote: ↑Sun Jan 02, 2022 12:54 pm
not going to lie about it, I have no idea what code to put where although I did get the form injected
I'm sorry, I don't have the time right now to go as much in depth as I want, but I'll try to at least give something (
note, I'm not a coder so I might be wrong about stuff, but it seems to work, when applied the way I think it should be)
Hooks are places in core that are calling for extra code. If the call is answered somewhere, that code will run along the core code. To answer the core hook-calls, our custom code has to listen:
Code: Select all
public function [b]listen[/b]_productActionSave() {
Everything within that function will run, when core executes the
hook-call:
Code: Select all
$admin_hooks->cat(Admin::camel_case($action) . 'Action');
The above should, on version >=1.0.8.5, probably be:
Code: Select all
public function listen_insertProductAction() {
for when creating a new product and
Code: Select all
public function listen_updateProductAction() {
for when editing a existing product. listen_productActionSave will actually not do anything anymore, as there is no call for productActionSave - It has been split into insertProductAction and updateProductAction, but before 1.0.8.5 productActionSave would be correct, and I included it here, as it was what you had in your file
This part ensures that whatever is wanted will be saved into the database.
That is done inside the listening function with something like:
Code: Select all
$products_extra_description = Text::input($_POST['products_extra_description']);
$GLOBALS['db']->query("UPDATE products_description SET products_extra_description = '" . $GLOBALS['db']->escape($products_extra_description) . "' WHERE products_id = " . (int)$GLOBALS['products_id']);
The first line makes the Posted value from your form ready for insertion into the database. The next line adds your second description to table.products_description on the product you are editing.
You can insert forms via hooks multiple places:
- Or in a new tab (This would require a few more things than just adding a form)
So instead of
Code: Select all
public function listen_injectDataForm() {
You should probably use
Code: Select all
public function listen_injectLanguageForm() {
I will gladly expound to the best of my knowledge, if anything is too confusing or just unclear
//Daniel