Forums / Templates, Stylesheets, Page Layout / Trying to locate the definition for a constant

Trying to locate the definition for a constant

Locked

Started by ruby on 25 May 2006, 5:21 PM · Views: 2,282

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
25 May 2006, 5:21 PM
#1
ruby avatar

ruby

New Zenner

Join Date:
May 2006
Posts:
12
Plugin Contributions:
0

Trying to locate the definition for a constant

Hi! I'd like to reformate the date_added on my product listing pages such that the day of the week no longer appears. I'm looking for the file in which this constant is defined:

PRODUCT_NEW_LIST_DATE_ADDED

I've been searching through a zillion files and I have no idea where it's defined. Anyone want to point me in the right direction?

I also tried using the developer tools to locate it, but it just found the files that called this constant, and not the one that defines it. Strange.

Zen Cart is a great package (especially for the price!), but I gotta say that it's hell trying to figure out which file to edit in order to customize a specific page. The admin configuration is limited as to how much you can really do.

But that's what I get for being an obsessive-compulsive web designer :D

25 May 2006, 5:30 PM
#2
ruby avatar

ruby

New Zenner

Join Date:
May 2006
Posts:
12
Plugin Contributions:
0

Re: Trying to locate the definition for a constant

Here's another one I can't find - this link isn't working on my categories menu, so I'd like to find the page where it originates:

FILENAME_PRODUCTS_ALL

Thanks in advance!

25 May 2006, 6:01 PM
#3
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

Re: Trying to locate the definition for a constant

try entering define('FILENAME_PRODUCTS_ALL into the bottom left box in the Developers Tool Kit, select All Files - Catalog and clicksearch. I guarantee you'll get a single result.

PRODUCT_NEW_LIST_DATE_ADDED isn't defined in a file: it is a configuration key in the database. Set if from Admin > Configuration > New Listing > Display Product Date Added

Neville
An assumption is what you arrive at when you get tired of thinking...

25 May 2006, 6:15 PM
#4
ruby avatar

ruby

New Zenner

Join Date:
May 2006
Posts:
12
Plugin Contributions:
0

Re: Trying to locate the definition for a constant

Thanks, bunyip. I did search the Developer's Toolkit and I did get a result for FILENAME_PRODUCTS_ALL, but not for the file in which the constant is defined, just for those that call it.

I don't want to turn off the Date Added display, I want to reformat it. Currently it shows the day of the week/day of the month/month/year. I want a standard American date format without the day of the week - month/day/year.

The products_date_added field in the database is a datetime field, so in mySql it's formatted like so: 0001-01-01 00:00:00

When you pull that data from the table, you can format it to suit your needs. I'm looking for the file in which that happens, so I can edit the date format accordingly. Thanks to you, I was able to locate a file in which a database query is made, but there is no date formatting in that file. It's really weird.

PRODUCT_NEW_LIST_DATE_ADDED has to be defined in a file somewhere, but I sure can't find it. :(

25 May 2006, 6:29 PM
#5
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

Re: Trying to locate the definition for a constant

FILENAME_PRODUCTS_ALL is defined in includes/filenames.php - that won't help you.
PRODUCT_NEW_LIST_DATE_ADDED is a database configuration key as I described above - it's value is used to determin if the date added column is displayed at all, and if so, in which order. Again, that won't help you achieve what you want.

If you take a look at includes/templates/template_default/templates/tpl_modules_products_new_listing.php at line 61 you'll see this code:

$display_products_date_added = TEXT_DATE_ADDED . ' ' . zen_date_long($products_new->fields['products_date_added']) . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_LIST_DATE_ADDED, 3, 1));

You can see there that the database outpur for the field products_date_added is being used by the function zen_date_long() to format it for display. So where you need to be looking is at that function.
Plug that function name into the search field for functions in the Developers Tool Kit, search All Files - Catalog and you'll find it's contained in includes/functions/functions_general.php at line 189.

Neville
An assumption is what you arrive at when you get tired of thinking...

25 May 2006, 6:56 PM
#6
ruby avatar

ruby

New Zenner

Join Date:
May 2006
Posts:
12
Plugin Contributions:
0

Re: Trying to locate the definition for a constant

Thanks, bunyip, I'm getting warmer thanks to your help.

I found the date_long function, which referenced another constant DATE_FORMAT_LONG in english.php. That's where the formatting is, so I can tweak that as needed.

So many constants in so many files!

As for FILENAME_PRODUCTS_ALL - it's not in my includes/filenames.php, maybe that's why my link is broken?

We seem to be using different ZC versions (I'm 3.0) because none of the line numbers you've provided match mine - no big deal, since control-F does the job, but that may be why my code isn't where yours is?

25 May 2006, 6:59 PM
#7
bunyip avatar

bunyip

Totally Zenned

Join Date:
Sep 2004
Location:
Western Massachusetts
Posts:
2,361
Plugin Contributions:
1

Re: Trying to locate the definition for a constant

Ruby:

As for FILENAME_PRODUCTS_ALL - it's not in my includes/filenames.php, maybe that's why my link is broken?
Yep - that'll be why

The line numbers I gave were from 1.3.0.1, so might not quite match your version.

Neville
An assumption is what you arrive at when you get tired of thinking...

25 May 2006, 7:09 PM
#8
ruby avatar

ruby

New Zenner

Join Date:
May 2006
Posts:
12
Plugin Contributions:
0

Re: Trying to locate the definition for a constant

Yep, that was it! I just inserted:

define('FILENAME_PRODUCTS_ALL', 'products_all');

and it's working fine now. Yippeee!

You're my hero :smile:

26 May 2006, 3:41 AM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Trying to locate the definition for a constant

Strongly recommend upgrading to v1.3.0.1 rather than run with a buggy version of v1.3 ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

26 May 2006, 3:26 PM
#10
ruby avatar

ruby

New Zenner

Join Date:
May 2006
Posts:
12
Plugin Contributions:
0

Re: Trying to locate the definition for a constant

Done. Thanks for the suggestion!