OK I have a great little scrip in PHP that lets me do some dynamic things based on peoples user agent, however I am having a bit of trouble figuring how to re-write this PHP using purely Miva Scrip, or how to include it so it executes properly.I recall that getting PHP to run in the HEAD is a bit problematic, but if it can be done that might be easier? I either need to get the PHP to run corectly in the HEAD section of MIVA pages or I need to rewrite it into Miva Script....The basics of the code are:$ua = $_SERVER['HTTP_USER_AGENT'];if ((preg_match('what I am looking for in the user agent', $ua)){ $user = "what I will test for latter to decide what to do";} else if ((preg_match('what I am looking for in the user agent', $ua)){ $user = "something else I will test for latter to decide what to do";} I also make use of the "||" or, "&&" and, and or the "!" not operators in these if else teststhen I runif ($user == "a value I set to test for"){ print "the HTML I want";}else if ($user == "another value I set to test for"){ print "the HTML I want";}any help I can get converting this PHP to MIVA or running this PHP in MIVA is much appreciated. I am basically getting caught up on properly passing the variable between to tests and how to execute preg_match() and $_SERVER['HTTP_USER_AGENT'] in Miva Script, or how to get these PHP instructions to properly execute if included in the HEAD section of a miva page. Either solution would work in this case.Thanks a million in advance.
Announcement
Collapse
No announcement yet.
PHP to Miva Scrip need some help
Collapse
X
-
Re: PHP to Miva Scrip need some help
OK I have a great little scrip in PHP that lets me do some dynamic things based on peoples user agent, however I am having a bit of trouble figuring how to re-write this PHP using purely Miva Scrip, or how to include it so it executes properly.I recall that getting PHP to run in the HEAD is a bit problematic, but if it can be done that might be easier? I either need to get the PHP to run corectly in the HEAD section of MIVA pages or I need to rewrite it into Miva Script....The basics of the code are:$ua = $_SERVER['HTTP_USER_AGENT'];if ((preg_match('what I am looking for in the user agent', $ua)){ $user = "what I will test for latter to decide what to do";} else if ((preg_match('what I am looking for in the user agent', $ua)){ $user = "something else I will test for latter to decide what to do";} I also make use of the "||" or, "&&" and, and or the "!" not operators in these if else teststhen I runif ($user == "a value I set to test for"){ print "the HTML I want";}else if ($user == "another value I set to test for"){ print "the HTML I want";}any help I can get converting this PHP to MIVA or running this PHP in MIVA is much appreciated. I am basically getting caught up on properly passing the variable between to tests and how to execute preg_match() and $_SERVER['HTTP_USER_AGENT'] in Miva Script, or how to get these PHP instructions to properly execute if included in the HEAD section of a miva page. Either solution would work in this case.There that should be easier for people to actually read. Thanks a million in advance.
-
Re: PHP to Miva Scrip need some help
OK I have a great little scrip in PHP that lets me do some dynamic things based on peoples user agent, however I am having a bit of trouble figuring how to re-write this PHP using purely Miva Scrip, or how to include it so it executes properly.
I recall that getting PHP to run in the HEAD is a bit problematic, but if it can be done that might be easier? I either need to get the PHP to run corectly in the HEAD section of MIVA pages or I need to rewrite it into Miva Script....
The basics of the code are:
PHP Code:$ua = $_SERVER['HTTP_USER_AGENT'];
if ((preg_match('what I am looking for in the user agent', $ua))
{
$user = "what I will test for latter to decide what to do";
}
else if ((preg_match('what I am looking for in the user agent', $ua))
{
$user = "something else I will test for latter to decide what to do";
}
then I run
PHP Code:if ($user == "a value I set to test for")
{
print "the HTML I want";
}
else if ($user == "another value I set to test for")
{
print "the HTML I want";
}
There that should be easier for people to actually read. Thanks a million in advance.
Comment
-
Re: PHP to Miva Scrip need some help
You could do this easily with actual mivascript
<mvif expr="{ 'WHAT YOU ARE LOOKING FOR IN USER AGENT' IN toupper(s.user_agent) }">
do this
<mvelseif expr="{ 'SOMETHING ELSE YOU ARE LOOKING FOR' IN toupper(s.user_agent) }">
do something else
<mvelse>
do the last thing
</mvif>
Do actually do it in a template, you'd need toolkit or toolbelt (and i don't know the syntax, but the Gist is the same).
Here's a complete list of system variables:
http://www.mivascript.com/topic/system-variables.htmlBruce Golub
Phosphor Media - "Your Success is our Business"
Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
phosphormedia.com
Comment
-
Re: PHP to Miva Scrip need some help
ok so something like:
PHP Code:else if ((preg_match('/iPad/i', $ua)) || (preg_match('/tablet/i', $ua)))
{
/* This user agent is on a tablet */
$user = "result1";
}
Code:<mvelseif expr="{ '/iPad/i' IN toupper(s.user_agent) || '/tablet/i' IN toupper(s.user_agent) }"> <MvASSIGN NAME="g.User" VALUE="result1">
Comment
-
Re: PHP to Miva Scrip need some help
Close: "||" is OR in mivascript.
<mvelseif expr="{ '/iPad/i' IN toupper(s.user_agent) || '/tablet/i' IN toupper(s.user_agent) }">
<MvASSIGN NAME="g.User" VALUE="result1">
To use mivascript, you'd have to create a module (by following the Module API doc and asking tons of questions which are not answered by that do (and of course, get and install the compiler). But yea, can be done.
Another thing you could do is use the PHP to 'redirect' the customer by having that as the default "landing" page, using PHP code to do the detection, then, send them to either "merchant.mv?screen=XXXX&restof=merchant&variables =intheurlBruce Golub
Phosphor Media - "Your Success is our Business"
Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
phosphormedia.com
Comment
-
Re: PHP to Miva Scrip need some help
Originally posted by Bruce - PhosphorMedia View PostClose: "||" is OR in mivascript.
<mvelseif expr="{ '/iPad/i' IN toupper(s.user_agent) || '/tablet/i' IN toupper(s.user_agent) }">
<MvASSIGN NAME="g.User" VALUE="result1">
To use mivascript, you'd have to create a module (by following the Module API doc and asking tons of questions which are not answered by that do (and of course, get and install the compiler). But yea, can be done.
Another thing you could do is use the PHP to 'redirect' the customer by having that as the default "landing" page, using PHP code to do the detection, then, send them to either "merchant.mv?screen=XXXX&restof=merchant&variables =intheurl
Comment
-
Re: PHP to Miva Scrip need some help
Yes, the mivascript command for || is OR.
if you haven't seen this already, its handy to have around: http://www.mivascript.com/Bruce Golub
Phosphor Media - "Your Success is our Business"
Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
phosphormedia.com
Comment
Comment