Is there a way I can create an OpenCart module that has access to all the (front-end) pages of the store? What I want is for the user to not have to “bind” this module to all the layouts in order for it to exist in all pages. Basically I want to build a module that injects some js code to every page of the app and depending on some OpenCart hooks on the back-end to run some extra js code on front or some api requests on the back-end. Thanks
How do i get access to all front end pages on an opencart module?
676 Views Asked by paptom At
1
There are 1 best solutions below
Related Questions in OPENCART
- Is it possible to use ES5 JavaScript with Angular 2 instead of TypeScript?
- Module '"angular2/angular2"' has no exported member 'For'
- import syntax in typescript creating another js file in visual studio
- Separate ts file for imports
- How to use an AngularJS 2 component multiple times in the same page?
- injectables not working in angular 2.0 latest build 26
- Does angular2 bootstrap have a way to dynamically target elements like it does in angular 1.x
- Import {} from location is not found in VS Code using TypeScript and Angular 2
- Angular 2/Typescript: require not found
- ng-switch in Angular2
Related Questions in OPENCART2.X
- Is it possible to use ES5 JavaScript with Angular 2 instead of TypeScript?
- Module '"angular2/angular2"' has no exported member 'For'
- import syntax in typescript creating another js file in visual studio
- Separate ts file for imports
- How to use an AngularJS 2 component multiple times in the same page?
- injectables not working in angular 2.0 latest build 26
- Does angular2 bootstrap have a way to dynamically target elements like it does in angular 1.x
- Import {} from location is not found in VS Code using TypeScript and Angular 2
- Angular 2/Typescript: require not found
- ng-switch in Angular2
Related Questions in OPENCART-MODULE
- Is it possible to use ES5 JavaScript with Angular 2 instead of TypeScript?
- Module '"angular2/angular2"' has no exported member 'For'
- import syntax in typescript creating another js file in visual studio
- Separate ts file for imports
- How to use an AngularJS 2 component multiple times in the same page?
- injectables not working in angular 2.0 latest build 26
- Does angular2 bootstrap have a way to dynamically target elements like it does in angular 1.x
- Import {} from location is not found in VS Code using TypeScript and Angular 2
- Angular 2/Typescript: require not found
- ng-switch in Angular2
Related Questions in OPENCART2.3
- Is it possible to use ES5 JavaScript with Angular 2 instead of TypeScript?
- Module '"angular2/angular2"' has no exported member 'For'
- import syntax in typescript creating another js file in visual studio
- Separate ts file for imports
- How to use an AngularJS 2 component multiple times in the same page?
- injectables not working in angular 2.0 latest build 26
- Does angular2 bootstrap have a way to dynamically target elements like it does in angular 1.x
- Import {} from location is not found in VS Code using TypeScript and Angular 2
- Angular 2/Typescript: require not found
- ng-switch in Angular2
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
I am not sure exactly what you are looking for by saying you want a module to have "access" to all the (front-end) pages of the store. Modules have to be placed in layouts, and layouts can be assigned to multiple pages.
Each layout can have elements that are assigned specifically to areas you can designate (and customize). For example, you might want to create a special place for your module in the common header. You would simply create the controller, language and view files in a folder of your own designation (in my example, I will use the common folder), and let's call these files "loadjs".
Pattern these after the
common/header.php
and.tpl
files. Just be sure to change the class and file names in the controller file to match. So you would create aloadjs.php
file in the common directory of the controller folder that contains theControllerCommonLoadjs
class, aloadjs.php
file in thelanguage/(your language)/common
folder, and aloadjs.tpl
file in theview/theme/(your theme name)/template/common
folder.Add a
$data['loadjs'] = $this->load->controller('common/loadjs');
to yourcontroller/common/header.php
file and<?php echo $loadjs; ?>
in yourview/theme/(your theme name)/template/common/header.tpl
file. You can now create your module.However, to be able to add it to your layout you will need to make some changes to some admin files.
Add $_['text_loadjs'] = 'Loadjs';
to youradmin/language/(your language)/design/layout.php
file and$data['text_loadjs'] = $this->language->get('text_loadjs');
to youradmin/controller/design/layout.php
file.You will need to make a change to your
admin/view/template/design/layout_form.tpl
file as well. Look for the following code:and add the following code just below that:
Now, login to your OpenCart Dashboard and add your module to the loadjs position on your layout. And that should do it.