Announcement

Collapse
No announcement yet.

Rotating testimonials with javascript

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

    Rotating testimonials with javascript

    I'm trying to add some rotating text for testimonials and it's not working. Here's an example of the code I'm using straight from codepen:
    https://codepen.io/jasondavis/pen/BaoEC

    Here's the page I'm trying to place it on:
    http://dev.imagescienceassociates.com/consulting.html

    I think the problem is where I'm putting the JS code, which is here:
    user interface > settings > client dimensions

    If this isn't the correct spot then does anyone know where I should be placing the code to get it to work?

    Thanks!

    #2
    JS is client side, so its location in terms of template execution is irrelevant. Because of this, javascript such as this is usually placed at the very end of the html document. Inspector shows a JS variable error for a variable not being populated.

    You might also consider rendering this with SMT code which might make updating easier.

    Wrap each quote in an IF statement testing for a value of say "QUOTEx" where x is a number.

    Use RANDOM(x) to select a number from 1 to how every many quotes there are, then use that number to create the QUOTEx variable


    <mvt:assign name="g.GetQuote" value="'QUOTE'$g.valueFromRandom"/>

    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


      #3
      Hi Bruce,

      I don't usually write any SMT code so this would be a little tricky for me. If I can't get the original way to work (or a similar JS solution) then I'll give your idea a try. If I do how would I write the IF statement? What would be an example of that? Thanks!

      Comment


        #4
        <mvt:assign name="g.randnum" value="Random('3')"/>


        <mvt:if expr="g.randnum EQ 1">

        This is random one.

        <mvt:elseif expr="g.randnum EQ 2">

        This is random two.

        <mvt:elseif expr="g.randnum EQ 3">

        This is random three

        <mvt:elseif expr="'...etc...'">

        so on...

        </mvt:if>
        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


          #5
          So I put this on my page just like this and nothing happened:

          -----

          <mvt:assign name="g.randnum" value="Random('3')"/>


          <mvt:if expr="g.randnum EQ 1">

          This is random one.

          <mvt:elseif expr="g.randnum EQ 2">

          This is random two.

          <mvt:elseif expr="g.randnum EQ 3">

          This is random three

          </mvt:if>

          --------

          In your first post you wrote this; <mvt:assign name="g.GetQuote" value="'QUOTE'$g.valueFromRandom"/>

          Is that supposed to go somewhere? Sorry, I need to know where everything goes and how it's formatted. Thanks.

          Comment


            #6
            Yea, don't ask me questions before the third cup of coffee...use this:

            <mvt:assign name="g.randnum" value="Random('3')"/>



            <mvt:if expr="g.randnum EQ 0">

            This is random one.

            <mvt:elseif expr="g.randnum EQ 1">

            This is random two.

            <mvt:elseif expr="g.randnum EQ 2">

            This is random three

            <mvt:elseif expr="g.randnum EQ 3">

            This is random four

            </mvt:if>

            Issue was, Random(3) will return 0, 1, 2, OR 3. (Forgot that Miva's Random can return a 0)

            You can ignore the other code example, this is simplier to follow.
            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


              #7
              I think that 3rd cup of coffee did the trick, it works great now. Thanks Bruce!

              Comment

              Working...
              X