5 Replies Latest reply on Jan 28, 2008 5:49 AM by smartdesignz

    Custom Triggers

    smartdesignz
      Hi

      Could some one please tell me how to create a custom trigger to do the following:

      on a input form

      Field one: Product Name

      hidden field two: place the Product Name in here and replace spaces with a underscore.

      Example Product: Mountain Bike would be submitted in the hidden field as Mountain_Bike
        • 1. Re: Custom Triggers
          Günter Schenk Level 4
          Hi tea break,

          the following Custom Trigger should be set to BEFORE amd will apply the "space to underscore" str_replace to the field "Product_Name" itself:

          $tNG->setColumnValue("Product_Name", str_replace(' ','_',$tNG->getColumnValue("Product_Name")));

          That said, you don´t need any redundant hidden field, which is probably not even part of the transaction

          Cheers
          Günter Schenk
          Adobe Community Expert, Dreamweaver
          • 2. Re: Custom Triggers
            smartdesignz Level 1
            Hi Gunter,
            thanks for the fast responce:-)

            but I need both fields and wish to push the information from the first field in to the second field with the underscore between words in that field. so in effect it will be as follows

            mountain_bike
            3_man_tents
            1_2_3_4
            and_so_on.

            as what I'm trying to do is with mod_rewrite to pull out product_name in the url as follows
            http://www.sitename.com/department/product_name/

            and not

            http://www.sitename.com/department/product%20name/

            or

            http://www.sitename.com/products.php?departmentid=1&productid=1

            but I don't want to type it in twice in to 2 fields with the underscore between the product namewhere needed in the second field
            Cheers
            • 3. Re: Custom Triggers
              Günter Schenk Level 4
              Hi tea break,

              ------
              push the information from the first field in to the second field
              ------

              I think you´ll need to search for a javascript based solution then, because ADDT´s Custom Triggers are not capable of doing that.

              Cheers
              Günter Schenk
              Adobe Community Expert, Dreamweaver
              • 4. Re: Custom Triggers
                Günter Schenk Level 4
                Another suggestion: if you need the original column contents *displayed* with underscores on whatever page, you could also apply the very same str_replace routine to a Recordset value, example:

                $productname_underscored = str_replace(" ","_",$row_queryname['Product_Name']);

                ...means that "echoing" the newly introduced variable "productname_underscored" will be displaying the contents of the column "Product_Name" with underscores instead:



                Cheers
                Günter Schenk
                Adobe Community Expert, Dreamweaver
                • 5. Re: Custom Triggers
                  smartdesignz Level 1
                  Hi Gunter,

                  cheers again, I sorted it using javascript :-)