Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Addon] Generic Box


kymation

Recommended Posts

It's possible. You need to make a copy of the files and rename them. Then use your editor's search-and-replace to:

 

1. Change all instances of bm_generic to the name of your new box.

 

2. Change all instances (Case Sensitive!) of _GENERIC_ to match your new name.

 

You might also want to change the name in the language file so you can keep the new box separate from the original.

 

Regards

Jim

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

Link to comment
Share on other sites

Well, it's the oddest thing...

 

Wanna replicate it? try re-ordering all the other boxes using 2-digit numbers, instead of the default 4-digit.

 

I really don't know why, but when I've done this (use 2-digits order numbers) I get the error message, re-order everything using 4-digits again and the problem solves by itself...

 

I've done this in 2 different pages, with the same causes/results/fix; you should check it yourself.

 

Great add-on by the way, thank you very much for sharing it with us.

 

Kindest regards.

 

I've heard of this error before, but I've never been able to duplicate it. Whatever the problem is, it's nothing to do with what the error message says. I would have to try to track it down with whatever debugging tricks I can manage. Without having the error in the code on my server to do this, it's just not happening. Sorry.

 

Regards

Jim

Link to comment
Share on other sites

I tried that, and still don't get an error message. I even tried setting all of the boxes' sort order to 0. My copy just works. I suspect this may have something to do with the version of PHP, or possibly a server setting.

 

If using 4-digit numbers works for you, then maybe it will help others as well, so thank you very much for posting that.

 

Regards

Jim

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

Link to comment
Share on other sites

  • 2 weeks later...

Hello, this contribution is excellent,

but I have the following error: Fatal error: Can not redeclare class language in C: \ wamp \ www \ 01-boutic_rc231_en_dev \ includes \ classes \ language.php on line 16.

When I install the module in admin all goes well, and on the main page when I update the browser, boxe appears, but if I click on the logo to reload the index page, I have nothing more: blank page.

Have you a fix for this, I see that I am not alone with this error.

Thank you for this job

Francois

 

Excuse my bad English, I'm in France and I do not speak very good English.

Link to comment
Share on other sites

New explain

 

Hello and thank you for your help.

 

This contrib is really easy to install in its original version, there are 2 files

catalog / includes / languages ​​/ english / modules / boxes / bm_generic.php

catalog / includes / modules / boxes / bm_generic.php

 

From my side, I put

catalog / includes / languages ​​/ french / modules / boxes / bm_generic.php by translating the English file (2 lines).

 

All is installed.

Now I change the admin name Français language became french and Anglais became english

 

The module is going well and

if I go to my index page by entering the address http://localhost/01-boutic_rc231_en_dev/index.php?language=fr'>http://localhost/01-boutic_rc231_en_dev/index.php?language=fr

boxe appears in its place without problem.

If I click on the logo it reload the index page and I have nothing ==> blank page

the page address is = http://localhost/01-boutic_rc231_en_dev/index.php

 

are missing ?language=fr

ditto in English, if I enter the address http://localhost/01-boutic_rc231_en_dev/index.php?language=en

boxing is well and the site in English, if refresh nothing and adress = http://localhost/01-boutic_rc231_en_dev/index.php

missing ?language=en

 

Francois

 

Excuse my bad English, I'm in France and I do not speak very good English.

Link to comment
Share on other sites

Hello thank's for response

 

Everything works when I disable the language Boxe

 

An idea of why?

I tried with all the other boxes and everything works.

 

there was a dispute between language boxe and generic boxe .

 

Francois

Link to comment
Share on other sites

Hello

Yes I did what you suggested.

It is through this that I saw that generic_boxe not working when I turn on language_boxe.

I do not know what to do more.

Thank you for your help

Francois

Link to comment
Share on other sites

Hello

I think this piece of code is a problem for me

 

include_once( DIR_WS_CLASSES . 'language.php' );

$language_class = new language;

$languages = $language_class->catalog_languages;

 

foreach( $languages as $language ) {

$this->languages_array[$language['id']] = $language['name'];

}

 

unset($language_class);

unset($languages);

unset($language);

 

if I leave it during the intallation of the module in admin

all is good in admin side, so I can enter text in different languages in the textarea title and content.

In the client side if the language_boxe is "on" result = blank page.

so, after installing

if I open the file bm_generic and I delete this piece of code without uninstall everything in admin,

everything is ok and I can activate language_boxe in the client side

 

All is good i can go on every page in french or english, no problem

 

But in admin, if this piece of code is delete, i can't change texte and title because in the admin of my boxe there is no textarea.

 

how to change this code to work in client side and admin side.

 

Thank you

Link to comment
Share on other sites

Find this code in catalog/includes/application_top.php:

   include(DIR_WS_CLASSES . 'language.php');

and change it to:

   include_once(DIR_WS_CLASSES . 'language.php');

Does the generic box now work with the original code?

 

Regards

Jim

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

Link to comment
Share on other sites

I still can't reproduce this error, so I'm limited to guesswork. I'll post if I come up with any more guesses.

 

Regards

Jim

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

Link to comment
Share on other sites

Thank's for your help.

My excuses!!

 

On my version I have some addon, but they are not language incidence.

 

On a fresh french version, all is ok in hall language with your box.

I try to know what addon is responsable and I post here

 

Francois

Link to comment
Share on other sites

Find this code in catalog/includes/application_top.php:

   include(DIR_WS_CLASSES . 'language.php');

and change it to:

   include_once(DIR_WS_CLASSES . 'language.php');

