Announcement

Collapse
No announcement yet.

Using clientside in Module_System_Head?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using clientside in Module_System_Head?

    Hi folks,

    I'm writing a system-ex module that has an admin setting to specify a page code. I thought I'd include the lookup button and pop-up as a convenience for the users. I looked at the HTML source of a product-admin page to find the syntax for the JS to call the PageLookupDialog() function, but when I wrote this into my code, I got a "function not defined" error. Looking thru the source of the page I borrowed from, I found this: I can include this code in my Module_System_Head() function, but where does the "T" parameter come from? I tried it without that, and it apparently didn't work. How do I generate that parameter?

    Thanks --

    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

    #2
    Kent, I think there is an API function the LSK for the admin that manages this feature.
    Ray Yates
    "If I have seen further, it is by standing on the shoulders of giants."
    --- Sir Isaac Newton

    Comment


      #3
      clientside is a feature you module need to implement. (see page 33 of miva.com/apiguide) You module must declare the feature in the features list and contain the following function:

      Code:
      <MvFUNCTION NAME = "Module_Clientside" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
          <MvIF EXPR = "{ ( '.js' EIN g.Filename ) EQ len_var( g.Filename ) }">
              <MvEVAL EXPR = "{ [ g.Module_Clientside ].Module_Content_Type( l.module, 'text/javascript' ) }">
          </MvIF>
      
          <MvIF EXPR = "{ g.Filename EQ 'features/tui/pagelookupdialog.js' }">
              <MIVA STANDARDOUTPUTLEVEL = "text, html">
              <MvINCLUDE INTERPRET = "off" FILE = "features/tui/pagelookupdialog.js">
              <MIVA STANDARDOUTPUTLEVEL = "">
      
              <MvFUNCTIONRETURN VALUE = "1">
          </MvIF>
      
          <MvASSIGN NAME = "l.null"    VALUE = "{ miva_output_header( 'Status', '404 Not Found' ) }">
      </MvFUNCTION>

      The T parameter is a cache busting parameter which gets updated each time the file is changed. This forces the browser to reload the file anytime it changes.

      Once you have your function defined you can load the Js in a call to clientside.mvc like this:


      Code:
      <MvEVAL EXPR = "{ '<script src="&mvte:global:clientside_url;Store_Code=&mvta:store:code;&amp;Filename=features/tui/pagelookupdialog.js&amp;Module_Code=modulecode $ '"></script>' }">
      Brennan Heyde
      VP Product
      Miva, Inc.
      [email protected]
      https://www.miva.com

      Comment


        #4
        So I don't need to use the "T" parameter if I write my own Module_Clientside code?

        Thanks --
        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

        Comment


          #5
          After more study, I don't think this really answers my question. The code snippet from the admin page references the path features/tui/pagelookupdialog.js. But I don't see any folder & file by that name on my server. So I don't see how adding the clientside feature to my module will help.

          I need to know how I can get that Javascript file onto my module's admin page, so that the call to PageLookupDialog() won't cause an error. And I suppose I'll run into this same problem in the future when I want to use the pop-ups for products, categories, etc.

          Thanks --
          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

          Comment


            #6
            Hi Kent,

            You should be calling the following functions in the appropriate places. Doing so will pull in all the necessary files.

            Code:
            <MvEVAL EXPR = "{ [ g.Module_Feature_TUI_AD ].Element_PageLookup_Dialog_CSS() }"> (Module_System_Head)
            <MvEVAL EXPR = "{ [ g.Module_Feature_TUI_AD ].Element_PageLookup_Dialog_JavaScript() }"> (Module_System_Head)
            <MvEVAL EXPR = "{ [ g.Module_Feature_TUI_AD ].Element_PageLookup_Dialog_HTML() }"> (Module_System_Content)
            David Carver
            Miva, Inc. | Software Developer

            Comment


              #7
              Hi David,

              Thanks for the code snippets. The module is almost working now. The Lookup button pops up the lightbox, but nothing happens when I make a selection and click the OK button. On the JS console, I get a "TypeError: input is null" message when I click the button. I suspect that the code for the dialog makes some assumptions about the form elements, and there's something about my code that doesn't fit. I looked at the HTML source of the page, but I couldn't figure out much. The PageLookupDialog function is not visible; and I had to Google "rocketscript" to find out a little about what that is ...

              There were some cases when I changed an input name, uploaded the revised module to the store, and refreshed the page, and the old field name was still showing up in some of the HTML source for the refreshed page. Is there some sort of caching going on? How do I make sure that the code running in the browser is in synch with what I uploaded to the server?

              Thanks --
              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

              Comment

              Working...
              X