Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

2334BS - Theme Switcher


Recommended Posts

what 'Theme Switcher' are you referring to ?

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

No, that one only works with the jQuery UI themes in stock osCommerce. I need to build a new Theme Switcher for Bootstrap. You also need to use Bootstrap themes with 2334BS.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

@@ArtcoInc

 

Search the bootstrap thread there was a link there somewhere to a bootstrap theme builder I think from WhiteHat not sure but interesting site obviously not a themeswitcher but interesting

To improve is to change; to be perfect is to change often.

 

Link to comment
Share on other sites

  • 1 month later...

And now we have a Theme Switcher for 2.3.3.4 Bootstrap. The themes are actually simpler than the jQuery UI themes, so this was not hard to do.

 

The code is available here.

 

This is still Beta code, but then so is Bootstrap on osCommerce, so please test carefully and report any bugs. There's no User's Manual yet, but anybody who has installed the existing Theme Switcher will have no problem with this one. I've tested it on the latest 2334BS running on PHP 5.3/MySQL 5.5, but it should run on any modern server. It's the same code as the current Theme Switcher with a few minor changes.

 

I've included 15 themes -- all of the free themes from Bootswatch. If you find another theme that you want to add, just create a folder in /ext/bootstrap/css/ named the same as your theme and drop your theme's bootstrap.min.css file in that folder. Theme Switcher will pick up that theme and show it as a selection in the Theme Switcher admin panel.

 

I'll make this a real Addon when 2334BS is released.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Hi Jim :)

Just had a bit time and thought I install your theme switcher for BS.

After installing and looking at the front end the left column (categories box) is not showing. Also all glyphicons are not showing.

To solve the column left issue i just reverted back to the original template_top.php and changed this

 

<!-- Bootstrap -->
 <link href="ext/bootstrap/css/bootstrap.min.css" rel="stylesheet">

 

to this

 

 <?php if (MODULE_HEADER_TAGS_THEME_SWITCHER_STATUS == false); { ?>
 <!-- Bootstrap -->
 <link href="ext/bootstrap/css/bootstrap.min.css" rel="stylesheet">
 <?php } ?>

 

Now if there is no theme switcher activated it shows the default theme if it is "true" it works with the other themes that you choose.

The template_top file that came with your package has the column left part removed that is why it didn't load and taking a closer look at the template_top.php file of yours

I couldn't really spot any major changes except that you removed the column and bootstrap.css part. So I thought changing only the above mentioned part should work. And it does so far...*fingerscrossed*

 

The other issue regarding the Icons, since the theme css file are one folder deeper down in the structure you need to adjust the paths inside the *theme*/bootstrap.min.css files

the original path is url('../fonts/glyphicons-halflings-regular.ttf') but it needs to be url('../../fonts/glyphicons-halflings-regular.ttf') so i just changed all glyphicon paths in each css file and the icons show just fine now.

 

Note:

Maybe should add some short description which explains where to look for the jquery and jquery UI versions. (I know where to look but some might not)
Also if there would be some kinda checker that confirms that the inserted jquery and jquery UI version is really there and available,
similar to "theme was found" (tick.gif), "template_top.php modified" (tick.gif), "language file found" (tick.gif)

 

The thing about switching the theme is that not "all" things change. Look at the footer area for example or the buttons. Gary warned me about it a while ago when I was trying to change the theme. After changing the theme you will have to amend some few things to have a perfect match.

 

Kind regards

Tsim
 

Link to comment
Share on other sites

You're right that the template_top.php doesn't work if the Theme Switcher module isn't installed. The original has the same problem. It usually doesn't matter, but for good coding practice I really should do something about that. Thanks for the code.

 

I didn't do anything to the left column. It's still there on my test site. However, the Custom and User stylesheets are now out of order, which could cause problems like that from improper cascading. I'll fix that.

 

I missed the icons. Maybe we should keep the themes at the same level as the css directory and not inside it. That would keep people from having to edit theme files, which is just nasty and would cause all kinds of problems.

 