Does the generic box now work with the original code?

 

Regards

Jim

 

I'm also running a dual-language site, and I was having the same problem as refered to several times in this topic: "Fatal error: Cannot redeclare class language in .../includes/classes/language.php on line 16"

 

Tried the change in the language.php file as proposed above as well, but didn't work.

 

As with francois21 the problem disappears when I disable the language box.

Also tried his removal of several lines of code from bm_generic.php. The problem was actually already solved when I just removed the first two lines of the piece of code francois posted:

include_once( DIR_WS_CLASSES . 'language.php' );
	  $language_class = new language;

 

But of course, that's not really working on the admin side when you want to edit the content of your box.

 

So, php-noob as I am, I went looking for the cause and solutions of this type of fatal error and found out that it's usually solved by first checking whether a class is declared or not. So, that's what I did:

 

 if (!class_exists('language')) {
     include_once( DIR_WS_CLASSES . 'language.php' );
	  $language_class = new language;
     $languages = $language_class->catalog_languages;

     foreach( $languages as $language ) {
       $this->languages_array[$language['id']] = $language['name'];
     }

     unset($language_class);
     unset($languages);
     unset($language);
   }
 }

(added the first and last line to existing code in bm_generic.php)

 

And presto! Everything seems to work fine. Maybe later versions of php don't complain about declaring classes twice, which might explain why some people are getting this error while others don't.

As I know just enough of php to tweek things a bit now and than, but nothing near the level of writing my own script, I'm not sure whether the above solution is actually a good one, or whether ther're implications I'm not able to foresee.

 

For the moment I'm happy, for I've got my generic box.

 

Thanks for your work! Great job. Very useful module.

Edited by Silverfish
Link to comment
Share on other sites

Ok... ignore the above.

 

The problem wasnt solved by the solution I just posted. I was working in two files at the same time and got a bit confused with what change caused what...

 

What did work in the end was simply editing the language.php file from:

 

class language {
 var $languages, $catalog_languages, $browser_languages, $language;

to

if (!class_exists('language')) {
class language {
 var $languages, $catalog_languages, $browser_languages, $language;

dont forget to close the if at the end of the file.

 

Shows how much of a noob i actually am.. ;) (is that why they dont let you edit your posts after a certain amount of time? ;))

Edited by Silverfish
Link to comment
Share on other sites

Ideally, every class and every function should be tested before it is declared. This would prevent a lot of errors from duplicate classes/methods/functions. So what you did is good coding practice and won't cause any problems.

 

What puzzles me is that the Generic Box is not declaring the class twice. That include_once() should mean that the class is only included if it doesn't already exist. This is the equivalent of what you are doing with class_exists(). Apparently this does not actually work in some cases, although it does on every server I have tested it on.

 

You could also try using your class_exists() in the Generic Box code to detect the language. Something like this:

global $language;
if (!class_exists('language')) {
     include_once( DIR_WS_CLASSES . 'language.php' );
}

 

Regards

Jim

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

Link to comment
Share on other sites

So I tried your suggestion as well. Then I got this message:

 

Fatal error: require() [function.require]: Failed opening required 'includes/languages/Array.php' (include_path='.:/usr/local/lib/php') in ../includes/application_top.php on line 279

 

I removed your line and tested the website again before moving the class_exists() back into the language.php file.

 

But I didnt have to do the last step for everything worked fine now without class_exists()!

 

I did change the order of the boxes in the meantime, so it might be related to that after all. All very puzzling...

Edited by Silverfish
Link to comment
Share on other sites

Good evening

I uninstall the add on I had and reinstall everything.

With the fix of Silverfish ,everything works well in all languages.

 

editing the language.php file from:

 

class language { var $languages, $catalog_languages, $browser_languages, $language;

 

to

 

if (!class_exists('language')) {class language { var $languages, $catalog_languages, $browser_languages, $language;

 

 

dont forget to close the if at the end of the file.

 

 

Thank you

Link to comment
Share on other sites

i have installed this box and its working very well. however i have been trying to link to the category that my image displays. but it dosnt work. it dosnt even change from the default link.

 

i do know that i had the same problem with the header and content until i had installed the update.

 

has anyone else had the same problem and can anyone help

 

thanks

graham

Link to comment
Share on other sites

Are you linking from the title of the box or the contents? What is your link? Copy and paste the link text here.

 

Regards

Jim

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

Link to comment
Share on other sites

at the moment there is not a link entered in the content link. i am trying to place a content link to the category that suits. but this is the link that is there no matter what i seem to do.

 

http://vanity-flair-uk.com/MODULE_BOXES_GENERIC_CONTENT_LINK

 

it comes up with page 404 not found for obvious reasons.

 

like i said there is no link entered and even when i enter a link it dosnt change.

Link to comment
Share on other sites

Try this: In catalog/include/modules/bm_generic.php, find this line (TWO places):

        if( tep_not_null( MODULE_BOXES_GENERIC_CONTENT_LINK ) ) {

and replace it with:

        if( defined( MODULE_BOXES_GENERIC_CONTENT_LINK  && tep_not_null( MODULE_BOXES_GENERIC_CONTENT_LINK ) ) {

Regards

Jim

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

Link to comment
Share on other sites

thanks for your help jim. i seem to have sorted the problem in a way. i have managed to deleted some php and got rid of the link all together. the replacement code you gave me did not work it kept coming up with an error on line 73. cant remember it exactly but at least it works now.

 

thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...