Display theme items with CPANELIF

moronhead

Well-Known Member
Aug 12, 2001
706
0
316
I'm thinking of using the CPANELIF tag to redirect a user to either a generic page or the relevant theme page depending on one or more variables like: package type, billing interval, server name.

Couldn't come up with a usable formula yet. The redirection is proving to be a challenge!

Anyone?
 

Juanra

Well-Known Member
Sep 22, 2001
777
0
316
Spain
I don't know if you can do that with cpanelif. It seems that it only accepts boolean arguments. It could be done in Perl, or in PHP, something like this:

&?php
if (!strcmp(&&cpanel print=&$CPDATA{'PLAN'}&&&, &mailonly&)) {
// redirect to mailonly index
} else {
// redirect to common index
}
?&

You can't use a Location header because the PHP wrapper sends its own headers before, so for the redirection you would have to use a META tag... or patch the wrapper :p
 

moronhead

Well-Known Member
Aug 12, 2001
706
0
316
Juanra, thanks for that idea. I'll give it a try.

I am mostly thinking about using it for items inside the theme. So you would keep the same theme for every client, but change the destination of an item according to a variable.

Let's say, in the case of MySQL you'd redirect the client to the usual theme page if his plan includes databases OR to a generic page saying &Sorry, you don't have an MySQL database in your account blah blah ....&.

& or patch the wrapper :p

* :-o
 

Juanra

Well-Known Member
Sep 22, 2001
777
0
316
Spain
I understand, in fact I suggested Nick some time ago that Cpanel might allow us to define our own variables from a custom module, so we could use our own configuration files, etc. I even mentioned that it could prove useful in combination with cpanelif tags... :) (I cannot tell you right now the bugzilla bug number, I will when it's up again.)

Anyway, you still can build the pages with PHP or Perl. We display more or less options depending on the package name (and sometimes depending on the username as well). Making changes is harder but it works OK.