We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8830
    • 98 Posts
    Hi,

    I'm creating a simple image gallery with MIGX, and I'm using a custom pager in the frontend.
    The gallery/pager is supposed to have "categories", and this is how I have done it:

    MIGX form:
    [
    {"caption":"Gallery item", "fields": [
        {"field":"type","caption":"Type","inputTV":"migxGalleryItemType"},
        {"field":"category","caption":"Category"},
        {"field":"image","caption":"Image","inputTV":"migxGalleryImage"}
    ]}
    ]


    So first you choose the item type (image or category), and then you can enter the category name OR choose the image. Works fine so far. Simple to use.

    What I need is to set this up for the frontend for which I need two type of counters.

    This is how it's supposed to look:

    Main images category: 1 2 3
    Other images category: 1 2

    Using +idx in the rowTpl will count all migx rows, both images and categories, which of course is useless for my display needs.

    This is how the rowTpl could look like:

    [[+type:is=`category`:then=`<h1>[[+category]]</h1>`:else=``]]
    
    [[+type:is=`image`:then=`<a href="#" data-cycle-cmd="goto" data-cycle-arg="[[+idx_only_images]]">[[+idx_only_since_previous_category]]</a>`:else=``]]


    I need one counter/iterator to count only rows with type 'image'. (to hook it up with the data-cycle-arg)
    And an other counter that only counts since previous category (i.e. resets with every category).

    How do I do these special counters? A snippet that calls getImageList where I can get the migx items and count them the way I want? I'm not sure how to go further.
    Maybe there is an other simpler way to achieve what I want?

    Thanks.

    /E

    This question has been answered by Bruno17. See the first response.

    [ed. note: Eminos last edited this post 12 years, 9 months ago.]
      • 4172
      • 5,888 Posts
      you can nest MIGX - TVs into each other

      the outer one to create the categories.
      the inner one for adding the images to each category.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 8830
        • 98 Posts
        That would probably solve one of the problem, I would then have the counter for the images of ONE category (unique +idx per category).
        But I still need an other counter for ALL images in all the categories, available at "image-level-tpl".

        And also a solution with nested MIGXs would not allow the user to simply drag and drop images between categories (by dragging the image-row bellow the category-row). A little bit more complicated to use.
        • discuss.answer
          • 4172
          • 5,888 Posts
          ok, I see.

          A simple way would be to pre-prepare the json with another snippet, where you do the countings and add them as additional fields.

          the call would then look like that:

          [[getImageList?
          &value=`[[prepareTheJson? &value=`[[*yourTV]]`]]`
          &tvname=`yourTV`
          &tpl=`yourTpl`
          ]]


          preparing the json, could also be done with a plugin for OnDocFormSave
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!