Forums / Upgrading to 1.5.x / Updating Mod for 150 - Little Problem

Updating Mod for 150 - Little Problem

Views: 7,490

Results 21 to 40 of 62
2 Apr 2012, 4:25 PM
#21
scriptjunkie avatar

scriptjunkie

Totally Zenned

Join Date:
Jul 2008
Posts:
772
Plugin Contributions:
0

Updating Mod for 150 - Little Problem

Ok, I found a tutorial at w3schools.com on how to write a PHP define.

The sample they provided looks simple enough:

<?php
define("GREETING","Hello you! How are you today?");
echo constant("GREETING");
?>

But here are my questions:

  1. Where do I put the define?
  2. How do I determine what the define's value should be?

I think that in order to understand what the define's value should be, I need to understand the logic behind the output (i.e. where will it appear so I can figure out what its supposed to say? what purpose is it serving?)

*Go that extra mile, you never know what's at the end of the road

* Empowerment Sanctuary

2 Apr 2012, 4:35 PM
#22
scriptjunkie avatar

scriptjunkie

Totally Zenned

Join Date:
Jul 2008
Posts:
772
Plugin Contributions:
0

Re: Updating Mod for 150 - Little Problem

A question about learning to interpret error messages:

How can I tell that the error message below is telling me that I'm missing a define? Is there something specific in there that points me in that direction, or does it just come with time and learning?

[31-Mar-2012 22:09:27]
PHP Warning:  include(includes/modules/FILENAME_RECENT_PRODUCTS_MODULE.php) [<a 
href='function.include'>function.include</a>]: failed to open stream: No such file or directory in 
/***/***/public_html/***/includes/templates/atestcustom/templates/tpl_modules_recent_products.php 
on line 12

[31-Mar-2012 22:09:27] 
PHP Warning:  include() [<a href='function.include'>function.include</a>]: Failed opening 
'includes/modules/FILENAME_RECENT_PRODUCTS_MODULE.php' for inclusion 
(include_path='.:/usr/lib/php:/usr/local/lib/php') in 
/***/***/public_html/***/includes/templates/atestcustom/templates/tpl_modules_recent_products.php on line 12

Note that I've already made the following changes, yet the error remains the same:

Changed includes/modules/FILENAME_RECENT_PRODUCTS_MODULE.php

to

includes/modules/FILENAME_RECENT_PRODUCTS.php

and

Changed line 12 of /includes/templates/atestcustom/templates/tpl_modules_recent_products.php from

include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_RECENT_PRODUCTS_MODULE));

to

include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_RECENT_PRODUCTS));

*Go that extra mile, you never know what's at the end of the road

* Empowerment Sanctuary

2 Apr 2012, 5:26 PM
#23
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Updating Mod for 150 - Little Problem

They usually go in a separate file.. Depending on the how it's being used in Zen Cart they could be in a language folder, a class folder, a functions folder, an extra datafiles folder or even an extra configures folder in Zen Cart.

Do a search through your store using the developers toolkit (search for "define(") to look for existing examples to see how you would construct one.

For Edit Orders there is one similar to what you are trying to do. From line 21 of admin/includes/extra_configures/edit_orders.php

