[ic] Renaming catalog.cfg - Managing multiple catalogs
Marty Tennison
marty at dripdepot.com
Mon Dec 22 17:32:42 UTC 2008
Doug Whiteley wrote:
> [snip]
>
> Or use symlinks.
>
>
Hi Guys,
Thanks for all the help. I actually came up with a pretty nice solution
that is (so far) working quite well. I'll post what I've done so far in
case anyone else tries this.
Scenario: I'm a single developer managing two (or more) catalogs. My
goal was to re-use as much code as possible from the catalogs but still
retain the flexibility to separate portions of code in an organized
manner. I got this idea from studying the Magento software and I really
liked they way they handled multi store setups.
The goals were this...
1) Store all catalogs in the same directory structure
2) Share as much (or as little) configuration setting between catalogs.
3) Allow separation of pages, blocks of code and themes simply by
placing files in different directories and not having to make
configuration changes.
4) Minimal or no use of symlinks to ease SVN configuration and enhance
organizational intuitiveness.
5) Minimal duplication of configuration settings.
And a lot more (to verbose to post)
So the solution I came up with was to use Subcatalog, PageDir,
TemplateDir and a lot of 'ParseVariables Yes' goodness. With this setup
I can create catalog specific or theme specific changes simply by moving
or creating the file in subcategories. I can also use shared blocks of
code with the same flexibility. And all this without making
configuration changes or using symlinks. So far, it's working pretty
good. Here are the (relevant portions) of the config files.
#========================================================================#
# interchange.cfg
#========================================================================#
Catalog store1 /home/interchange/catalogs /cgi-bin/store1
SubCatalog store2 store1 /home/interchange/catalogs /cgi-bin/store2
#==========================================================================#
# catalog.cfg (Config file for store1)
#==========================================================================#
# This is the first catalog or "Parent" catalog configuration file.
# It does not matter which catalog is the parent since they all parse
# the default.cfg file in the same manner. The only difference is that
# This file must be named catalog.cfg where as the subcatalogs configuration
# files are named after the shop. Example: shop1.cfg, shop2.cfg etc.
#==========================================================================#
ParseVariables Yes
#==========================================================================#
# Set some variables that are unique to this catalog only
#==========================================================================#
Variable SERVER_NAME store1.com
Variable CATALOGNAME store1
# Database setup
DatabaseAuto dbi:mysql:store1 user pass
#==========================================================================#
# Include the default configuration for all catalogs
#==========================================================================#
include default.cfg
#==========================================================================#
# Include the catalog specific configuration
#==========================================================================#
include etc/__CATALOGNAME__/actionmaps.cfg
#==========================================================================#
# store2.cfg (Config file for store2)
#==========================================================================#
ParseVariables Yes
#==========================================================================#
# Set some variables that are unique to this catalog only
#==========================================================================#
Variable SERVER_NAME store2.com
Variable CATALOGNAME store2
# Database setup
DatabaseAuto dbi:mysql:store2 user pass
#==========================================================================#
# Include the default configuration for all catalogs
#==========================================================================#
include default.cfg
#==========================================================================#
# Include the catalog specific configuration
#==========================================================================#
include etc/__CATALOGNAME__/actionmaps.cfg
#==========================================================================#
# default.cfg (Config file for all shared catalogs)
#==========================================================================#
# This is the default configuration file for all shared catalogs.
#==========================================================================#
Message Parsing default.cfg for catalog __CATALOGNAME__ ...
# Parse variables in this configuation file.
ParseVariables Yes
# Disable this for production
Pragma dynamic_variables
# Turn this on to get debug info
Variable DEBUG 1
# Override the default data directory (default products)
DataDir data
#==========================================================================#
# Set some variables
#==========================================================================#
Variable SECURE_SERVER __SERVER_NAME__
Variable CATALOGDIR /home/interchange/catalogs
Variable CGI_DIR /home/httpd/vhosts/__SERVER_NAME__/cgi-bin
Variable CGI_URL
Variable CACHEDIR /var/cache/interchange/__CATALOGNAME__
Variable DOCROOT /home/httpd/vhosts/__SERVER_NAME__/httpdocs
Variable ICROOT /usr/local/interchange
Variable LOGDIR /var/log/interchange/__CATALOGNAME__
Variable SAMPLEHTML __DOCROOT__/__CATALOGNAME__
Variable SAMPLEURL http://__SERVER_NAME__
#==========================================================================#
# Read in shared variables for all catalogs
#==========================================================================#
Database default_variables default_variables.txt TAB
VariableDatabase default_variables
#==========================================================================#
# Read in catalog specific variables, overriding shared if they exist
#==========================================================================#
Database __CATALOGNAME___variables __CATALOGNAME___variables.txt TAB
VariableDatabase __CATALOGNAME___variables
#==========================================================================#
# Read in global templates
#==========================================================================#
DirConfig Variable templates
#==========================================================================#
# If we have a theme set (Variable THEME) then adjust the search
# order of PageDir and TemplateDir so that the theme specific
# directories are searched first.
#==========================================================================#
ifdef THEME
Message Configuring catalog __CATALOGNAME__ with theme __THEME__ ...
# Include a theme file for any theme specific configurations
# This is not required, only optional. Theme files are read
# in ascending order (or bottom up) so that theme configuration
# files are read last so they can override other settings.
include templates/__THEME__/theme.cfg
include templates/__CATALOGNAME__/__THEME__/theme.cfg
# Pick up an entire directory of variables if defined.
DirConfig Variable themes/__THEME__
DirConfig Variable themes/__CATALOGNAME__/__THEME__
# Setup the catalog pages directory, this take precedence over TemplateDir.
PageDir pages/__CATALOGNAME__/__THEME__
# Now we set TemplateDir. We include the PageDir directory so that files
# relative to the PageDir directory will be found.
TemplateDir pages/__CATALOGNAME__/__THEME__
TemplateDir pages/__THEME__
TemplateDir pages/__CATALOGNAME__
# Now we setup the search order for the blocks directory.
TemplateDir blocks/__CATALOGNAME__/__THEME__
TemplateDir blocks/__THEME__
# If used, define search order of tables and directories for page data.
# PageTables page_data___CATALOGNAME_____THEME__
# PageTables page_data___CATALOGNAME__
endif
#==========================================================================#
# End of theme configuration
#==========================================================================#
#==========================================================================#
# If no theme is defined then we set the PageDir
#==========================================================================#
ifndef THEME
PageDir pages/__CATALOGNAME__
endif
#==========================================================================#
# These get set regardelss of theme existence.
#==========================================================================#
TemplateDir pages/__CATALOGNAME__
TemplateDir pages
TemplateDir blocks/__CATALOGNAME__
TemplateDir blocks
# PageTables page_data___CATALOGNAME__
# PageTables page_data
#==========================================================================#
# All done with PageDir, TemplateDir and Themes.
# Now we setup general conifuration stuff
#==========================================================================#
Message Sending __CATALOGNAME__ errors to __LOGDIR__/error.log
AutoVariable ImageDir
ImageDir /images/__CATALOGNAME__/
#ImageDirSecure /images/__CATALOGNAME__/
ErrorFile __LOGDIR__/error.log
AsciiTrack __LOGDIR__/tracking.log
TrackFile __LOGDIR__/usertrack.log
SessionDatabase __CACHEDIR__/session
ScratchDir __CACHEDIR__/tmp
VendURL http://__SERVER_NAME____CGI_URL__
SecureURL __SECURE_SERVER____CGI_URL__
RunDir /var/run/interchange/__CATALOGNAME__
etc, etc etc.......
There is of course a lot more, but this should give a general idea of
the direction. If anyone spots a "Gotcha" please let me know. :)
--
- - -- ---- ---------------------------- --- -- - -
Marty Tennison
- -- --- --------------------------------------- --- --
More information about the interchange-users
mailing list