Miva Script 101 /
Mivascript Driven Websites
Mivascript Driven Websites
Scot's Scripts: MIVA Script Driven Websites
Navigation, manageability, consistency.
Using MIVA script is one of many ways to save time working on your website so you can put more time into the things that increase revenue.
The information about MIVA script driven websites was originally created for the 2006 MIVA convention, however I was unable to attend due to a good musical opportunity (I'm a jazz pianist in real life).
page wrappers overview
mvif wrappers
function wrappers
mvdo wrappers
dbf wrappers
Page Wrappers: Overview
Page Wrapping: a way to make your site consistent, easy to navigate, and easy to manage.
Whether you code your HTML by hand or with tools such as Dreamweaver, keeping things consistent can be a chore.
One could spend days getting their site just right, to go through and update dozens of html pages, to put the final touches on graphics, and to make sure everything fits before finally uploading to a website.
Then, no matter how meticulous one is, it's almost expected to find unintended results (bugs? features?) when checking the site online.
One of the most flexible tools for MIVA script developers is the MIVA scripting language.
What are page wrappers?
The easiest page wrapping technique is where you have a static header and footer and then based on a variable in a link or form, the content changes.
A similar way is to call a function with the content you want to display.
A more advanced method that lets you manage your site from a browser is by pulling the content from a database.
MvIF Wrappers
The idea behind MvIF wrappers is the same as all the page wrapper styles:
• The user clicks on a link that has a page variable
• The script uses the page variable to display appropriate content
In the example code below, there are three links. We use system variable s.documenturl for the link because it will automatically insert the correct path to the page.
s.documenturl is the easy way to make sure links in your scripts work on any site they are installed on
The first link, The Best Cat For You, has a page variable set to the_best_cat.
When a visitor clicks on that link, the page comes back up, but this time the line, It's the one that you like the most. is added to the page.
The MIVA engine checks each MvIF statement for any matching conditions. In this case, the g.page variable equals the_best_cat, so whatever is inside the MvIF statement gets executed. In this case, it's some text, but it could be more MIVA script or anything else you would put in a script or web page.
• test the script below
Function Wrappers
Function wrappers are based on the same general ideas as MvIF wrappers. Instead of having your content inside MvIF tags, your content is inside functions embedded in the file.
Function wrappers act just like MvIF wrappers:
• The user clicks on a link that has a page variable
• The script uses the page variable to display appropriate content
In the example code below, there are three links. We use system variable s.documenturl for the link because it will automatically insert the correct path to the page.
The first link, The Best Cat For You, has a page variable set to the_best_cat.
When a visitor clicks on that link, the page comes back up, but this time the line, It's the one that you like the most. is added to the page.
The MIVA engine checks each MvIF statement for any matching conditions. In this case, the g.page variable equals the_best_cat, so whatever is inside the MvIF statement gets executed. In this case, a function is executed.
• test the script below
This would be the index.mvc file.
MvDO Wrappers
MvDO wrappers work like all page wrapping techniques. The difference with MVDO wrappers is that you will keep your content in one or more library files.
Using this method can be helpful when it comes to site organization. The more stuff you have in your site, the easier it is to lose track.
After your visitor clicks on a link, the MIVA engine checks each MvIF statement for any matching conditions. In this case, the g.page variable equals the_best_cat, so whatever is inside the MvIF statement gets executed. In this case, a function in a seperate file is executed.
<MvEVAL EXPR = "{[ l.mvdo_lib ].the_best_cat()}"> is a new way to use the MvDO tag. Fun and useful too.
• test the scripts below
This would be the index.mvc file.
This is the library file that the MvDO tags above are calling.
Dbf Wrappers
DBF wrappers are no different than any of the other wrapper styles we examined except that page content is stored in a database.
Instead of pulling the content from a function in the same file or a library file, the script opens the database, finds the correct record, and then returns the record information so the script can display or otherwise process it.
In the example below, page content data is stored in a dbf file and it is read by a function called display_content which takes the page ID as a parameter. All this does is let the system know which page to pull the data from.
There are comments in the code below to help explain in greater detail what's going on. If you need more comments, let me know.
• test the script below
updated July 04, 2023