Post by jaynarayan » Thu Aug 31, 2017 4:54 pm

Hi,
I am new to opencart and trying to create custom theme using verson 3.All the tutorial i found on internet are for v2 and not working properly with v3. Please guide me.

Thanks.

Newbie

Posts

Joined
Thu Aug 31, 2017 3:38 pm

Post by jaynarayan » Thu Aug 31, 2017 8:10 pm

Found the solution with help of this link https://forum.opencart.com/viewtopic.p ... 13#p683903

steps worked for me(version 3.0.2.0 ):
1. Copy all the folder catalog/view/theme/default to catalog/view/theme/THEMENAME

2. Create the files by copying the default theme files i.e.
./admin/language/en-gb/extension/theme/THEMENAME.php (other languages too if needed)
./admin/view/template/extension/theme/THEMENAME.twig
./admin/controller/extension/theme/THEMENAME.php
as the respective default theme files

-> replacing theme_default with theme_THEMENAME, heading title on all 3 files etc

->search and replace theme/default to theme/THEMENAME in ./admin/controller/extension/theme/THEMENAME.php

->change href of css link in header.twig file
from
<link href="catalog/view/theme/default/stylesheet/stylesheet.css" rel="stylesheet">
to
<link href="catalog/view/theme/THEMENAME /stylesheet/stylesheet.css" rel="stylesheet">

3. You can now go to Extensions- Extensions Filter Themes and see your new Theme. Enable, choose the directory you uploaded at in step 1 and set all the parameters necessary and save.

4. You can now go to System Settings edit your store(s) and select the NEWTHEME.

You should now be seeing your new theme (assuming client/server caches are set to renew).

5. Now you can create your themeby changing css or template files or any other file to suite your need .

Newbie

Posts

Joined
Thu Aug 31, 2017 3:38 pm

Post by archaeopteryx » Mon Oct 02, 2017 10:50 am

I've been having one hellofa time understanding / making this work. I'm going to try and clarify this as i do it and hopefully help others out in the process... Hopefully they'll catch up on the docs for 3.x soon...

1. Duplicate the default theme

Code: Select all

<install_dir>/catalog/view/theme/default

To my own theme folder

Code: Select all

<install_dir>/catalog/view/theme/MyTheme
2. Modify stylesheet link in header.twig

Code: Select all

# <install_dir>/catalog/view/theme/MyTheme/template/common/header.twig
...
<link href="catalog/view/theme/default/stylesheet/stylesheet.css" rel="stylesheet">
...
# Becomes
...
<install_dir>/catalog/view/theme/MyTheme/template/common/header.twig
...
3. Duplicate the 3 default theme's extension files...

Code: Select all

<install_dir>/admin/language/en-gb/extension/theme/default.php
<install_dir>/admin/view/template/extension/theme/default.twig
<install_dir>/admin/controller/extension/theme/default.php

...to create my new theme's extension files

Code: Select all

<install_dir>/admin/language/en-gb/extension/theme/MyTheme.php
<install_dir>/admin/view/template/extension/theme/MyTheme.twig
<install_dir>/admin/controller/extension/theme/MyTheme.php
4. Edit MyTheme.php (in language)

Code: Select all

#<install_dir>/admin/language/en-gb/extension/theme/MyTheme.php
#
# Here I want to replace all references to 'default theme' with 'My Theme'
# I see that this isn't all that necessary but for clarity I will make sure any messages / errors / etc 
# Relating to My Theme reflect 'My Theme' instead of 'Default Theme'
# Here are the 4 occurrences 
...
$_['heading_title'] = 'My Theme';
...
$_['text_success'] = 'Success: You have modified My Theme!';
$_['text_edit'] = 'Edit My Theme';
...
$_['error_permission'] = 'Warning: You do not have permission to modify My Theme!';
5. Edit MyTheme.twig (in templates)

Code: Select all

# <install_dir>/admin/view/template/extension/theme/MyTheme.twig
# Here's where it gets confusing. The original post says to replace theme_default... 
# there are 48 occurrences  in this template. 
# My gut tells me to not mess with the <select> tags 'name' attribute 
# (which is where these all occur) and if they wanted me to they would 
# have said 'replace default_theme_*' or the like...
# On the other hand, there is no other occurrence of default_theme anywhere else 
# in this file. I will leave alone for now and if it doesn't work i'll come back to this.
6. search and replace theme/default to theme/MyTheme