I took out the checks for jQuery and jQuery UI, but I could just as well leave them in. Could still be useful. I can also leave the section of the User's Manual in that talks about where to get these files. They're no longer directly related to the theme, but there's nothing else to keep track of them.

 

The theme is not all-inclusive, but the same can be said of the jQuery UI theme. I wish it was. In any case, people will still have to fix those things the theme does not cover, or we find a way to theme the entire page. Someday....

 

Thanks a lot for the bug reports. I was trying to get this ready in time to release it at nearly the same time as the official osCommerce release. It's a handy tool to have.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

@@kymation

 

regarding the template_top.php, you're right your one is the original one I did some small changes that I didn't recall that is why mine didn't show the column left part.

If you could keep the themes in the same level would be great. The less people have to touch the files the better.

Link to comment
Share on other sites

OK, this seems to work. The updated package is here. Don't forget to move the themes up a level if you have the previous package installed.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

It still needs some cleanup. At least we have a working file to play with. Now to see if this stands up under use.

 

@@Tsimi  Thanks again for your help with testing.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

@@kymation

 

Hi Jim

 

The default osC BS comes with two additional css files. One is called custom.css and the other user.css.

When using the theme switcher both these files were ignored and not included, so amending those two files had no effect.

 

To include those two files I changed the following part of the code

$theme_text = '<link href="ext/bootstrap/' . $theme_name . '/bootstrap.min.css" rel="stylesheet">' . PHP_EOL;

to

$theme_text = '<link href="ext/bootstrap/' . $theme_name . '/bootstrap.min.css" rel="stylesheet">' . 
	      '<link href="custom.css" rel="stylesheet">' . 
	      '<link href="user.css" rel="stylesheet">';

I am not confident enough to say that THIS is the right solution, so I would appreciate if you could confirm this code change.

 

There are also two code pieces that i don't fully understand and if they have anything to do with the BS theme switcher.

Deactivating them with /* */ tags gives me an error message...so I guess they are somehow vital for this add-on to work?

////
	// Check whether includes/template_top.php has been modified/replaced
	if( !function_exists( 'tep_template_top_check' ) ) {
		function tep_template_top_check() {
			$filename = DIR_FS_CATALOG . DIR_WS_INCLUDES . 'template_top.php';
			if( file_exists( $filename ) ) {
				// Read the file into an array, one line per element
				$file_array = file( $filename );

				// Step through the files and check for a match with the selected version of the CSS file
				foreach ($file_array as $line) {
					// Check if the line matches one of the lines that should be removed
					if( trim( $line ) == '<link rel="stylesheet" type="text/css" href="ext/jquery/ui/redmond/jquery-ui-1.8.6.css" />' ||
					trim( $line ) == '<script type="text/javascript" src="ext/jquery/jquery-1.4.2.min.js"></script>' ||
					trim( $line ) == '<script type="text/javascript" src="ext/jquery/ui/jquery-ui-1.8.6.min.js"></script>' ) {
						// One or more lines exist, so return error and quit
						return tep_image( DIR_WS_ICONS . 'cross.gif', '', '16', '16', 'style="vertical-align:middle;"' ) . ' <span style="vertical-align:middle; font-weight:bold; color:red;">' . MODULE_HEADER_TAGS_THEME_SWITCHER_TEMPLATE_TOP_NOT_MODIFIED . '</span>' . $jquery_directory;
						break;
					}
				}

			} else {
				// The file was not found, so return an error
				return tep_image( DIR_WS_ICONS . 'cross.gif', '', '16', '16', 'style="vertical-align:middle;"' ) . ' <span style="vertical-align:middle; font-weight:bold; color:red;">' . MODULE_HEADER_TAGS_THEME_SWITCHER_TEMPLATE_TOP_NOT_MODIFIED . '</span>' . $jquery_directory;

			} // if( file_exists

			// The lines were not found in the file, so return a success message
			return tep_image( DIR_WS_ICONS . 'tick.gif', '', '16', '16', 'style="vertical-align:middle;"' ) . ' <span style="vertical-align:middle; font-weight:bold;">' . MODULE_HEADER_TAGS_THEME_SWITCHER_TEMPLATE_TOP . '</span>';
		} // function theme_check
	} // if( !function_exists  MODULE_HEADER_TAGS_THEME_SWITCHER_TEMPLATE_TOP_MODIFIED

