How does Opencart Module saves its settings? - module

Hey guys I ran into a bit of a problem with module I am developing for OpenCart v1.5.6.4. This is what I have in Admin section for module settings.
As you can see I built in extra tabs where I want to give user the ability to specify extra options which will be used to build out a prescription form on the Catalog side.
Problem is how do I go about Save extra data from each additional tab to a custom table when user click on Save button?
Is there a special function that gets called when Save button is clicked that I could implement myself?

Eh, I guess I was a bit tired last night to realise that this section of code defined in index() handles saving of module setting to the database:
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
//save module settings
$this->model_setting_setting->editSetting('prescripts', $this->request->post);
//mark of success
$this->session->data['success'] = $this->language->get('text_success');
//redirect back to module page
$this->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
}
So all i need to do is stuff my custom code in here and I am done with Admin controller.

Related

TYPO3 Plugin - One action public access and one private

I'm developing an extension that have both, a list of records (action show) and a form to send a new record (action new).
The list must be for public access, but the form must require a login form (I'm using the login form content type that comes with TYPO3).
I have tried using the Access Tab for the plugin selecting Show at any Login but it applies to the entire plugin not for each action.
Currently, this is how the page looks like:
How could I get to display the login form only when someone tries to create a new record?
Note: The extension is based on Extbase and Fluid. The target version is TYPO3 6.2.
The easiest would be to split the actions in different "views" with switchableControllerActions in your flexform. Then you would need to place separate plugins on two different pages, that way you can have different access configuration for the plugins. If you don't know how to adjust the flexform, you can post the content of it here.
The other way would be to make a check inside the controller, but i would only use it if you have a lot of different roles you need to check.
if ($this->loginUser === null && $GLOBALS['TSFE']->loginUser && !empty($GLOBALS['TSFE']->fe_user->user['uid'])) {
// the user is logged in
} else {
// return '' as action content
return '';
}

Is it good to duplicate the opencart module?

Well I want to make a custom page in opencart admin panel to insert and delete some data from opencart database
For example :
Set an image slider on opencart home page and fetching images from database & for insertion of images, I want to create a custom page in opencart admin panel ??
So how can it be possible ??
You can duplicate any module and create other for your needs. Remember to duplicate and change the filename so the "new" extension can work properly.
Folder to consider for admin:
admin->controller->{type of module}->module's name
admin->model->(type of module)->module's name
admin->language->english (always)->(type of module)->module's name
optional:
admin->language->(other languages)->(type of module)->module's name
you may try,
1,Login as Admin-> systems -> design ->banners -> insert ->
YOUR BANNER NAME-> add banner ->
Title: YOUR TITLE
Image: YOUR IMAGE -> Save
2, Login as Admin-> extensions -> Modules ->Slideshow -> Edit -> add Module -> SELECT YOUR BANNER -> Save
Also when duplicating modules be aware that you may also need to change the existing class name to different one. For example when duplicating module flat rate you will also need to change in the controller /admin/controller/shipping/flat.php :
class ControllerShippingFlat extends Controller {
to something new like :
class ControllerShippingFlatDuplicate extends Controller {
It's posible, but in my opinion if you want to create a new "admin page" in your Opencart you can do it using vqmod.
so, you don't have to rewrite any core file.
you can donwload any free extension on the opencart website to take an example
You can simply duplicate some simple modules available in opencart admin panel like Welcome module or Banner or Slideshow module.
This method will help you to disable the module or change the position of content in future.
Duplicating opencart module tutorial : http://opencart.hostjars.com/blog/58
As a beginner it's better to duplicate an existing module and modifying it as per requirement. When you get the idea of how opencart modules work, you can build modules from scratch.
Yes, it is pretty safe and sound to duplicate a module in opencart and it is a bit logical with any of the cms as no one is going to create a module from scratch for a very little functionality like inserting some values to database.
As depicts you just want to insert some images links, so you can proceed with replicating the catalog / information functionality in opencart admin panel.
You just need to create a new table in database to store new modules data and fetching new module data in front end.
If you want to create a custom module or custom page for your store you can check below link. There is complete solutions for your question and describe very deeply.
Create custom module: http://www.php-dev-zone.com/2015/02/opencart-custom-module-development.html

Sugarcrm : modify actions on Dashlet quickEdit button

I have a very specific question on Sugarcrm.
I'm using version Enterprise 6.5.16, and i'm coming to a dead-end.
What i currently have :
When the user is on his homepage, he has a Dashlet called "My open Cases", which displays every open Cases assigned to/or created by him.
For each row of this dashlet, we have a quickEdit icon displayed. (you know, the little pen).
When the user clicks on that little icon, it opens the quickcreate (or quickedit?) popup.
What i want to achieve is :
I want, when the user clicks on the icon, that Sugar does not open a popup, but opens a new browser tab on EditView.
So basically, when on Home, when the user wants to edit "Case01--Issue" from the dashlet, instead of poping the quickcreate (or quickedit) form, i want to open a new browser tab with the complete edit view of "Case01 -- Issue".
What do i have to do? I did not see the definition of the icon in custom/modules/Cases/metadata/dashletviewdefs.php nor elsewhere.
Thanks by advance for your help and time!
Gaƫlle
The "My Cases" dashlet, and most dashlets, extend the DashletGeneric class, found in /include/Dashlets/DashletGeneric.php. This uses the template file DashletGenericDisplay.tpl in the same directory, and this is the template that displays the quick edit button.
To remove or alter the quick edit button, you would extend My Cases and insist that it use a custom smarty template of your own creation. In /custom/modules/Cases/Dashlets/CustomMyCasesDashlet/CustomMyCasesDashlet.php you might have the following:
<?php
require_once('modules/Cases/Dashlets/MyCasesDashlet/MyCasesDashlet.php');
class CustomMyCasesDashlet extends MyCasesDashlet{
$displayTpl = 'custom/modules/Cases/Dashlets/CustomMyCasesDashlet/CustomMyCasesDashlet.tpl';
}
You would then copy the original template to the new file and location referenced by CustomMyCasesDashlet::displayTpl and adjust as desired.
For your Dashlet to register correctly with the system, you'll also need your CustomMyCasesDashlet.meta.php file. Copy the original to your custom directory and adjust labels as necessary -- the key is to replace references to MyCasesDashlet with CustomMyCasesDashlet.
You should create your own dashlet (with copying existing one in "custom" folder), replace all standart entries to your own. Add copy of DashletGenericDisplay.tpl too and name it like CustomMyCasesDashlet.tpl.
It's not necessary to extend MyCasesDashlet class. You can leave "extends DashletGeneric".
In constructor function CustomMyCasesDashlet() just add the line:
$this->displayTpl = 'custom/modules/Cases/Dashlets/CustomMyCasesDashlet/CustomMyCasesDashlet.tpl';
Pay attention to $this->. Its necessary to override DashletGeneric field.
Copy the file from modules/Cases/Dashlets/MyCasesDashlet/MyCasesDashlet.php and paste it to custom/modules/Cases/Dashlets/MyCasesDashlet/MyCasesDashlet
If you don't have Cases folder inside the custom directory, create one.
After copying the file, add a property to load your custom TPL file.
Default DashletGenericDisplay.tpl file located at include/Dashlets/
class MyCasesDashlet extends DashletGeneric {
var $displayTpl = "custom/modules/Cases/Dashlets/DashletGenericDisplay.tpl";

Log in form for Normal Users Only Drupal 7

Is there any way or how to start off to make a default log in form on drupal 7 applicable for normal users only? Administrators cannot log in in that log in form (I'll make a custom log in form for administrators, but that wasn't the issue here)
It was like,
http://mysite.com/user/
You see a log in form, ONLY normal users can log-in in that form.
Is there any way to do this any hints or clues where to start off first?
I've been here
https://drupal.org/node/1894620
Studied this
https://api.drupal.org/api/drupal/modules!node!node.api.php/function/hook_node_access/7
It doesn't seem right, or I just don't manage to applied it well.
I'm lost. Any help would be appreciated though.
I think the only solution is to copy the whole User-Login form (within its all submit- and validation-functions) in your own custom module.
You can start by looking up the form-array from the login-form.....
function mymodule_form_alter(&$form, $form_state, $form_id)
{
if ($form_id == 'user_login')
{
// The login form here...
print_r($form);
}
}
.... and copying this into a new hook_form(), implemented by your module.
Now you can alter the submit and validation of the form in the copy.
In the new validation function you can check for the correct User-Role.

Show custom text at "My personal information" page through plugin

I want to show some custom text at "My personal information" page in customer's account using a plugin in Prestashop. I have no idea how to do this?
Any help is much appreciated!
It is not possible to do it by a plugin or module, because prestashop is not providing any HOOK for that page / place.
But you can do it by a little work out there. I am considering you are using prestashop 1.5 , so lets work with that.
1) First create a cms page at admin and note its id. Lets consider its id is 10.
2) Now open the file override/controllers/front/IdentityController.php . In this class file create a function like below.
public function initContent()
{
parent::initContent();
$identityCmsPage = new CMS(10, $this->context->language->id_lang);
$this->context->smarty->assign('identityCmsPage', $identityCmsPage);
}
Now after that, open file at your themes folder themes/your theme/indentity.tpl
and display that cms page contents like
{$identityCmsPage->content}
and you will have that cms page contents there.
Note: This code is not tested and may have errors. Please adjust accordingly if you got any.