• [SOLVED] Quick Recipe - Evolution - Directory of items #

  • designetic Reply #1, 1 year ago

    Reply
    Good resource found through Google:

    http://www.gregorysmart.com/2009/07/03/a-modx-ditto-directory/

    Original Post
    Hi,

    Any advice or input on how I should do this. I need a quick recipe for a small directory listing (not exceeding 200). I am hoping that MODx would do and will offer what I think would be a good solution.

    The directory items will each appear as follows:

    [Item Image]
    [Description]
    [Contact Details]
    [Tag List]
    [URL]

    Generally, I suppose I will make use of:
      [list]
    • Ditto - to list and summarise each item
    • TVs - for each field associated with the list item(Image, details, URL etc)
    • A container(document)- to display the listing of each item
    [/list]

    Would this be proper use of MODx?

    Thanks,
    dn


  • designetic Reply #2, 1 year ago

    Reply
    Hope someone can assist me here.

    I followed through the article I posted above and created the templates,documents and containers as advised. I thought I understood most of it as it seems fairly straight forward.

    I do not understand the reasoning behind the last item under the title "The Snippet(s)". Why do we call a placeholder?
    The one with the following

    code:

    [+docLink:isnot=``:then=`<a href="[+docLink+]" title="[+pagetitle+]'s Website" target="_blank">[+pagetitle+]'s Website</a>`+]
    


    The part talks about placeholders yet in the beginning we created TVs. Is docLink some

    sort of plugin like pHX? or its a placeholder that relates/is converted from a TV that has been created(as

    one of the directory item fields). Ditto converts TVs to placeholders?

    As an example:

    I created the following TVs to hold the field values:

    [*CompanyName*] - Text
    [*Email*] - Input Type: Email
    [*Website*] - Input Type: URL
    


    Then in the {{directoryFolder}} chunk, I had the following Ditto Call:

    [!Ditto? &startID=`[*id*]` &depth=`2` &tpl=`physicianTPL` &sortBy=`lastName` &sortDir=`asc` &summarize=`10` &paginate=`1` paginateAlwaysShowLinks=`1`!]
    


    Taking a que from the example given, in my {{physicianTPL}} Chunk I have:

    <p>
    Company Name:[+CompanyName:isnot=``:then=`[+CompanyName+]`+]<br/>
    Email:[+Email:isnot=``:then=`CompanyEmail`+]<br/>
    Website:[+Website:isnot=``:then=`<a href="[+CompanyWebsite+]" title="[+pagetitle+]'s Website" target="_blank">[+pagetitle+]'s Website</a>`+]<br/>
    </p>
    <hr />
    


    It outputs 10 iterations of

    Company Name:
    Email:
    Website:
    


    ...without the actual expected field/TV values.

    Note that I have only created ONE directory entry as a test and expected to see just that one.

    What have I done wrong? And why do we call placeholders e.g [+Website+] when we created TVs e.g.

    [*Website*]

    Forgive me for the ignorance




  • jaredloman Reply #3, 11 months, 4 weeks ago

    Reply
    Hey Designetic..

    I'll take a whack at helping you out...

    First of all..just to make sure.. are you using Evo or Revo? This tutorial appears to be designed for Evo, so if you are using Revo, you are going to run into problems.

    Secondly, In my opinion, I think that ModX will work great for your needs!

    Without fully going over the tutorial in the article you linked..I think I should be able to answer some of your questions.

    To answer your main question.. The reason you are using placeholders as opposed to directly calling the TV's is because Ditto uses placeholders to get TV content from separate resources. If you were to call a TV in a ditto template like "" you will only get the contents of the TV in the current resource as opposed to the resources ditto is calling.

    I'm not sure what your directory structure looks like, but let's just say your ditto call is on Resource id1 and you have 5 documents that are children of Resource id1. Assuming these resources have a template, and that template is connected to the given TV's, you should be able to fill in the TV content for each of the child documents. Your directory structure doesn't have to be identical to this, but if you want to use "[*id*]" for your startId, the documents that you want to get information from have to be children of the resource your ditto call is in. Otherwise...just specify the resource id that is the parent of the child documents.

    Also..In your Ditto call, I'd remove the "sortBy" for the moment. "I THINK" ditto needs either a default ModX field or TV to sort by so unless you have already figured this out, it probably won't work anyhow.

    Regarding your template.. I don't think it's necessary to have the pHX call in it for your situation (except for the url). You could just do:
    <p>
    Company Name:[+CompanyName+]<br/>
    Email:[+CompanyEmail+]<br/>
    Website:[+CompanyWebsite:isnot=``:then=`<a href="[+CompanyWebsite+]" title="[+pagetitle+]'s Website" target="_blank">[+CompanyName+]'s Website</a>`+]<br/>
    </p>
    <hr />

    The reason for this, is that you don't want an empty "<a>" element in your document if the particular company doesn't have a website. The above method will only add the "<a>" tag if the company has a website.

    In order to simply get your current template working you'd at the least need to do this:
    <p>
    Company Name:[+CompanyName:isnot=``:then=`[+CompanyName+]`+]<br/>
    Email:[+CompanyEmail:isnot=``:then=`CompanyEmail`+]<br/>
    Website:[+CompanyWebsite:isnot=``:then=`<a href="[+CompanyWebsite+]" title="[+pagetitle+]'s Website" target="_blank">[+CompanyName+]'s Website</a>`+]<br/>
    </p>
    <hr />

    As far as to what you've done wrong.. Well again..It's really hard to say without seeing your directory structure, but if I had to guess, I'd bet it's a mix of the issue with the Ditto TPL (physicianTPL), and maybe having the Ditto call in the wrong place..or not having the directory hierarchy setup correctly.

    Hopefully this gives you a start in resolving your issue!

    -Jared


  • designetic Reply #4, 11 months, 2 weeks ago

    Reply
    Hi Jared.

    My apologies for the very late reply. Thanks for your help.

    I abandoned it completely as I failed to make it work. Fortunately, the author also has an alternative solution, which worked very well with no problems:

    http://www.gregorysmart.com/2010/03/04/dittophx-directory-wcross-categorization/

    dn