define('FILENAME_ORDER_EDIT', 'edit_orders.php'); 
```Super Orders also uses a similar file to point links to the orders.php file

> **ScriptJunkie:**
>
> Ok, I found a tutorial at w3schools.com on how to write a PHP define.
> 
> The sample they provided looks simple enough:
> ```
<?php
define("GREETING","Hello you! How are you today?");
echo constant("GREETING");
?>
```But here are my questions:
> 
> 1. Where do I put the define?
> 2. How do I determine what the define's value should be?
> 
> I think that in order to understand what the define's value should be, I need to understand the logic behind the output (i.e. where will it appear so I can figure out what its supposed to say?  what purpose is it serving?)

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

2 Apr 2012, 7:21 PM
#24
scriptjunkie avatar

scriptjunkie

Totally Zenned

Join Date:
Jul 2008
Posts:
772
Plugin Contributions:
0

Re: Updating Mod for 150 - Little Problem

Warning: Post typed as I wandered through my thought process. Please bear with me :unsure:

Ohhhh I see....the define you listed below tells the code which file to look in. I think I get it now!

define('FILENAME_ORDER_EDIT', 'edit_orders.php');

So, I would write it this way:

define('FILENAME_RECENT_PRODUCTS', 'recent_products.php');

But, as you said...there are several folders I could place such a file in (or several files I could add the define to). How do I determine how the define is being used in Zen Cart in order to determine where to place it?

Since this mod has no class folder, no functions folder, no extra datafiles folder or an extra configures folder....How do I determine which of those is the best one to create for the new defines file?

:::thinking:::: the file that calls this define is the one referenced in the error log: includes/templates/custom_template/templates/tpl_modules_recent_products.php. The code from that file which actually calls the define (if I understand all this correctly), is:

include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_RECENT_PRODUCTS));

So....I'm guessing here....the above include is telling zen cart what the name of the module is? And the define statement is telling zen cart which file some of that mod's code is in?

Is that right? If so, I would think that adding the define statement to the language file would be appropriate?

Doing so would change language/english/extra_definitions/recent_products.php file from:

<?php

// recently viewed sidebox title name
  define('BOX_HEADING_RECENTLY_VIEWED', 'Recently Viewed');

?>

to

<?php

// recently viewed sidebox title name
  define('BOX_HEADING_RECENTLY_VIEWED', 'Recently Viewed');
  
// define file name  
  define('FILENAME_RECENT_PRODUCTS', 'recent_products.php'); 

?>

Is that right?

DivaVocals:

They usually go in a separate file.. Depending on the how it's being used in Zen Cart they could be in a language folder, a class folder, a functions folder, an extra datafiles folder or even an extra configures folder in Zen Cart.

Do a search through your store using the developers toolkit (search for "define(") to look for existing examples to see how you would construct one.

For Edit Orders there is one similar to what you are trying to do. From line 21 of admin/includes/extra_configures/edit_orders.php

define('FILENAME_ORDER_EDIT', 'edit_orders.php');

*Go that extra mile, you never know what's at the end of the road

* Empowerment Sanctuary

2 Apr 2012, 8:38 PM
#25
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Updating Mod for 150 - Little Problem

I can't say that what you posted WON'T work, but it's not the way I would do it..

I wouldn't put it in a language file because it's not a constant that is used to display text on screen anywhere (which is the purpose of the language files). If the constant being called is not part of a class or a function, then that's not where you'd put it either..

Eliminating all of these, the extra_datafiles is probably the place** I'D** put it as it's not a constant related to a configuration item I wouldn't use the extra_configures folder, but you'd be better off waiting for someone more knowledgeable than I to confirm this. (BTW, the word "extra" in the folder name is a HINT that these are extra files usually related to a something that expands current functionality. (Again, someone can correct me on that too, it's how I always interpreted these folder names)

ScriptJunkie:

Warning: Post typed as I wandered through my thought process. Please bear with me :unsure:

Ohhhh I see....the define you listed below tells the code which file to look in. I think I get it now!

define('FILENAME_ORDER_EDIT', 'edit_orders.php');

> 
> ```php
define('FILENAME_RECENT_PRODUCTS', 'recent_products.php');
```But, as you said...there are several folders I could place such a file in (or several files I could add the define to).  How do I determine how the define is being used in Zen Cart in order to determine where to place it?
> 
> Since this mod has no class folder, no functions folder, no extra datafiles folder or an extra configures folder....How do I determine which of those is the best one to create for the new defines file?
> 
> :::thinking::::  the file that calls this define is the one referenced in the error log: includes/templates/custom_template/templates/tpl_modules_recent_products.php. The code from that file which actually calls the define (if I understand all this correctly), is:
> 
> ```php
include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_RECENT_PRODUCTS));
```So....I'm guessing here....the above include is telling zen cart what the name of the module is?  And the define statement is telling zen cart which file some of that mod's code is in?
> 
> Is that right?  If so, I would think that adding the define statement to the language file would be appropriate?
> 
> Doing so would change  language/english/extra_definitions/recent_products.php file **from:**
> 
> ```php
<?php

// recently viewed sidebox title name
  define('BOX_HEADING_RECENTLY_VIEWED', 'Recently Viewed');

?>
```**to**
> 
> ```php
<?php

// recently viewed sidebox title name
  define('BOX_HEADING_RECENTLY_VIEWED', 'Recently Viewed');
  
// define file name  
  define('FILENAME_RECENT_PRODUCTS', 'recent_products.php'); 

