Post by settysantu » Mon May 20, 2019 10:15 pm

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

User avatar
New member

Posts

Joined
Mon Jan 03, 2011 11:59 am
Location - Hyderabad, India

Post by webshop » Tue May 21, 2019 12:01 am

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

Newbie

Posts

Joined
Mon May 20, 2019 11:42 pm

Post by settysantu » Tue May 21, 2019 12:35 am

In catalog/view/theme/default/template/extension/module/starter_module.twig just use this

Code: Select all

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

User avatar
New member

Posts

Joined
Mon Jan 03, 2011 11:59 am
Location - Hyderabad, India

Post by settysantu » Tue May 21, 2019 12:37 am

Code: Select all

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

User avatar
New member

Posts

Joined
Mon Jan 03, 2011 11:59 am
Location - Hyderabad, India

Post by webshop » 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?

Newbie

Posts

Joined
Mon May 20, 2019 11:42 pm

Post by settysantu » Tue May 21, 2019 12:45 am

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?

User avatar
New member

Posts

Joined
Mon Jan 03, 2011 11:59 am
Location - Hyderabad, India

Post by webshop » 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

Newbie

Posts

Joined
Mon May 20, 2019 11:42 pm

Post by settysantu » Tue May 21, 2019 1:18 am

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'];

User avatar
New member

Posts

Joined
Mon Jan 03, 2011 11:59 am
Location - Hyderabad, India

Post by webshop » 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

Newbie

Posts

Joined
Mon May 20, 2019 11:42 pm

Post by settysantu » Tue May 21, 2019 9:47 am

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

User avatar
New member

Posts

Joined
Mon Jan 03, 2011 11:59 am
Location - Hyderabad, India

Post by webshop » 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'];

Newbie

Posts

Joined
Mon May 20, 2019 11:42 pm

Post by settysantu » Thu May 23, 2019 10:01 am

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

User avatar
New member

Posts

Joined
Mon Jan 03, 2011 11:59 am
Location - Hyderabad, India

Post by webshop » Thu May 23, 2019 6:32 pm

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

Newbie

Posts

Joined
Mon May 20, 2019 11:42 pm
Who is online

Users browsing this forum: No registered users and 30 guests