d_seo_module.md (36737B)
1 Seo Module 2 ========== 3 The first professional SEO extension for opencart 2 and 3 4 5 ##### Table of content 6 1. [Installation & Update](#installation-and-update) 7 2. [API](#api) 8 1. [Admin events](#admin-list-of-events-and-their-methods) 9 * [common](#admin-common) 10 * [localisation](#localisation) 11 * [setting](#setting) 12 * [catalog](#catalog) 13 2. [Catalog events](#catalog-list-of-events-and-their-methods) 14 * [common](#catalog-common) 15 * [product](#product) 16 * [information](#information) 17 18 19 Installation and Update 20 ======================= 21 The easiest way is to use Shopunity.net extension to install the module. 22 23 ###[Shopunity](https://shopunity.net) (recomended) 24 1. In Shopunty module search for SEO module and click install 25 2. After installation is complete click Admin 26 3. Click install inside the SEO module to complete the installation. 27 28 ###Extension Installer (shopunity module required) 29 1. Go to Admin / Extensions / Extension Installer 30 2. Upload zip archive 31 3. Go to Admin / Extensions / Modules 32 4. Next to SEO module Click install 33 5. Edit SEO module 34 6. Click install to complete the installation process. 35 36 ###FTP (shopunity module required) 37 1. Upload all the files from the folder upload 38 2. Go to Admin / Extensions / Modules 39 3. Next to SEO module Click install 40 4. Edit SEO module 41 5. Click install to complete the installation process. 42 43 44 ###Update 45 You can update practically the same way as you have install the module. Only you will not need to click the final install inside the module since the module has already been installed. Though if the new version of the module locates missing parts, it will display an update button. 46 47 API 48 === 49 You can extend the SEO Module functionality by using the built-in API. The SEO module will look inside the ```admin/controller/extension/d_seo_module/``` and if your extension was found, will call specially named methods. The result will be used to modify the output using Opencart Event Methods. 50 51 ####For the API to work you will need 52 1. Install your extension in Opencart (table `oc_extension`). 53 2. Add your extension in the list ```d_seo_extension_install``` in the Opencart table `oc_setting`. 54 3. Add method, that corresponds to the event you want to subscribe to. 55 56 Here is an example of adding a new item to the SEO Module Menu in admin panel: 57 58 ```php 59 private $codename = 'd_seo_module_myfeature'; 60 private $route = 'd_seo_module/d_seo_module_myfeature'; 61 62 public function menu() { 63 $_language = new Language(); 64 $_language->load($this->route); 65 66 $url_token = ''; 67 68 if (isset($this->session->data['token'])) { 69 $url_token .= 'token=' . $this->session->data['token']; 70 } 71 72 if (isset($this->session->data['user_token'])) { 73 $url_token .= 'user_token=' . $this->session->data['user_token']; 74 } 75 76 $menu = array(); 77 78 if ($this->user->hasPermission('access', 'extension/module/' . $this->codename)) { 79 $menu[] = array( 80 'name' => $_language->get('heading_title_main'), 81 'href' => $this->url->link('extension/module/' . $this->codename, $url_token, true), 82 'sort_order' => 20, 83 'children' => array() 84 ); 85 } 86 87 return $menu; 88 } 89 ``` 90 91 --- 92 93 ##Admin list of events and their methods 94 > ####How to use it? 95 > This is how you should understand the following events: 96 97 > In Opencart 2.2.0 and below `admin/view/common/menu/after` is called after the `menu.tpl` or `menu.twig` is rendered to the screen. 98 > In Opencart 2.3.0 and above `admin/view/common/column_left/before` is called before the `column_left.tpl` or `column_left.twig` is rendered to the screen. 99 100 > To subsribe you will need to add the method `public function menu()` to your controller file `admin/controller/d_seo_module/d_seo_module_myfeature.php`. 101 102 > You will populate `$menu` with your menu item(s) `array('name' => ..., 'href' => ..., 'sort_order' => ..., 'children' => ...)` and `return $menu;` 103 104 105 ###common 106 ####1. admin/view/common/menu/after or admin/view/common/column_left/before 107 #####menu() 108 _Add an item(s) in admin to seo menu. You will add your menu item(s) and return the menu array._ 109 110 * **method:** `public function menu()` 111 * **parameters:** `$menu[] = array('name' => ..., 'href' => ..., 'sort_order' => ..., 'children' => ...);` 112 * **return:** `$menu = array(...)` 113 114 Example 115 ```php 116 private $codename = 'd_seo_module_myfeature'; 117 118 public function menu() { 119 $_language = new Language(); 120 $_language->load($this->route); 121 122 $url_token = ''; 123 124 if (isset($this->session->data['token'])) { 125 $url_token .= 'token=' . $this->session->data['token']; 126 } 127 128 if (isset($this->session->data['user_token'])) { 129 $url_token .= 'user_token=' . $this->session->data['user_token']; 130 } 131 132 $menu = array(); 133 134 if ($this->user->hasPermission('access', 'extension/module/' . $this->codename)) { 135 $menu[] = array( 136 'name' => $_language->get('heading_title_main'), 137 'href' => $this->url->link('extension/module/' . $this->codename, $url_token, true), 138 'sort_order' => 20, 139 'children' => array() 140 ); 141 } 142 143 return $menu; 144 } 145 ``` 146 ####2. admin/view/common/dashboard/after 147 #####dashboard() 148 _Add dashboard module item(s) in admin dashbord for Opencart 2.2.0 and under. You will add your dashboard module item(s) and return the dashboards array._ 149 150 * **method:** `public function dashboard()` 151 * **parameters:** `$dashboards[] = array('html' => ..., 'width' => ..., 'sort_order' => ...);` 152 * **return:** `$dashboards = array(...)` 153 154 Example 155 ```php 156 private $codename = 'd_seo_module_myfeature'; 157 158 public function dashboard() { 159 $dashboards = array(); 160 161 if ($this->user->hasPermission('access', 'extension/module/' . $this->codename)) { 162 $dashboards[] = array( 163 'html' => $this->load->controller('extension/dashboard/d_seo_module_myfeature'), 164 'width' => 12, 165 'sort_order' => 50 166 ); 167 } 168 169 return $dashboards; 170 } 171 ``` 172 173 ###localisation 174 ####1. admin/model/localisation/language/addLanguage/after 175 #####language_add_language() 176 _After new language has been added, you can preform your own actions like add a new column to a table._ 177 178 * **method:** ```public function language_add_language($data)``` 179 * **parameters:** ```$data = array('language_id' => ..., ...);``` 180 * **output:** `none` 181 182 ####2. admin/model/localisation/language/editLanguage/after 183 #####language_edit_language() 184 _Called when language has been edited. Similar to `language_add_language($data)`._ 185 186 * **method:** ```public function language_edit_language($data)``` 187 * **parameters:** ```$data = array('language_id' => ..., ...);``` 188 * **output:** `none` 189 190 ####3. admin/model/localisation/language/deleteLanguage/after 191 #####language_delete_language() 192 _Called when language has been deleted. Similar to `language_add_language($data)`._ 193 194 * **method:** ```public function language_delete_language($data)``` 195 * **parameters:** ```$data = array('language_id' => ...);``` 196 * **output:** `none` 197 198 --- 199 200 ###setting 201 ####1. admin/view/setting/setting/after 202 #####setting_tab_general() 203 _Modify the output of store setting form and new store create form. You simply return an HTML of the input or anything else that you want to place into the form and tab._ 204 205 * **method:** `public function setting_tab_general()` 206 * **parameters:** `none` 207 * **output:** `html` 208 209 Example 210 **admin/controller/extension/d_seo_module/d_seo_module_myfeature.php** 211 ```php 212 private $codename = 'd_seo_module_myfeature'; 213 private $route = 'extension/d_seo_module/d_seo_module_myfeature'; 214 215 public function setting_tab_general() { 216 $_language = new Language(); 217 $_language->load($this->route); 218 219 //get language data 220 $data['entry_myfeature'] = $_language->get('entry_myfeature'); 221 $data['help_myfeature'] = $_language->get('help_myfeature'); 222 223 //get validate error data 224 $data['error'] = ($this->config->get($this->codename . '_error')) ? $this->config->get($this->codename . '_error') : array(); 225 226 //add config_myfeature value to the $data for settings general tab 227 if (isset($this->request->post['mydata'])) { 228 $data['mydata'] = $this->request->post['mydata']; 229 } else { 230 $data['mydata'] = $this->{'model_extension_d_seo_module_' . $this->codename}->getMyData(); 231 } 232 233 //render the $data with the setting_tab_general.tpl or setting_tab_general.twig. the HTML will be returned and added to the final HTML inside the Setting General tab. 234 return $this->load->view($this->route . '/setting_tab_general', $data); 235 } 236 ``` 237 238 #####setting_tab_general_language() 239 _You can add html to the language tabs._ 240 241 * **method:** `public function setting_tab_general_language()` 242 * **parameters:** `none` 243 * **output:** `$html_tab_general_language = array(...)` 244 245 Example 246 **admin/controller/extension/d_seo_module/d_seo_module_myfeature.php** 247 ```php 248 private $codename = 'd_seo_module_myfeature'; 249 private $route = 'extension/d_seo_module/d_seo_module_myfeature'; 250 251 public function setting_tab_general_language() { 252 //load models and language files 253 $_language = new Language(); 254 $_language->load($this->route); 255 256 $this->load->model($this->route); 257 258 //get languages 259 $languages = $this->{'model_extension_d_seo_module_d_seo_module_myfeature'}->getLanguages(); 260 261 //get language data 262 $data['entry_myfeature'] = $_language->get('entry_myfeature'); 263 $data['help_myfeature'] = $_language->get('help_myfeature'); 264 265 //get validate error data 266 $data['error'] = ($this->config->get($this->codename . '_error')) ? $this->config->get($this->codename . '_error') : array(); 267 268 //add config_myfeature value to the $data for settings general tab 269 if (isset($this->request->post['mydata'])) { 270 $data['mydata'] = $this->request->post['mydata']; 271 } else { 272 $data['mydata'] = $this->{'model_extension_d_seo_module_' . $this->codename}->getMyData(); 273 } 274 275 //render the $data with the setting_tab_general_language.tpl or setting_tab_general_language.twig. the HTML will be returned and added to the final HTML inside the Setting General tab. 276 $html_tab_general_language = array(); 277 278 foreach ($languages as $language) { 279 $data['language_id'] = $language['language_id']; 280 281 $html_tab_general_language[$data['language_id']] = $this->load->view($this->route . '/setting_tab_general_language', $data); 282 } 283 284 return $html_tab_general_language; 285 } 286 ``` 287 288 #####setting_tab_store() 289 * **method:** `public function setting_tab_store()` 290 * **parameters:** `none` 291 * **output:** `html` 292 293 #####setting_tab_local() 294 * **method:** `public function setting_tab_local()` 295 * **parameters:** `none` 296 * **output:** `html` 297 298 #####setting_tab_option() 299 * **method:** `public function setting_tab_option()` 300 * **parameters:** `none` 301 * **output:** `html` 302 303 #####setting_style() 304 _This is a style input. You can use this for adding CSS to the form. Yet we recommend using he default `$this->document->addStyle($href, $rel = 'stylesheet', $media = 'screen')`;_ 305 306 * **method:** `public function setting_style()` 307 * **parameters:** `none` 308 * **output:** `html` 309 310 #####setting_script() 311 _Add js scripts to the form._ 312 313 * **method:** `public function setting_script()` 314 * **parameters:** `none` 315 * **output:** `html` 316 317 ####2. admin/controller/setting/setting/validate 318 #####setting_validate() 319 _After Opencart validate actions has been completed, you can preform your own actions using an array $error._ 320 321 * **method:** ```public function setting_validate($error)``` 322 * **parameters:** ```$error = array(...);``` 323 * **output:** `$error = array(...)` 324 325 Example: 326 **admin/controller/extension/d_seo_module/d_seo_module_myfeature.php** 327 ```php 328 private $codename = 'd_seo_module_myfeature'; 329 private $route = 'extension/d_seo_module/d_seo_module_myfeature'; 330 331 public function setting_validate($error) { 332 if (isset($this->request->post['mydata'])) { 333 $_language = new Language(); 334 $_language->load($this->route); 335 336 if ((utf8_strlen($this->request->post['mydata']) < 3) || (utf8_strlen($this->request->post['mydata']) > 255)) { 337 $error['mydata'] = $_language->get('error_mydata'); 338 } 339 340 $this->config->set($this->codename . '_error', $error); 341 } 342 343 return $error; 344 } 345 ``` 346 347 ####3. admin/controller/setting/setting/index 348 #####setting_edit_setting() 349 _Before setting has been edited, you can preform your own actions using an array $data._ 350 351 * **method:** ```public function setting_edit_setting($data)``` 352 * **parameters:** ```$data = array('store_id' => ..., ...);``` 353 * **output:** `none` 354 355 ####4. admin/view/setting/store_form/after 356 #####store_form_tab_general() 357 _Modify the output of store form and new store create form. You simply return an HTML of the input or anything else that you want to place into the form and tab._ 358 359 * **method:** `public function store_form_tab_general()` 360 * **parameters:** `none` 361 * **output:** `html` 362 363 #####store_form_tab_general_language() 364 _You can add html to the language tabs._ 365 366 * **method:** `public function store_form_tab_general_language()` 367 * **parameters:** `none` 368 * **output:** `$html_tab_general_language = array(...)` 369 370 #####store_form_tab_store() 371 * **method:** `public function store_form_tab_store()` 372 * **parameters:** `none` 373 * **output:** `html` 374 375 #####store_form_tab_local() 376 * **method:** `public function store_form_tab_local()` 377 * **parameters:** `none` 378 * **output:** `html` 379 380 #####store_form_tab_option() 381 * **method:** `public function store_form_tab_option()` 382 * **parameters:** `none` 383 * **output:** `html` 384 385 #####store_form_style() 386 _This is a style input. You can use this for adding CSS to the form. Yet we recommend using he default `$this->document->addStyle($href, $rel = 'stylesheet', $media = 'screen')`;_ 387 388 * **method:** `public function store_form_style()` 389 * **parameters:** `none` 390 * **output:** `html` 391 392 #####store_form_script() 393 _Add js scripts to the form._ 394 395 * **method:** `public function store_form_script()` 396 * **parameters:** `none` 397 * **output:** `html` 398 399 ####5. admin/controller/setting/store_form/validateForm 400 #####store_validate_form() 401 _After Opencart validate actions has been completed, you can preform your own actions using an array $error._ 402 403 * **method:** ```public function store_validate_form($error)``` 404 * **parameters:** ```$error = array(...);``` 405 * **output:** `$error = array(...)` 406 407 ####6. admin/model/setting/store/addStore/after 408 #####store_add_store() 409 _Before new store has been added, you can preform your own actions using an array $data._ 410 411 * **method:** ```public function store_add_store($data)``` 412 * **parameters:** ```$data = array('store_id' => ..., ...);``` 413 * **output:** `none` 414 415 ####7. admin/model/setting/store/editStore/after 416 #####store_edit_store() 417 _Before store settings has been edited, you can preform your own actions using an array $data._ 418 419 * **method:** ```public function store_edit_store($data)``` 420 * **parameters:** ```$data = array('store_id' => ..., ...);``` 421 * **output:** `none` 422 423 ####8. admin/model/setting/store/deleteStore/after 424 #####store_delete_store() 425 _Before store settings has been deleted, you can preform your own actions using an array $data._ 426 427 * **method:** ```public function store_delete_store($data)``` 428 * **parameters:** ```$data = array('store_id' => ...);``` 429 * **output:** `none` 430 431 --- 432 433 ###catalog 434 ####1. admin/view/catalog/category_form/after 435 #####category_form_tab_general() 436 _Modify the HTML output of category form. You simply return an HTML of the input or anything else that you want to place into the form based on the tab._ 437 438 * **method:** `public function category_form_tab_general()` 439 * **parameters:** `none` 440 * **output:** `html` 441 442 #####category_form_tab_general_language() 443 _You can add html to the language tabs._ 444 445 * **method:** `public function category_form_tab_general_language()` 446 * **parameters:** `none` 447 * **output:** `$html_tab_general_language = array(...)` 448 449 #####category_form_tab_data() 450 * **method:** `public function category_form_tab_data()` 451 * **parameters:** `none` 452 * **output:** `html` 453 454 #####category_form_style() 455 _This is a style input. You can use this for adding CSS to the form. Yet we recomend using he default `$this->document->addStyle($href, $rel = 'stylesheet', $media = 'screen')`;_ 456 457 * **method:** `public function category_form_style()` 458 * **parameters:** `none` 459 * **output:** `html` 460 461 #####category_form_script() 462 _Add js scripts to the form._ 463 464 * **method:** `public function category_form_script()` 465 * **parameters:** `none` 466 * **output:** `html` 467 468 ####2. admin/controller/catalog/category/validateForm 469 #####category_validate_form() 470 _After Opencart validate actions has been completed, you can preform your own actions using an array $error._ 471 472 * **method:** ```public function category_validate_form($error)``` 473 * **parameters:** ```$error = array(...);``` 474 * **output:** `$error = array(...)` 475 476 ####3. admin/model/catalog/category/addCategory/after 477 #####category_add_category() 478 _After new category has been added, you can preform your own actions using an array $data._ 479 480 * **method:** ```public function category_add_category($data)``` 481 * **parameters:** ```$data = array('category_id' => ..., ...);``` 482 * **output:** `none` 483 484 ####4. admin/model/catalog/category/editCategory/after 485 #####category_edit_category() 486 _After category has been edited, you can preform your own actions using an array $data._ 487 488 * **method:** ```public function category_edit_category($data)``` 489 * **parameters:** ```$data = array('category_id' => ..., ...);``` 490 * **output:** `none` 491 492 ####5. admin/model/catalog/category/deleteCategory/after 493 #####category_delete_category() 494 _After category has been deleted, you can preform your own actions using an array $data._ 495 496 * **method:** ```public function category_delete_category($data)``` 497 * **parameters:** ```$data = array('category_id' => ...);``` 498 * **output:** `none` 499 500 ####6. admin/view/catalog/product_form/after 501 #####product_form_tab_general() 502 _Modify the HTML output of product form. You simply return an HTML of the input or anything else that you want to place into the form based on the tab._ 503 504 * **method:** `public function product_form_tab_general()` 505 * **parameters:** `none` 506 * **output:** `html` 507 508 #####product_form_tab_general_language() 509 _You can add html to the language tabs._ 510 511 * **method:** `public function product_form_tab_general_language()` 512 * **parameters:** `none` 513 * **output:** `$html_tab_general_language = array(...)` 514 515 #####product_form_tab_data() 516 * **method:** `public function product_form_tab_data()` 517 * **parameters:** `none` 518 * **output:** `html` 519 520 #####product_form_tab_links() 521 * **method:** `public function product_form_tab_links()` 522 * **parameters:** `none` 523 * **output:** `html` 524 525 #####product_form_style() 526 _This is a style input. You can use this for adding CSS to the form. We recommended using the default `$this->document->addStyle($href, $rel = 'stylesheet', $media = 'screen')`;_ 527 528 * **method:** `public function product_form_style()` 529 * **parameters:** `none` 530 * **output:** `html` 531 532 #####product_form_script() 533 _Add js scripts to the form._ 534 535 * **method:** `public function product_form_script()` 536 * **parameters:** `none` 537 * **output:** `html` 538 539 ####7. admin/controller/catalog/product/validateForm 540 #####product_validate_form() 541 _After Opencart validate actions has been completed, you can preform your own actions using an array $error._ 542 543 * **method:** ```public function product_validate_form($error)``` 544 * **parameters:** ```$error = array(...);``` 545 * **output:** `$error = array(...)` 546 547 ####8. admin/model/catalog/product/addProduct/after 548 #####product_add_product() 549 _After new product has been added, you can preform your own actions using an array $data._ 550 551 * **method:** `public function product_add_product($data)` 552 * **parameters:** `$data = array('product_id' => ..., ...)` 553 * **output:** `none` 554 555 ####9. model/catalog/product/editProduct/after 556 #####product_edit_product() 557 _After product has been edited, you can preform your own actions using an array $data._ 558 559 * **method:** `public function product_edit_product($data)` 560 * **parameters:** `$data = array('product_id' => ..., ...)` 561 * **output:** `none` 562 563 ####10. model/catalog/product/deleteProduct/after 564 #####product_delete_product() 565 _After product has been deleted, you can preform your own actions using an array $data._ 566 567 * **method:** `public function product_delete_product($data)` 568 * **parameters:** `$data = array('product_id' => ...)` 569 * **output:** `none` 570 571 ####11. admin/view/catalog/manufacturer_form/after 572 #####manufacturer_form_tab_general() 573 _Modify the HTML output of manufacturer form. You simply return an HTML of the input or anything else that you want to place into the form based on the tab._ 574 575 * **method:** `public function manufacturer_form_tab_general()` 576 * **parameters:** `none` 577 * **output:** `html` 578 579 #####manufacturer_form_tab_general_language() 580 _You can add html to the language tabs._ 581 582 * **method:** `public function manufacturer_form_tab_general_language()` 583 * **parameters:** `none` 584 * **output:** `$html_tab_general_language = array(...)` 585 586 #####manufacturer_form_tab_data() 587 * **method:** `public function manufacturer_form_tab_data()` 588 * **parameters:** `none` 589 * **output:** `html` 590 591 #####manufacturer_form_style() 592 _This is a style input. You can use this for adding CSS to the form. We recommended using the default `$this->document->addStyle($href, $rel = 'stylesheet', $media = 'screen')`;_ 593 594 * **method:** `public function manufacturer_form_style()` 595 * **parameters:** `none` 596 * **output:** `html` 597 598 #####manufacturer_form_script() 599 _Add js scripts to the form._ 600 601 * **method:** `public function manufacturer_form_script()` 602 * **parameters:** `none` 603 * **output:** `html` 604 605 ####12. admin/controller/catalog/manufacturer/validateForm 606 #####manufacturer_validate_form() 607 _After Opencart validate actions has been completed, you can preform your own actions using an array $error._ 608 609 * **method:** ```public function manufacturer_validate_form($error)``` 610 * **parameters:** ```$error = array(...);``` 611 * **output:** `$error = array(...)` 612 613 ####13. admin/model/catalog/manufacturer/addManufacturer/after 614 #####manufacturer_add_manufacturer() 615 _After a new manufacturer has been added, you can preform your own actions using an array $data._ 616 617 * **method:** `public function manufacturer_add_manufacturer($data)` 618 * **parameters:** `$data = array('manufacturer_id' => ..., ...)` 619 * **output:** `none` 620 621 ####14. admin/model/catalog/manufacturer/editManufacturer/after 622 #####manufacturer_edit_manufacturer() 623 _After a new manufacturer has been added, you can preform your own actions using an array $data._ 624 625 * **method:** `public function manufacturer_edit_manufacturer($data)` 626 * **parameters:** `$data = array('manufacturer_id' => ..., ...)` 627 * **output:** `none` 628 629 ####15. admin/model/catalog/manufacturer/deleteManufacturer/after 630 #####manufacturer_delete_manufacturer() 631 _After a new manufacturer has been deleted, you can preform your own actions using an array $data._ 632 633 * **method:** `public function manufacturer_delete_manufacturer($data)` 634 * **parameters:** `$data = array('manufacturer_id' => ...)` 635 * **output:** `none` 636 637 ####16. admin/view/catalog/information_form/after 638 #####information_form_tab_general() 639 _Modify the HTML output of information form. You simply return an HTML of the input or anything else that you want to place into the form based on the tab._ 640 641 * **method:** `public function information_form_tab_general()` 642 * **parameters:** `none` 643 * **output:** `html` 644 645 #####information_form_tab_general_language() 646 _You can add html to a language tabs._ 647 648 * **method:** `public function information_form_tab_general_language()` 649 * **parameters:** `none` 650 * **output:** `$html_tab_general_language = array(...)` 651 652 #####information_form_tab_data() 653 * **method:** `public function information_form_tab_data()` 654 * **parameters:** `none` 655 * **output:** `html` 656 657 #####information_form_style() 658 _This is a style input. You can use this for adding CSS to the form. We recommended using the default `$this->document->addStyle($href, $rel = 'stylesheet', $media = 'screen')`;_ 659 660 * **method:** `public function information_form_style()` 661 * **parameters:** `none` 662 * **output:** `html` 663 664 #####information_form_script() 665 _Add js scripts to the form._ 666 667 * **method:** `public function information_form_script()` 668 * **parameters:** `none` 669 * **output:** `html` 670 671 ####17. admin/controller/catalog/information/validateForm 672 #####information_validate_form() 673 _After Opencart validate actions has been completed, you can preform your own actions using an array $error._ 674 675 * **method:** ```public function information_validate_form($error)``` 676 * **parameters:** ```$error = array(...);``` 677 * **output:** `$error = array(...)` 678 679 ####18. admin/model/catalog/information/addInformation/after 680 #####information_add_information() 681 _After a information has been edited, you can preform your own actions using an array $data._ 682 683 * **method:** `public function information_add_information($data)` 684 * **parameters:** `$data = array('information_id' => ..., ...)` 685 * **output:** `none` 686 687 ####19. admin/model/catalog/information/editInformation/after 688 #####information_edit_information() 689 _After a information has been edited, you can preform your own actions using an array $data._ 690 691 * **method:** `public function information_edit_information($data)` 692 * **parameters:** `$data = array('information_id' => ..., ...)` 693 * **output:** `none` 694 695 ####20. admin/model/catalog/information/deleteInformation/after 696 #####information_delete_information() 697 _After a information has been deleted, you can preform your own actions using an array $data._ 698 699 * **method:** `public function information_delete_information($data)` 700 * **parameters:** `$data = array('information_id' => ...)` 701 * **output:** `none` 702 703 --- 704 705 ##Catalog list of events and their methods 706 > ####How to use it? 707 > For the frontend you have two basic events: 708 > - `before` (before event - here you modify the data array) 709 > - `after` (after event - here you modify the HTML). 710 711 1. `catalog/view/common/home/before` is called before the `home.tpl` or `home.twig` is rendered to the screen. 712 2. To subsribe you will need to add the method `public function home_before($data)` to your controller file `catalog/controller/extension/d_seo_module/d_seo_module_myfeature.php` with a parameter `$data` 713 3. You will modify `$data` accordingly and `return $data;` 714 715 ###catalog common 716 ####1. catalog/view/common/header/before 717 #####header_before() 718 _Modify the data that will be rendered to the `header.tpl` or `header.twig`._ 719 720 * **method:** `public function header_before($data)` 721 * **parameters:** `$data = array(...)` 722 * **output:** `$data = array(...)` 723 724 Example 725 **catalog/controller/extension/d_seo_module/d_seo_module_myfeature.php** 726 ```php 727 private $codename = 'd_seo_module_myfeature'; 728 private $route = 'extension/d_seo_module/d_seo_module_myfeature'; 729 730 public function header_before($data) { 731 //load models and language files 732 $_language = new Language(); 733 $_language->load($this->route); 734 735 $this->load->model($this->route); 736 737 //get language data 738 $data['myfeature'] = $_language->get('myfeature'); 739 740 return $data; 741 } 742 ``` 743 744 ####2. catalog/view/common/header/after 745 #####header_after() 746 _Modify the HTML of the `header.tpl` or `header.twig` before browser renders it._ 747 748 * **method:** `public function header_after($html)` 749 * **parameters:** `(string) $html` 750 * **output:** `(string) $html` 751 752 Example 753 **catalog/controller/extension/d_seo_module/d_seo_module_myfeature.php** 754 ```php 755 private $codename = 'd_seo_module_myfeature'; 756 private $route = 'extension/d_seo_module/d_seo_module_myfeature'; 757 758 public function header_after($html) { 759 //load models and language files 760 $_language = new Language(); 761 $_language->load($this->route); 762 763 $this->load->model($this->route); 764 765 //get language data 766 $myfeature = $_language->get('myfeature'); 767 768 if (file_exists(DIR_SYSTEM . 'library/d_simple_html_dom.php')) { 769 $html_dom = new d_simple_html_dom(); 770 $html_dom->load((string)$html, $lowercase = true, $stripRN = false, $defaultBRText = DEFAULT_BR_TEXT); 771 772 foreach ($html_dom->find('#myfeature') as $element) { 773 $element->innertext = $myfeature; 774 } 775 776 return (string)$html_dom; 777 } return $html; 778 } 779 ``` 780 781 ####3. catalog/view/common/footer/before 782 #####footer_before() 783 _Modify the data that will be rendered to the `footer.tpl` or `footer.twig`._ 784 785 * **method:** `public function footer_before($data)` 786 * **parameters:** `$data = array(...)` 787 * **output:** `$data = array(...)` 788 789 ####4. catalog/view/common/footer/after 790 #####footer_after() 791 _Modify the HTML of the `footer.tpl` or `footer.twig` before browser renders it._ 792 793 * **method:** `public function footer_after($html)` 794 * **parameters:** `(string) $html` 795 * **output:** `(string) $html` 796 797 ####5. catalog/view/common/home/before 798 #####home_before() 799 _Modify the data that will be rendered to the `home.tpl` or `home.twig`._ 800 801 * **method:** `public function home_before($data)` 802 * **parameters:** `$data = array(...)` 803 * **output:** `$data = array(...)` 804 805 ####6. catalog/view/common/home/after 806 #####home_after() 807 _Modify the HTML of the `home.tpl` or `home.twig` before browser renders it._ 808 809 * **method:** `public function home_after($html)` 810 * **parameters:** `(string) $html` 811 * **output:** `(string) $html` 812 813 ####7. catalog/controller/common/language/language 814 #####language_language() 815 _When switching the language you can preform your own actions._ 816 817 * **method:** `public function language_language()` 818 * **parameters:** `none` 819 * **output:** `none` 820 821 Example 822 **admin/controller/extension/d_seo_module/d_seo_module_myfeature.php** 823 ```php 824 private $codename = 'd_seo_module_myfeature'; 825 private $route = 'extension/d_seo_module/d_seo_module_myfeature'; 826 827 public function language_language() { 828 $this->load->model($this->route); 829 830 if (isset($this->request->post['redirect'])) { 831 $this->request->post['redirect'] = $this->{'model_extension_d_seo_module_' . $this->codename}->getURLForLanguage($this->request->post['redirect'], $this->session->data['language']); 832 } 833 } 834 ``` 835 836 ####8. catalog/controller/common/seo_url/index or catalog/controller/startup/seo_url/index 837 #####seo_url() 838 _Here you can get route of your page by seo keyword or preform your own actions until the route has not yet been determined._ 839 840 * **method:** `public function seo_url()` 841 * **parameters:** `none` 842 * **output:** `none` 843 844 #####seo_url_check() 845 _Here you can preform your own actions after route of the page has been already determined._ 846 847 * **method:** `public function seo_url_check()` 848 * **parameters:** `none` 849 * **output:** `html` 850 851 --- 852 853 ###product 854 ####1. catalog/view/product/category/before 855 #####category_before() 856 _Modify the data that will be rendered to the `category.tpl` or `category.twig`._ 857 858 * **method:** `public function category_before($data)` 859 * **parameters:** `$data = array(...)` 860 * **output:** `$data = array(...)` 861 862 ####2. catalog/view/product/category/after 863 #####category_after() 864 _Modify the HTML of the `category.tpl` or `category.twig` before browser renders it._ 865 866 * **method:** `public function category_after($html)` 867 * **parameters:** `(string) $html` 868 * **output:** `(string) $html` 869 870 ####3. catalog/model/catalog/category/getCategory/after 871 #####category_get_category() 872 _After category data has been returned, you can preform your own actions using an array $data._ 873 874 * **method:** `public function category_get_category($data)` 875 * **parameters:** `$data = array(...)` 876 * **output:** `$data = array(...)` 877 878 ####4. catalog/model/catalog/category/getCategories/after 879 #####category_get_categories() 880 _After categories data has been returned, you can preform your own actions using an array $data._ 881 882 * **method:** `public function category_get_categories($data)` 883 * **parameters:** `$data = array(...)` 884 * **output:** `$data = array(...)` 885 886 ####5. catalog/view/product/product/before 887 #####product_before() 888 _Modify the data that will be rendered to the `product.tpl` or `product.twig`._ 889 890 * **method:** `public function product_before($data)` 891 * **parameters:** `$data = array(...)` 892 * **output:** `$data = array(...)` 893 894 ####6. catalog/view/product/product/after 895 #####product_after() 896 _Modify the HTML of the `product.tpl` or `product.wig` before browser renders it._ 897 898 * **method:** `public function product_after($html)` 899 * **parameters:** `(string) $html` 900 * **output:** `(string) $html` 901 902 ####7. catalog/model/catalog/product/getProduct/after 903 #####product_get_product() 904 _After product data has been returned, you can preform your own actions using an array $data._ 905 906 * **method:** `public function product_get_product($data)` 907 * **parameters:** `$data = array(...)` 908 * **output:** `$data = array(...)` 909 910 ####8. catalog/model/catalog/product/getProducts/after 911 #####product_get_products() 912 _After products data has been returned, you can preform your own actions using an array $data._ 913 914 * **method:** `public function product_get_products($data)` 915 * **parameters:** `$data = array(...)` 916 * **output:** `$data = array(...)` 917 918 ####9. catalog/view/product/manufacturer_list/before 919 #####manufacturer_list_before() 920 _Modify the data that will be rendered to the `manufacturer_list.tpl` or `manufacturer_list.twig`._ 921 922 * **method:** `public function manufacturer_list_data($data)` 923 * **parameters:** `$data = array(...)` 924 * **output:** `$data = array(...)` 925 926 ####10. catalog/view/product/manufacturer_list/after 927 #####manufacturer_list_after() 928 _Modify the HTML of the `manufacturer_list.tpl` or `manufacturer_list.twig` before browser renders it._ 929 930 * **method:** `public function manufacturer_list_after($html)` 931 * **parameters:** `(string) $html` 932 * **output:** `(string) $html` 933 934 ####11. catalog/view/product/manufacturer_info/before 935 #####manufacturer_info_before() 936 _Modify the data that will be rendered to the `manufacturer_info.tpl` or `manufacturer_info.twig`._ 937 938 * **method:** `public function manufacturer_info_before($data)` 939 * **parameters:** `$data = array(...)` 940 * **output:** `$data = array(...)` 941 942 ####12. catalog/view/product/manufacturer_info/after 943 #####manufacturer_info_after() 944 _Modify the HTML of the `manufacturer_info.tpl` or `manufacturer_info.twig` before browser renders it._ 945 946 * **method:** `public function manufacturer_info_after($html)` 947 * **parameters:** `(string) $html` 948 * **output:** `(string) $html` 949 950 ####13. catalog/model/catalog/manufacturer/getManufacturer/after 951 #####manufacturer_get_manufacturer() 952 _After manufacturer data has been returned, you can preform your own actions using an array $data._ 953 954 * **method:** `public function manufacturer_get_manufacturer($data)` 955 * **parameters:** `$data = array(...)` 956 * **output:** `$data = array(...)` 957 958 ####14. catalog/model/catalog/manufacturer/getManufacturers/after 959 #####manufacturer_get_manufacturers() 960 _After manufacturers data has been returned, you can preform your own actions using an array $data._ 961 962 * **method:** `public function manufacturer_get_manufacturers($data)` 963 * **parameters:** `$data = array(...)` 964 * **output:** `$data = array(...)` 965 966 ####15. catalog/view/product/search/before 967 #####search_before() 968 _Modify the data that will be rendered to the `search.tpl` or `search.twig`._ 969 970 * **method:** `public function search_before($data)` 971 * **parameters:** `$data = array(...)` 972 * **output:** `$data = array(...)` 973 974 ####16. catalog/view/product/search/after 975 #####search_after() 976 _Modify the HTML of the `search.tpl` or `search.twig` before browser renders it._ 977 978 * **method:** `public function search_after($html)` 979 * **parameters:** `(string) $html` 980 * **output:** `(string) $html` 981 982 ####17. catalog/view/product/special/before 983 #####special_before() 984 _Modify the data that will be rendered to the `special.tpl` or `special.twig`._ 985 986 * **method:** `public function special_before($data)` 987 * **parameters:** `$data = array(...)` 988 * **output:** `$data = array(...)` 989 990 ####18. catalog/view/product/special/after 991 #####special_after() 992 _Modify the HTML of the `special.tpl` or `special.twig` before browser renders it._ 993 994 * **method:** `public function special_after($html)` 995 * **parameters:** `(string) $html` 996 * **output:** `(string) $html` 997 998 --- 999 1000 ###information 1001 ####1. catalog/view/information/information/before 1002 #####information_before() 1003 _Modify the data that will be rendered to the `information.tpl` or `information.twig`._ 1004 1005 * **method:** `public function information_before($data)` 1006 * **parameters:** `$data = array(...)` 1007 * **output:** `$data = array(...)` 1008 1009 ####2. catalog/view/information/information/after 1010 #####information_after() 1011 _Modify the HTML of the `information.tpl` or `information.twig` before browser renders it._ 1012 1013 * **method:** `public function information_after($html)` 1014 * **parameters:** `(string) $html` 1015 * **output:** `(string) $html` 1016 1017 ####3. catalog/model/catalog/information/getInformation/after 1018 #####information_get_information() 1019 _After information data has been returned, you can preform your own actions using an array $data._ 1020 1021 * **method:** `public function information_get_information($data)` 1022 * **parameters:** `$data = array(...)` 1023 * **output:** `$data = array(...)` 1024 1025 ####4. catalog/model/catalog/information/getInformations/after 1026 #####information_get_informations() 1027 _After informations data has been returned, you can preform your own actions using an array $data._ 1028 1029 * **method:** `public function information_get_informations($data)` 1030 * **parameters:** `$data = array(...)` 1031 * **output:** `$data = array(...)` 1032 1033 ---