We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16085
    • 203 Posts
    Using:

    • MODX Revolution 2.1.3-pl
      getResources v1.4.0

    • jQuery 1.5
      jQuery UI 1.8

    How do I automate the class switching using getResources!?

    For example I have a list, the first item is active the rest inactive. I've tried using an if output but it sets all the li's to inactive:
    <li [[+id:eq=`[[*id]]`:then=` class="active"`:else=` class="inactive"`]]><a href="#[[+alias]]">#[[+pagetitle]]</a></li>

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Well, the placeholder's +id value refers to the ID of the resource being processed by getResources. The TV *id value always refers to the ID of the resource containing the getResources call. Since getResources will never be processing its own parent page, then that idea won't work. Most JQuery rotators and slideshows have a way of specifying the item to be opened on load, and automatically assigns the appropriate classnames.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 16085
        • 203 Posts
        @sottwell,

        tried changing my input/output filter:
        <li [[+idx:eq=`1`:then=`class="active"`:else=`class="inactive"`]]><a href="#[[+alias]]">#[[+pagetitle]]</a></li>

        which set the first <li> to active and the rest to inactive but as you've said jQuery is doing it's own thing so I need to look into that more. Besides got a taste of the input/output feature.

        I think like other before I'm trying to use getResources as the Wayfinder alternative and the IF post got me thinking I could do something similar with getResources. I did however come across TabControl which possibly would work using getResources, though not yet tried it.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          When setting up these JQuery tabs and rotators and what-not, the thing to do is take the demo source and manipulate the getResources or Ditto or whatever listing snippet you want to use to produce the same HTML output as is used in the demo. Let the javascript handle the rest of it. A bit of CSS customization is all you ever need to do.

          These JQuery plugins have all kinds of configuration options and all MODx needs to do is to provide the necessary content for the javascript and the css to work with.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org