?>
```Is that right?

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

2 Apr 2012, 9:16 PM
#26
scriptjunkie avatar

scriptjunkie

Totally Zenned

Join Date:
Jul 2008
Posts:
772
Plugin Contributions:
0

Re: Updating Mod for 150 - Little Problem

ahhhhh ok. I'll give that a shot and see if it works.

If not, I'll report back here and see what suggestions others might have.

And...as I've just realized that I completely forgot about final IH testing (SO SORRY), I'm going to go do that right now.

DivaVocals:

I can't say that what you posted WON'T work, but it's not the way I would do it..

I wouldn't put it in a language file because it's not a constant that is used to display text on screen anywhere (which is the purpose of the language files). If the constant being called is not part of a class or a function, then that's not where you'd put it either..

Eliminating all of these, the extra_datafiles is probably the place** I'D** put it as it's not a constant related to a configuration item I wouldn't use the extra_configures folder, but you'd be better off waiting for someone more knowledgeable than I to confirm this. (BTW, the word "extra" in the folder name is a HINT that these are extra files usually related to a something that expands current functionality. (Again, someone can correct me on that too, it's how I always interpreted these folder names)

*Go that extra mile, you never know what's at the end of the road

* Empowerment Sanctuary

3 Apr 2012, 12:26 AM
#27
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: Updating Mod for 150 - Little Problem

Should add there is a syntax error somewhere in

/includes/modules/recent_products.php

or at least thats what dreamweavers syntax checker tells me

apparently its the very last line, which tends to mean there is an errant brace or something somewhere above

I also get the above error id I add an extra datafile with this in it

define('FILENAME_RECENT_PRODUCTS_MODULE', 'recent_products.php');

I note you aren't using the MODULE bit, if i don't use that i just get the old error you mentioned

Webzings Design
Semi retired from Web Design

3 Apr 2012, 12:32 AM
#28
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Updating Mod for 150 - Little Problem

the extra_datafiles is probably the place I'D put it Not that I'm an expert on the filesystem either, but that makes the most sense to me. It would be "easier" to put all the defines in one (language) file for this small mod, but that wouldn't really be treating the different defines properly.

3 Apr 2012, 12:51 AM
#29
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: Updating Mod for 150 - Little Problem

/includes/modules/recent_products.php

bah humbug

has

14 {
11 }

no wonder there are syntax errors!!!

Webzings Design
Semi retired from Web Design

3 Apr 2012, 1:13 AM
#30
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: Updating Mod for 150 - Little Problem

Ok I think i may have it working, well sort of. I am still not sure I have added the braces in the correct places

and it is saying "featured products" rather than "recently viewed"

go here and have a look at various products and the recently viewed should appear both below and in the sidebox

http://grumpykiwi.com/

Webzings Design
Semi retired from Web Design

3 Apr 2012, 2:01 AM
#31
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: Updating Mod for 150 - Little Problem

Aha, I think it is working.

Webzings Design
Semi retired from Web Design

3 Apr 2012, 3:59 AM
#32
scriptjunkie avatar

scriptjunkie

Totally Zenned

Join Date:
Jul 2008
Posts:
772
Plugin Contributions:
0

Re: Updating Mod for 150 - Little Problem

nigelt74:

Aha, I think it is working.

Sounds like you were able to resolve the syntax errors?

Once I added the define to the extra_datafile, I got error logs indicating a syntax error on the last line of the file you mentioned in an earlier post. When I looked at the file, the last line was a blank line below the <?...so I deleted it.

THEN, it threw the same error message only this time, the last line is the <?

Grrr....it was a good time to set it aside and do the final IH testing, but after that life got crazed....this is the first chance I've had to come back to it.

Noticed, as you did, that there are references in the file to featured products. I think whoever wrote this mod (or perhaps someone who updated it at some point)...used similar code for inspiration and didn't make all the changes/corrections they should have.

ZC150 aside....looking at the code (and of course I know nothing about code)...but I just can't see how this particular mod would have worked with with ANY version of ZC due to the number of typos and syntax errors throughout.

*Go that extra mile, you never know what's at the end of the road

* Empowerment Sanctuary

3 Apr 2012, 4:07 AM
#33
scriptjunkie avatar

scriptjunkie

Totally Zenned

Join Date:
Jul 2008
Posts:
772
Plugin Contributions:
0

Re: Updating Mod for 150 - Little Problem

Took a look at your test site - it appears you have indeed resolved the syntax errors and got the centerbox to show.

Nice work!

*Go that extra mile, you never know what's at the end of the road

* Empowerment Sanctuary

3 Apr 2012, 4:10 AM
#34
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: Updating Mod for 150 - Little Problem

Yep, i don't understand how it could have ever worked, there are just too many errors

Incidently if you go back to the very first or second version of it available, it is actually your missing mod, its just been renamed

Hopefully this atached version will work for you, i have tested on 3 sites and it has worked perfectly on all of them

Webzings Design
Semi retired from Web Design

3 Apr 2012, 4:20 AM
#35
scriptjunkie avatar

scriptjunkie

Totally Zenned

Join Date:
Jul 2008
Posts:
772
Plugin Contributions:
0

Re: Updating Mod for 150 - Little Problem

nigelt74:

Yep, i don't understand how it could have ever worked, there are just too many errors

Incidently if you go back to the very first or second version of it available, it is actually your missing mod, its just been renamed

Hopefully this atached version will work for you, i have tested on 3 sites and it has worked perfectly on all of them

Thanks! Will test this and report back here.

Incidentally, re: the missing mod...I thought that also and that's why I downloaded this one. But when I went through the files, I realized the two have completely different files (beyond the file names).

The other one (Recently Viewed Sidebox) has files in includes/auto_loaders and includes/init_includes and no files in modules (only in modules/sideboxes/custom). Also, it has no files in templates/custom/templates (only in templates/custom/sideboxes).

So...if it IS the same mod...someone completely rewrote it and changed the files that come with the download pack.

Attaching the version updated for 150 for your reference.

*Go that extra mile, you never know what's at the end of the road

* Empowerment Sanctuary

3 Apr 2012, 4:55 AM
#36
scriptjunkie avatar

scriptjunkie

Totally Zenned

Join Date:
Jul 2008
Posts:
772
Plugin Contributions:
0

Re: Updating Mod for 150 - Little Problem

nigelt74:

Yep, i don't understand how it could have ever worked, there are just too many errors

Incidently if you go back to the very first or second version of it available, it is actually your missing mod, its just been renamed

Hopefully this atached version will work for you, i have tested on 3 sites and it has worked perfectly on all of them

Yep, you're right. Went back and took a look. Seems the entire mod was re-written. Seems like a lot of work to go through to add a centerbox? Also....it's interesting that the very first version of the mod was functional, until it was updated to add the centerbox option.

Anyway...installed the zip file you included in your last post and it works perfectly and doesn't throw any errors!!

I really thank you for that because I would have had a really hard time identifying the code errors.

Before it gets submitted, I want to make a couple changes to the readme. Regarding the updates you made to modules/recent_products.php....should I delete all the brackets you commented out, along with their comments?

Or should I just leave well enough alone?

*Go that extra mile, you never know what's at the end of the road

* Empowerment Sanctuary

3 Apr 2012, 5:04 AM
#37
nigelt74 avatar

nigelt74

Totally Zenned

Join Date:
Sep 2005
Location:
Waikato, New Zealand
Posts:
1,558
Plugin Contributions:
1

Re: Updating Mod for 150 - Little Problem

Nope remove them, thats just my unique fault finding technique, and i completely forgot to get rid of them

Webzings Design
Semi retired from Web Design

3 Apr 2012, 5:09 AM
#38
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Updating Mod for 150 - Little Problem

gjh42:

Not that I'm an expert on the filesystem either, but that makes the most sense to me. It would be "easier" to put all the defines in one (language) file for this small mod, but that wouldn't really be treating the different defines properly.That's kinda what I thought.. Thanks for your confirmation.:smile:

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

3 Apr 2012, 5:29 AM
#39
scriptjunkie avatar

scriptjunkie

Totally Zenned

Join Date:
Jul 2008
Posts:
772
Plugin Contributions:
0

Re: Updating Mod for 150 - Little Problem

Just want to take a quick moment to thank all three of you for your help in updating this mod, helping me learn, and providing your valuable time :smile:

I sure do appreciate it :smile:

*Go that extra mile, you never know what's at the end of the road

* Empowerment Sanctuary

3 Apr 2012, 5:50 AM
#40
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Updating Mod for 150 - Little Problem

ScriptJunkie:

Just want to take a quick moment to thank all three of you for your help in updating this mod, helping me learn, and providing your valuable time :smile:

I sure do appreciate it :smile:Thank nigel and Glenn.. I'm just the backup singer in this group..:laugh::laugh: Just call me one of the Pips!!

on the midnight train to Georgia - whoo hoo

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.