and this one

////
	// Check whether the selected theme CSS file exists
	if( !function_exists( 'tep_theme_version_check' ) ) {
		function tep_theme_version_check() {
			// The jQuery UI directory is hard-coded in the rest of osC, so...
			$theme_directory = DIR_FS_CATALOG . 'ext/jquery/ui/' . MODULE_HEADER_TAGS_THEME_SWITCHER_THEME;

			if( file_exists( $theme_directory ) && is_dir( $theme_directory ) ) {
				// Get an array of all of the files in the theme directory
				$themes_array = tep_get_directory_list( $theme_directory );

				// Step through the files and check for a match with the selected version of the CSS file
				foreach( $themes_array as $theme_css ) {
					if( $theme_css == 'jquery-ui-' . MODULE_HEADER_TAGS_THEME_SWITCHER_JQUERY_UI_VERSION . '.min.css' ) {
						//The correct version exists, so return success and quit
						return tep_image( DIR_WS_ICONS . 'tick.gif', '', '16', '16', 'style="vertical-align:middle;"' ) . ' <span style="vertical-align:middle; font-weight:bold;">' . MODULE_HEADER_TAGS_THEME_SWITCHER_THEME_VERSION_FOUND . '</span>';
						break;
					}
				}

			} // if( file_exists

			// The jQuery file was not found, so return an error message
			return tep_image( DIR_WS_ICONS . 'cross.gif', '', '16', '16', 'style="vertical-align:middle;"' ) . ' <span style="vertical-align:middle; font-weight:bold; color:red;">' . MODULE_HEADER_TAGS_THEME_SWITCHER_THEME_VERSION_MISSING . '</span>' . $jquery_directory;
		} // function theme_check
	} // if( !function_exists

Could you please explain or clarify what the two code snippets above actually do? And if they also need to be changed to work correctly with BS.

 

Thanks and kind regards

Lambros

Link to comment
Share on other sites

@@Tsimi  The links to the custom.css and user.css are still in includes/template_top.php -- they were just moved down so they load after the theme.

 

That first chunk of code tests whether the changes to includes/template_top.php were made. It needs to be updated to check for the correct changes. It's not a very sophisticated test in any case; it could certainly be improved.

 

The second chunk of code was the test for the existence of the jQuery theme. It should be rewritten to check for the Bootstrap theme instead.

 

This whole thing was just a quick update of the existing Theme Switcher, and obviously I missed some of the necessary changes. I'll fix those as soon as I get some time. Which is not today.

 

Thanks for pointing out these bugs.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

@@kymation

 

 

Thanks for clarifying the other two chunks of code...just trying to get my head around this...to understand better how the theme switcher works and what still need to be done...thank you.

Link to comment
Share on other sites

Hi Jim

 

Me again....

 

I changed the ht_theme_switcher.php file and removed (deactivated) all the jquery and jquery UI stuff because BS does not use jquery or jquery UI based themes.

I couldn't figure out the purpose of the Check whether includes/template_top.php has been modified/replaced code for BS so I also deactivated it.

Now it is a very, very simple file with only the necessary functions for BS.

 

Amended as described few posts above the template_top.php, added the other two css files to the $theme_text part and deactivated all the jquery stuff by using the // tsimi tag.

I attached the file just in case you or someone else want to take a look at it.

 

 

 

P.S. i renamed it to Version 0.1.1 beta

Link to comment
Share on other sites

  • 8 months later...

I cleaned up the code and uploaded it to the Theme Switcher archive (link below). Thanks to @@Tsimi for finding some of the larger bugs. I hope that I got the rest of them. If I didn't, please post on the support thread and I'll fix it.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...