We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40785
    • 9 Posts
    Hello MODXer's,

    I followed the first parts of the MIGX tutorial Bruno graciously put together and I'm able to add my product image, product name, description, price and sku number to the resource it belongs in. We're working with a toy store. So, we've got 100's and 100's of tiny little products. Made more sense to organize the products into groups assign those groups to a resource instead of making 100's of individual product resources on a product by product basis. Everything is working great except for those resources that contain 50 or more products for a given group. The natural alternative of having to make users scroll for ever is to paginate the content. Preaching to the choir, I'm sure. Anyways...

    I see tons and tons of examples of how to "paginate" using getResources and getPage. Paginating the content within a Resource that's fed by MIGX-TV output seems to be a unique request. The fact that I'm new to MODX and just starting to learn PHP I'm sure is most the problem as I'm unable, after two weeks of research, able to make heads or tails of even how to begin putting any type of code together to start testing.

    I only found one posting that was nearly identical to what we're needing to do. I've scoured the internet, forums and documentation and still unable to bridge the connection. And unfortunately the person that posted wasn't using MIGX-TV (I believe), and at the same time never responded back to Bruno's helpful comments.

    Entitled:
    Need help breaking single resources into multiple pages with getPage

    Url:
    http://forums.modx.com/thread?thread=14992

    Quote from: Mr. at May 04, 2011, 10:03 PM

    This is probably documented somewhere, but I've missed it. I totally get how to use getPage/getResources to break a listing of resources into multiple pages, but I haven't been able to figure out how to break a *single* resource (ie. a long blog post) into multiple pages.

    Bruno responded with:
    Quote from: Bruno17 at Jun 10, 2011, 10:19 AM
    you can try this:

    use this snippet, which breaks the content into parts delimited by '{BREAK}' and outputs an json-string.


    <?php
    //[[!splitContentToJson]]
    $delimiter = $modx->getOption('delimiter',$scriptProperties,'{BREAK}');
    
    $content = $modx->getOption('content',$scriptProperties,$modx->resource->getContent());
    $contents = explode($delimiter,$content); 
    if (count($contents)>0){
        foreach ($contents as $content){
            $output[]['content']=$content;
        }
    return $modx->toJson($output);
    }


    then you can use this json-string in getImageList from MIGX-TV like that:

    [[!getImageList? &value=`[[splitContentToJson]]`&tpl=`@CODE:[[+content]]` ]]


    and its possible to use getImageList together with getPage the same way as you would do it with getResources.

    [[!getPage? 
    &element=`getImageList` 
    &value=`[[!splitContentToJson]]`
    &tpl=`@CODE:[[+content]]`
    &limit=`1`
    ]]
    <div class="pageNav">[[!+page.nav]]</div>




    Given the information below can someone please get us pointed in the right direction. Thanks for any helpful pointers.

    We're Running MODX 2.2.5

    In my "migxtestTV" Input Options the only values I filled in are:
    Input Type: migx

    Form Tabs:
    [{"caption":"Info", "fields": [
    {"field":"product_name","caption":"ProductName","inputTV":"product_nameTV"},
    {"field":"description","caption":"Description","inputTV":"product_descriptionTV"},
    {"field":"price","caption":"Price","inputTV":"priceTV"},
    {"field":"sku_number","caption":"SkuNumber","inputTV":"sku_numberTV"}
    ]},
    
    {"caption":"Image", "fields":[
    	{"field":"title","caption":"Alt-Title"},
        {"field":"image","caption":"Image","inputTV":"imageTV"}
    ]}
    ]
    



    Grid Columns:
    [
    {"header": "ImgAlt-Title", "width": "160", "sortable": "true", "dataIndex": "title"},
    {"header": "Image", "width": "160", "sortable": "false", "dataIndex": "image","renderer": "this.renderImage"},
    {"header": "ProductName", "width": "160", "sortable": "true", "dataIndex": "product_name"},
    {"header": "Description", "width": "160", "sortable": "true", "dataIndex": "description"},
    {"header": "Price", "width": "160", "sortable": "true", "dataIndex": "price"},
    {"header": "SkuNumber", "width": "160", "sortable": "true", "dataIndex": "sku_number"}
    ]
    

    Output Options: Default

    Content Snippet Call:
    [[!getImageList? &tvname=`migxtestTV` &tpl=`thumbTpl`]]


    We get the output were looking for on the resource, we just don't understand how to paginate all the outputted content Within the Resource. I see the properties listed on the FrontEnd MIGX docs and know this is doable, I just don't see how without some kind of example and limited knowledge of php programming/scripting.

    Attaching SceenShot of Nav Menu:
    [ed. note: modx-rocks last edited this post 11 years, 6 months ago.]
      • 4172
      • 5,888 Posts
      doesn't this work?

      [[!getPage?
      &element=`getImageList`
      &tvname=`migxtestTV` 
      &tpl=`thumbTpl`
      &limit=`20`
      ]]
      <div class="pageNav">[[!+page.nav]]</div>



      btw:

      It would also be possible and perhaps the better option, to use childresources for your Products. Hide them from tree and use a MIGXdb - TV to manage them. [ed. note: Bruno17 last edited this post 11 years, 6 months ago.]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 40785
        • 9 Posts
        Hi Bruno,

        Thanks for your response.


        Quote from: Bruno17 at Oct 29, 2012, 10:46 AM
        doesn't this work?

        [[!getPage?
        &element=`getImageList`
        &tvname=`migxtestTV` 
        &tpl=`thumbTpl`
        &limit=`20`
        ]]
        <div class="pageNav">[[!+page.nav]]</div>


        You ROCK Bruno!! Hahahahaha.... (laughing at myself) Yes, this works. I knew it would be something simple but not that simple. This is awesome. Thankyou!!

        Off Topic:
        Ahhhhh... I see some light at the end of the tunnel. Thanks laugh

        A snippet called from within a snippet. Cool...
        Now I see what they mean when they say "getPage" is a wrapper snippet. To get the solution you provided to work correctly, and not double the amount of content being displayed on the public view, I had to remove the "getImageList" snippet call and replace it with the getPage snippet call you provided. Having both calls on the same page showed some interesting results. smiley

        Off Topic:
        Bruno, if you don't have time to answer the following I totally understand. It's more or less a mental note to myself as I'm learning, and I just happened to come upon it using MIGX-TV.
        Somewhat off topic but something I wanted to share with you Bruno, in the hopes that you can possibly clear up some confusion.

        "Snippet Calls"
        What determines "placement/location" of snippet calls? EG... sometimes I see examples of snippet calls being placed in the actual resource page "content area", like with your "getImageList" snippet call. Then, sometimes I see snippet calls being made within templates...

        ...How does a person determine, when or where, the most appropriate place for a snippet call is to be made from? Resource or Template?

        Quote from: Bruno17 at Oct 29, 2012, 10:46 AM

        btw:

        It would also be possible and perhaps the better option, to use childresources for your Products. Hide them from tree and use a MIGXdb - TV to manage them.

        Interesting... Let me ask you something (as I ask myself, "am I setting up MODX for this store in the most effecient manner?")

        Right now, the front end menu is somewhat confusing on our test site.

        I will definitely follow through with your suggestion. Currently for the Store owner to do CRUD on products they have the "migxtestTV" interface to use, which is very nice, but they have to do a lot clicking and traversing back and forth in the resource tree before they actually start doing some CRUD work. If they only had and handful of products this wouldn't be an issue.

        Would or can MIGXdb be setup so they can do ALL of their product CRUD operations within one area within the MODX manager? Ideally I was hoping they could have an interface that allowed them to do the following for CRUD operations.

        Example:


        • First thing they do is select (from a dropdown list) which main category resource they want to work with. And from there choose which child resource within that main category resource they want to work with.
        • Once that's chosen that would make a call to populate a window showing all the resources listed for that given child resource. << like I see in the backend "migxtestTV" I built.
        • From here they can right click on product and choose to update or delete. Per normal.
        • From here they can drag and drop to rearrange product order as the public see's them listed. Per normal.
        • And/Or from here click on a Tab that would allow them to add new products like I have MIGX-TV setup now.

        Currently on the front end, when you hover over the main horizontal "Products Categories" menu, a drop down menu is shown with all the main toy categories. Clicking on one these brings you to a page with all the child categories for the given parent category. It's these child categories that actually house content. But nothing is shown yet and they still have to click on a child category to see some actual content. This is less than ideal from a user experience viewpoint. I'll get this sorted. Hopefully MIGXdb can help resolve all the little issues and make this as efficient as can be for both management and front end user experience. smiley


        Curious as to what the public view see's and how this is layed out on the screen. Grid view, List view? Choice?
        Ahhhh. Never mind. The MODX doc's portion of the site was down for a while. Just got access again.
        Often we have the problem with lots of Resources in the Resource-Tree to be very confused at some point and we wish, we would have a better way to manage them in a paginated grid view.

        Since we don't see many examples in the MODX docs of a visual representation of what's actually outputted to the users screen, would you be interested in allowing me to submit an example mini MIGX-TV tut to you, so others can see what can be achieved with just a little coding and your awesome snippets?

        Thanks Bruno. You've been a tremendous help. When I'm lurking through the forums doing research I'm always learning something from your responses to others. laugh [ed. note: modx-rocks last edited this post 11 years, 6 months ago.]
          • 4172
          • 5,888 Posts
          What I would recommend for your project is:

          Put your categories and subcategories into Resources, as you have it now.
          Create a xpdo-schema for your products.
          Put your products in a custom-table.

          Use a MIGXdb - CMP to manage them all. Its easy to have filters for categories and subcategories for the grid, and its easy to create listboxes in the update/create-window where you can choose categories and subcategories (your category-Resources)

          Use bloX to make the frontend-stuff.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 40785
            • 9 Posts
            Great. Thanks for the useful tips Bruno. Much appreciated. Time for MIGXdb. smiley