Page 1 of 1

Starter Module

Posted: Mon May 20, 2019 10:15 pm
by settysantu
Using starter module you can create you own modules, it works like skeleton. You can also clone on Github or download from here https://www.opencart.com/index.php?rout ... n_id=36876

If i create full starter kit with all fields will it help? let me know

Re: Starter Module

Posted: Tue May 21, 2019 12:01 am
by webshop
I am trying to add an option Enable or Disable in this module

I inserted in admin/controller/extension/module/starter_module.php following code

Code: Select all

		if (isset($this->request->post['new'])) {
			$data['new'] = $this->request->post['new'];
		} elseif (!empty($module_info)) {
			$data['new'] = $module_info['new'];
		} else {
			$data['new'] = '';
		}
in admin/view/template/extension/module/starter_module.twig the following

Code: Select all

<div class="form-group">
            <label class="col-sm-2 control-label" for="input-new">new</label>
            <div class="col-sm-10">
              <select name="new" id="input-new" class="form-control">
                {% if new %}
                <option value="1" selected="selected">{{ text_enabled }}</option>
                <option value="0">{{ text_disabled }}</option>
                {% else %}
                <option value="1">{{ text_enabled }}</option>
                <option value="0" selected="selected">{{ text_disabled }}</option>
                {% endif %}
              </select>
</div>
in catalog/view/theme/default/template/extension/module/starter_module.twig the code from below
Here I want to display one text ex: Enabled if is enabled and False if is false, in this way is not working, please help me, what I missed.

Code: Select all

     {% if new == text_enabled %}
	Enabled
        {% else %}
	 False
        {% endif %}
   
Please admin don't delete, I hope it is in the right category

Re: Starter Module

Posted: Tue May 21, 2019 12:35 am
by settysantu
In catalog/view/theme/default/template/extension/module/starter_module.twig just use this

Code: Select all

{% if new %}
	Enabled
        {% else %}
	 False
        {% endif %}

Re: Starter Module

Posted: Tue May 21, 2019 12:37 am
by settysantu

Code: Select all

     {% if new %}
	Enabled
        {% else %}
	 False
        {% endif %}
   
Just remove == text_enabled

Re: Starter Module

Posted: Tue May 21, 2019 12:43 am
by webshop
If is enabled or disabled the result always is False, I need to add any code in catalog/controller as well?

Re: Starter Module

Posted: Tue May 21, 2019 12:45 am
by settysantu
webshop wrote:
Tue May 21, 2019 12:43 am
If is enabled or disabled the result always is False, I need to add any code in catalog/controller as well?
Can you share your full code? you have github?

Re: Starter Module

Posted: Tue May 21, 2019 12:52 am
by webshop
I just added the admin controller and admin/view file into admin folder and in the catalog folder is the catalog/view..twig.
https://github.com/bblori/Opencart3

Re: Starter Module

Posted: Tue May 21, 2019 1:18 am
by settysantu
webshop wrote:
Tue May 21, 2019 12:52 am
I just added the admin controller and admin/view file into admin folder and in the catalog folder is the catalog/view..twig.
https://github.com/bblori/Opencart3
I can't find controller file in catalog folder? you need to add this code

Code: Select all

 $data['new'] = (int)$setting['new'];

Re: Starter Module

Posted: Tue May 21, 2019 1:45 am
by webshop
I added, could you check please now I got Notice: Undefined index: new in

Finally I managed to set up, with your module, thank you

Re: Starter Module

Posted: Tue May 21, 2019 9:47 am
by settysantu
webshop wrote:
Tue May 21, 2019 1:45 am
I added, could you check please now I got Notice: Undefined index: new in

Finally I managed to set up, with your module, thank you
Can you share full error message? btw if you want you can use this carousel module https://www.opencart.com/index.php?rout ... n_id=32751

Re: Starter Module

Posted: Thu May 23, 2019 5:29 am
by webshop
Hi,

I trying to return into header page this " new " variable which was set in your starter module, how can do that, could you help me?

$data['new'] = (int) $setting['new'];

Re: Starter Module

Posted: Thu May 23, 2019 10:01 am
by settysantu
webshop wrote:
Thu May 23, 2019 5:29 am
Hi,

I trying to return into header page this " new " variable which was set in your starter module, how can do that, could you help me?

$data['new'] = (int) $setting['new'];
You need do it with catalog/controller/common/header.php

Re: Starter Module

Posted: Thu May 23, 2019 6:32 pm
by webshop
I know, If I setup everything in admin/controller/setting and admin/view/...setting.twig files, in that case is working the variable in the catalog/..header as well you can see how I made here https://github.com/bblori/Enable-Style-OC3

But I want to set everything in starter extension to work with header.

Many thanks for reading