When I call my custom module directly it seems like g.Store_Table_Prefix and some other global level variables are not being set. How do i get these values populated?
Announcement
Collapse
No announcement yet.
Direct Call to custom module missing global variables
Collapse
X
-
Re: Direct Call to custom module missing global variables
You may need to patch together some code yourself, by copying and pasting from the LSK. A lot of variables are intialized by config.mv. Many other important ones are initialized at the beginning of merchant.mv.Kent Multer
Magic Metal Productions
http://TheMagicM.com
* Web developer/designer
* E-commerce and Miva
* Author, The Official Miva Web Scripting Book -- available on-line:
http://www.amazon.com/exec/obidos/IS...icmetalproducA
-
Re: Direct Call to custom module missing global variables
...but does that work on the ADMIN side? i'm assuming that the OP was looking for variables to use when his module runs as a script in the background.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
-
Re: Direct Call to custom module missing global variables
Where would I find this module? What's it called?Originally posted by Rick Wilson View PostIn PR8 Update 5 there's a Variable and Entity module built in to the core software.Ray Yates
"If I have seen further, it is by standing on the shoulders of giants."
--- Sir Isaac Newton
Comment
-
Re: Direct Call to custom module missing global variables
RickOriginally posted by Rick Wilson View PostIt's built into the Pages section, look up a page and then click the VAR List button in the upper right. Also it's documented in the reference docs on our main site.
I found it in the PDF but it's not showing up on any of the sites we manage.
Miva Merchant 5.5
Production Release 8Update 5
Miva Merchant Engine v5.13
Database API: mysql
Ray Yates
"If I have seen further, it is by standing on the shoulders of giants."
--- Sir Isaac Newton
Comment
-
Re: Direct Call to custom module missing global variables
Usually when I'm calling one of my modules directly I try to figure out which global variable I actually need (you likely don't need all of them) and pass those directly in the call.Originally posted by dorgan View PostWhen I call my custom module directly it seems like g.Store_Table_Prefix and some other global level variables are not being set. How do i get these values populated?Ray Yates
"If I have seen further, it is by standing on the shoulders of giants."
--- Sir Isaac Newton
Comment
-
Re: Direct Call to custom module missing global variables
Go to Utilities from the store admin. You should see an item labelled Token List under the Modules tab. Check the box next to it and click update. After that, navigating to a page in admin will show the VAR LIST button at the top right of the page (next to the extras and help buttons).Originally posted by RayYates View PostRick
I found it in the PDF but it's not showing up on any of the sites we manage.
Miva Merchant 5.5
Production Release 8Update 5
Miva Merchant Engine v5.13
Database API: mysql
Remember, this is only available on PR8 Update 5+ stores.
Comment
-
Re: Direct Call to custom module missing global variables
When called directly your module should do something like the following:Originally posted by dorgan View PostWhen I call my custom module directly it seems like g.Store_Table_Prefix and some other global level variables are not being set. How do i get these values populated?
The initial MvDO of lib/config.mv will set all of the global variables that indicate the version and the various feature and lib paths relative to the mm5 directory. We have to use a relative path to get to config.mvc because we haven't yet determined the root directory for modules so that we can use the g.Module_XXX variables.Code:<MvDO FILE = "../../lib/config.mvc"> <MvIF EXPR = "{ NOT [ '../../lib/db.mvc' ].OpenDataFiles( g.Merchant_Version, g.Domain ) }"> <MvEXIT> </MvIF> <MvEVAL EXPR = "{ [ '../../lib/util.mvc' ].SetRuntimePaths() }"> <MvIF EXPR = "{ NOT [ g.Module_Library_DB ].Store_Open( g.Store_Code, g.Store ) }"> <MvEXIT> </MvIF>
The OpenDataFiles call will connect to the database and populate g.Domain. Note that we have to use a relative path here as well.
The SetRuntimePaths function will look at the settings in g.Domain and set the g.Module_XXX path variables.
The Store_Open call will open the store specified by the input parameter Store_Code and set the g.Store variable. This function will also set g.Store_Table_Prefix. Note that since we've called SetRuntimePaths() we can use g.Module_Library_DB in the call.
It is critically important that, at the bare minimum, any custom entry points into Miva Merchant MvDO lib/config.mvc. This MvDO explicitly sets any global variables that we use in database queries or subsequent MvDO operations. Passing any of those variables in as parameters will introduce one or more major security holes into your module.
Comment
Comment