Code: Select all

# <install_dir>/admin/controller/extension/theme/MyTheme.php
# There are 5 occurrences
...
$this->load->language('extension/theme/MyTheme');
...
'href' => $this->url->link('extension/theme/MyTheme', 'user_token=' . $this->session->data['user_token'] . '&store_id=' . $this->request->get['store_id'], true)
...
$data['action'] = $this->url->link('extension/theme/MyTheme', 'user_token=' . $this->session->data['user_token'] . '&store_id=' . $this->request->get['store_id'], true);
...
$this->response->setOutput($this->load->view('extension/theme/default', $data));
...
if (!$this->user->hasPermission('modify', 'extension/theme/MyTheme')) { ...
7. Got to admin web interface to enable the theme
You can now go to Extensions- Extensions Filter Themes and see your new Theme. Enable, choose the directory you uploaded at in step 1 and set all the parameters necessary and save.
Ok, I see my theme in Extensions > Extensions > Filter=themes but when I try to enable it I get "internal server error"
I need to find out how to get better errors and turn on debuging / find where the logs are stored. I'll be back once I get that figured out... I'll also try changing those 48 occurrences of default_theme_* to MyTheme_* and get back to you.

Newbie

Posts

Joined
Mon Oct 02, 2017 9:21 am

Post by rupalip » Wed Oct 25, 2017 1:45 pm

I have tired the above solution, But in the extensions part when I select the custom theme and edit it a form opens, in which all the input are "theme_default_ " where it should be "theme_customTheme_", inspite of changing it same in the twig file created in the extensions/theme/customtheme.twig


Please reply, help me find the solution,
Thanks.

Newbie

Posts

Joined
Wed Oct 25, 2017 1:41 pm

Post by steve_sobol » Mon Jan 29, 2018 10:07 am

About that internal server error... I also saw it when enabling my theme

I checked my logs...

[Sun Jan 28 17:51:14.415304 2018] [php7:error] [pid 33696:tid 1172] [client 127.0.0.1:51378] PHP Fatal error: Uncaught Error: Class 'Controllerextensionthemebamidbar' not found in D:\\data\\sw\\bamidbarconnect\\shop\\system\\engine\\action.php:71

You have to update the class name in the controller you copied from the default

In my case, that entailed changing the name ControllerExtensionThemeDefault to ControllerExtensionThemeBamidbar fixed the problem; bamidbar is my theme's name.

Newbie

Posts

Joined
Mon Jan 29, 2018 9:10 am

Post by steve_sobol » Mon Jan 29, 2018 12:06 pm

Also, in the post linked to from this one, there are instructions
as the respective default theme files and replacing theme_default with theme_THEMENAME, heading title on language files etc
There was a question from a commenter about which items needed to be renamed to theme_THEMENAME - I did a global search/replace of all occurrences of theme_default in the three files in the admin/ directory. That seems to have worked.

Newbie

Posts

Joined
Mon Jan 29, 2018 9:10 am

Post by lindsey80 » Wed Feb 28, 2018 6:00 am

steve_sobol wrote:
Mon Jan 29, 2018 10:07 am
About that internal server error... I also saw it when enabling my theme

I checked my logs...

[Sun Jan 28 17:51:14.415304 2018] [php7:error] [pid 33696:tid 1172] [client 127.0.0.1:51378] PHP Fatal error: Uncaught Error: Class 'Controllerextensionthemebamidbar' not found in D:\\data\\sw\\bamidbarconnect\\shop\\system\\engine\\action.php:71

You have to update the class name in the controller you copied from the default

In my case, that entailed changing the name ControllerExtensionThemeDefault to ControllerExtensionThemeBamidbar fixed the problem; bamidbar is my theme's name.
After looking into these posts, I thought this had solved my issue and it now appears in my store to select the template, but when I go to extensions>extensions and select the template and update the fields I get this appear at the top of the page.

Notice: Undefined index: theme_default_product_limit in /home/stgiftsc/public_html/test/admin/controller/extension/theme/lindsey.php on line 335Notice: Undefined index: theme_default_product_description_length in /home/stgiftsc/public_html/test/admin/controller/extension/theme/lindsey.php on line 339Notice: Undefined index: theme_default_image_category_width in /home/stgiftsc/public_html/test/admin/controller/extension/theme/lindsey.php on line 343Notice: Undefined index: theme_default_image_thumb_width in /home/stgiftsc/public_html/test/admin/controller/extension/theme/lindsey.php on line 347Notice: Undefined index: theme_default_image_popup_width in /home/stgiftsc/public_html/test/admin/controller/extension/theme/lindsey.php on line 351Notice: Undefined index: theme_default_image_product_width in /home/stgiftsc/public_html/test/admin/controller/extension/theme/lindsey.php on line 355Notice: Undefined index: theme_default_image_additional_width in /home/stgiftsc/public_html/test/admin/controller/extension/theme/lindsey.php on line 359Notice: Undefined index: theme_default_image_related_width in /home/stgiftsc/public_html/test/admin/controller/extension/theme/lindsey.php on line 363Notice: Undefined index: theme_default_image_compare_width in /home/stgiftsc/public_html/test/admin/controller/extension/theme/lindsey.php on line 367Notice: Undefined index: theme_default_image_wishlist_width in /home/stgiftsc/public_html/test/admin/controller/extension/theme/lindsey.php on line 371Notice: Undefined index: theme_default_image_cart_width in /home/stgiftsc/public_html/test/admin/controller/extension/theme/lindsey.php on line 375Notice: Undefined index: theme_default_image_location_width in /home/stgiftsc/public_html/test/admin/controller/extension/theme/lindsey.php on line 379

Does anyone know why this is happening and how it can be fixed so that it saves what I'm inputting.

Many thanks in advance

Newbie

Posts

Joined
Fri Feb 02, 2018 9:57 pm

Post by domiiniic1990 » Wed Apr 18, 2018 4:44 am

Hey guys im having this same issue tho. Notice: Undefined index: theme_fantasy_product_limit in...... working on it for 2 days now :-[ anyone know the solution ?

Newbie

Posts

Joined
Wed Apr 18, 2018 4:42 am

Post by sudhakare18 » Wed May 09, 2018 7:28 pm

/admin/language/en-gb/extension/theme/
I try to do custom theme in opencart, I have seen some tutorial in that they coping the default theme and renaming some file and title, They showed this directory (/admin/language/en-gb/extension/theme/default.php, ./admin/view/template/extension/theme/default.twig, ./admin/controller/extension/theme/default.php) but in my opencart root folder there is no such folder in my root directory.

How to get the files.

Please help me,
Thank You

Newbie

Posts

Joined
Wed May 09, 2018 7:22 pm

Post by gerya » Thu May 17, 2018 6:08 am

I had same problem with undefined index with new theme inputs name, It's solved when I disabled caching. There is a a gear on the admin dashboard. Click the gear and you get options to disable caching.

Attachments

disable_cashe.png

disable_cashe.png (103.06 KiB) Viewed 5210 times


Newbie

Posts

Joined
Thu May 17, 2018 6:02 am

Post by kevxcs » Wed May 23, 2018 10:36 pm

Hi all,

I've been having the undefined index errors which has been resolved by replacing all instances of "default" in admin/view/template/extension/theme/my_theme.twig with "my_theme" (obviously it should be whatever you've used for your theme name).

I noticed that there's a test on line 35:
{% if directory == theme_default_directory %}
which is going to fail since it should be
{% if directory == theme_my_theme_directory %}

Looking further into the file all the input box names are theme_default_blah_blah_blah so it makes to change them all to whatever your theme name is.

It's worth mentioning that I did turn off caching first.

Newbie

Posts

Joined
Wed May 23, 2018 10:23 pm

Post by Fabienlolo » Thu Aug 09, 2018 12:45 am

Hi guys,
first post of that topic and previous post (by kevxcs » Wed May 23, 2018 2:36 pm) made it complete for me, just as covered by the following video https://www.youtube.com/watch?v=mqTstomXZiM. This video tutorial is almost 100% step by step but you might have to use common sense sometime as for example the "admin/view/template/extension/theme/MYTHEME.twig" file changes, line 128. I changed 'default' to 'MYTHEME' and everything works fine so far. O0

New member

Posts

Joined
Fri Jun 29, 2018 7:24 am
Location - Q.Roo, Mexico
Who is online

Users browsing this forum: No registered users and 10 guests