Announcement

Collapse
No announcement yet.

Single Product per Page URL for Javascript

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

    Single Product per Page URL for Javascript

    Hi I am using Sellerdeck v11.2 and sellerdeck hosting..

    I have searched the forums without success (there are some related articles, but don't answer the question) which is..
    how do I put the full URL of a single product page, or even just the page name, into a variable?

    I am trying to use the 'Dynamic Drive' add to favourites script,
    this requires a line of javascript like this..

    <a href="javascript:bookmarksite('WebSparky', 'http://www.websparky/acatalog/SingleProductPageName.html')">Add to <br />Favourites!</a>

    Just cant find a way of puting in the SPP URL
    can anyone help?

    Thanks
    Tezzflyer

    Websparky Electrical Goods

    http://www.websparky.co.uk

    #2
    Code:
    <a href="javascript:bookmarksite('WebSparky <actinic:variable name="ProductName" encoding="perl" selectable="false" />', '<actinic:block php="true">echo <actinic:variable name="IsPreviewMode" selectable="false" /> ? '<actinic:variable name="ProductPageName" encoding="perl" selectable="false" />' : '<actinic:variable name="CatalogURL" encoding="perl" selectable="false" />' . basename('<actinic:variable name="ProductPageName" encoding="perl" selectable="false" />');</actinic:block>');">Add to <br />Favourites!</a>
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Almost there!

      Thanks Norman, that almost works!
      I am now using this:-
      <a href="javascript:bookmarksite('WebSparky <actinic:variable name="ProductPageMetaDescription" />', '<actinic:variable name="ProductPageName" selectable="false" />')">Add this Page<br />to Favourites!</a>

      But now get a javascript error (as shown in the attached screen shot

      I tried puting in the URL of the website up to the page name eg:
      <a href="javascript:bookmarksite('WebSparky', '<http://www.websparky.co.uk/acatalog/actinic:variable name="ProductPageName" selectable="false" />')">Add to <br />Favourites!</a>
      But When I do this I don't get the javascript error, but the resulting shortcut points to a file on my !PC
      to summarize - when I use the product page name variable the page name is rendered correctly but the add to bookmarks fails with the permission denied error , if I use 'http://www.websparky.co.uk/acatalog/ProductPageName' I dont get an error, but the browser renders this as ''http://www.websparky.co.uk/acatalog/C:\Documents...(filesystem path to the page) and therfor the bookmark brings up page not found!

      Can you shed any light on this?
      Attached Files
      Last edited by Tezzflyer; 02-Nov-2012, 01:26 AM. Reason: Additional information
      Tezzflyer

      Websparky Electrical Goods

      http://www.websparky.co.uk

      Comment


        #4
        What you're doing with the URL won't work. ProductPageName is a full URL, not just the filename part.

        It would be best to use the code I gave, upload and let people know the address of a faulty page.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          Solved!
          I have incorparated some code from the Sellerdeck knowlege base, into the javascript - And it Worked! woohoo!
          here it is all put together.....

          <a href="javascript:bookmarksite('WebSparky <actinic:variable name="ProductName" />', 'http://www.Websparky.co.uk/acatalog/<actinic:block php="true" >
          $pageName = "<actinic:variable name="ProductPageName" />";
          <actinic:block if="%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e">
          $separator = "\\";
          </actinic:block>
          <actinic:block if="%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%20%3d%3d%20false" >
          $separator = "\\";
          </actinic:block>
          $pieces = explode($separator, $pageName);
          echo $pieces[count($pieces)-1];
          </actinic:block>')">Bookmark this Page</a>

          Thanks
          Tezzflyer

          Websparky Electrical Goods

          http://www.websparky.co.uk

          Comment


            #6
            Originally posted by NormanRouxel View Post
            What you're doing with the URL won't work. ProductPageName is a full URL, not just the filename part.

            It would be best to use the code I gave, upload and let people know the address of a faulty page.
            There was no faulty page - when uploaded as per your post, the javscript failed with the permission denied error.

            when I tried the other option, the javascript didn't fail - but pointed to a file on my PC rather than the website URL ! Very frrustrating!

            all sorted now though.

            Thanks for your help, it is very much appreciated, and without it I would not have got to a satisfactory conclusion.
            Tezzflyer

            Websparky Electrical Goods

            http://www.websparky.co.uk

            Comment


              #7
              Ahah. ProductPageName works differently on the live site than on Preview. I've amended my post #2 to work live. It's still just 1 line and would work on any site as it doesn't hard-code the catalog URL.

              Your KB code is weird. It has 2 redundant blockif's that both set $separator = "\\" regardless of whether it's preview or live. Try my amended code as it's much cleaner.
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #8
                Bingo!

                Originally posted by NormanRouxel View Post
                Ahah. ProductPageName works differently on the live site than on Preview. I've amended my post #2 to work live. It's still just 1 line and would work on any site as it doesn't hard-code the catalog URL.

                Your KB code is weird. It has 2 redundant blockif's that both set $separator = "\\" regardless of whether it's preview or live. Try my amended code as it's much cleaner.
                I wondered about the redundand blocks - but thought I would give it a go anyway, and it worked so I thought I would'nt try and break it!

                Your new line of code works a treat (but you knew that didn't you!) and is much easier to understand.
                Can't thank you enough for your help with this.
                so Thanks!
                Tezzflyer

                Websparky Electrical Goods

                http://www.websparky.co.uk

                Comment

                Working...
                X