Display random reusable component?

Options

Does anybody know if it's possible to use an S tag configuration to display a random reusable component in the eCRM? I need to display a story and related image at random in the page wrapper. Note: I can't do JUST an image, it has to be image AND text, and there's also some code, so a reusable component would be the best option.

Thanks!

Tagged:

Comments

  • The only way I could think of doing this offhand is to use javascript. Something like:

    <style>

    .random { display: none; }

    </style>

    <div id="ru1" class="random">

    resusable content 1

    </div>

    <div id="ru2" class="random">

    resusable content 2

    </div>

    <div id="ru3" class="random">

    resusable content 3

    </div>

    <div id="ru4" class="random">

    resusable content 4

    </div>

    <script>

    var rndmInt = Math.floor(Math.random()*4)+1;

    document.getElementById( "ru" + rndmInt ).style.display = "block";

    </script>

  • Adrian Cotter:

    The only way I could think of doing this offhand is to use javascript. Something like:

    <style>

    .random { display: none; }

    </style>

    <div id="ru1" class="random">

    resusable content 1

    </div>

    <div id="ru2" class="random">

    resusable content 2

    </div>

    <div id="ru3" class="random">

    resusable content 3

    </div>

    <div id="ru4" class="random">

    resusable content 4

    </div>

    <script>

    var rndmInt = Math.floor(Math.random()*4)+1;

    document.getElementById( "ru" + rndmInt ).style.display = "block";

    </script>

    The S55 tag returns a random number (syntax ]), so you could set a session variable to a random number then check it for each possible value like so:



    ]]]::1::

    <div id="ru1" class="random">

    resusable content 1

    </div>

    ::

    ]::2::

    <div id="ru2" class="random">

    resusable content 2

    </div>

    ::

    ]::3::

    <div id="ru3" class="random">

    resusable content 3

    </div>

    ::

    ]::4::

    <div id="ru4" class="random">

    resusable content 4

    </div>

    ::]]]]]]]]

  • Noah Cooper:

    The S55 tag returns a random number (syntax ]), so you could set a session variable to a random number then check it for each possible value like so:



    ]]]::1::

    <div id="ru1" class="random">

    resusable content 1

    </div>

    ::

    ]::2::

    <div id="ru2" class="random">

    resusable content 2

    </div>

    ::

    ]::3::

    <div id="ru3" class="random">

    resusable content 3

    </div>

    ::

    ]::4::

    <div id="ru4" class="random">

    resusable content 4

    </div>

    ::]]]]]]]]

    nice!

Categories