MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: Different templates for catalogs.



******    message to minivend-users from mikeh@minivend.com     ******

Quoting Pumin Wuvanich (pumin@hotmail.com):
> 
> Hello folks,
> 
>       i'm thinking about creating some templates of different layout, and 
> will allow every catalogs to share those templates.  Those templates will 
> cantain same functionalities, but just look different (in color, font, 
> layout, background, etc.).  So now the look of each catalog can be changed 
> once in a while based on given templates.
> 
>       To illustrate this, normally, each cart has its own HTML files in 
> 'catalogs/cart_name_here/pages' directory (such as leftside, rightside, 
> browse.html, etc.).  And i'm thinking to redirect all catalogs to one of 
> those new templates such as 'catalogs/template_library/alien-theme' ,or 
> 'catalogs/template_library/zoo-theme', for example.  So now a number of 
> carts may select 'alien-theme', and they can switch to 'zoo-theme' whenever 
> they get bored.
> 
>       The question here is .. is this idea possible?  I just need to make 
> sure before i spend months on this.  :)  Any comments or advices will be 
> greatly appreciated.
> 

Absolutely. That is exactly why I do things the way I do....

Variable  THEME  -alien-theme

ParseVariables  Yes
ConfigDir  config__THEME__
ParseVariables  No
Variable      LEFTSIDE   <leftside
Variable      RIGHTSIDE  <rightside
Variable      NO_RIGHT   <no_right
Variable      MENUBAR    <menubar
Variable      MENUBOTTOM <menubottom
Variable      LOGOBAR    <logobar
Variable      COPYRIGHT  <copyright
ConfigDir  config
ParseVariables  Yes

Now you make a directory called config-alien-theme and reconfigure.
If there are any [include pages/leftside] tags anywhere, make
sure to change them to [include config__THEME__/leftside].

One feature I put in MV3.12 is not documented; that you can set configuration
in places beyond the user's control. Using "simple" as an example, if you put a
file in the global etc/ directory (this is the etc/ in the directory where
minivend.cfg resides) called "simple.before" then it will configure the
defaults before catalog.cfg is read. Then if you put a file called simple.after
in the global etc/ directory , it will make settings AFTER the catalog.cfg is
read. 

For instance, if you want to make absolutely sure that your user cannot
use "cat" as their EncryptProgram, then you can put in simple.after:

ParseVariables Yes
EncryptProgram  /usr/local/bin/pgpe -fat -r __ORDERS_TO__ 2>/tmp/simple.encrypt.err

MV4 will have some more things in configuration, so that you can
do something like:

EncryptProgram <<&EOF
sub {
	my $value = shift;
	return $value unless ! $value || $value =~ /cat/;
	return '/usr/local/bin/pgpe -fat -r __ORDERS_TO__ 2>/tmp/simple.encrypt.err';
}
EOF

If you are not advanced in Perl, I wouldn't read any farther. 8-)

While I am on a roll with the undocumented configuration things, here are
some capabilities that may not be known even to confirmed source readers:

	- You can add directives to catalog.cfg
	- You can configure catalog.cfg and minivend.cfg from a SQL database
	- You can configure things from the command line upon startup

Anyone interested should consult the source for Config.pm, but here is
an example of the first:

----- start minivend.cfg ----

UserTag myroutine Routine <<EOR
sub {
	use MyModule;
	package Vend::Config;
	sub parse_myparse {
		# This directive will be set to "foo-value" if a value is passed.
		my ($directive, $value) = @_;
		return '' unless $value;
		return "foo-$value";
	}
	return "my results";
}
EOR

AddDirective   MyDirective  myparse	  foo

----- end minivend.cfg ----

Now you can set in catalog.cfg:

MyDirective   bar

And the value of $Vend::Cfg->{MyDirective} will be "foo-bar". This can
be useful if you are setting up complex additional functionality via
modules.

AddDirective has the syntax:

	DirectiveName   parser   default

The optional parser is always a routine in the package Vend::Config with
"parse_" prefixed; that is why I define a routine "parse_myparse" in
the placeholder global UserTag above. If no parser is defined then the
value will be set unprocessed. The optional default is what should be set
by default. Standard parsers in include "yesno" to set a true/false based
on a yes or no value, "boolean" for arrays, "hash" for hash settings,
"integer" to guarantee an integer number, "regex" for a danger-free
regular expression, etc.

-- 
Mike Heins                          http://www.minivend.com/  ___ 
                                    Internet Robotics        |_ _|____
                                    131 Willow Lane, Floor 2  | ||  _ \
It's a little-known fact            Oxford, OH  45056         | || |_) |
that the Y1K problem caused         <mikeh@minivend.com>     |___|  _ <
the Dark Ages. -- unknown           513.523.7621 FAX 7501        |_| \_\
-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: