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

    I’m working on 1.0.0-RC1
    i have on my site ’PERSONS’ and ’EXPERTISES". Now i want their expertise listed on a person page and viceversa but i woudn’t know how to do this.

    A) how can i populate a Dropdownbox TV in the PERSON template with all existing expertise pages? i guess i have to put some @SELECT in the ’Input Option Values:’ of the TV expertises but HOW?
    this wiki page ’http://wiki.modxcms.com/index.php/Template_Variable_Drop_Down_Menu’ doesn’t reveal how to implement the @BINDING or how to deal with a 2 column return

    B) say ive got this. now i can select some ’expertises’ for a person. but how do i acces this data on the ’PERSON’ template? a simple [[*epertises]] doesn’t seem to return a list of multiple expertises. Well maybe it does but i cant figure out how to ,lets say, list them in eg.<li>item</li>.

    C)Now assume even this challenge has been tackled i also need pages for the ’EXPERTISES’ and it has to be possible to list all persons that have a specific expertise on the ’EXPERTISE’ page.
    But How??

    tnx a lot... if you reply.
    R.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You’re using 2.0 (Revolution) tags in a 1.0 (Evolution) installation. TVs in 1.0 are [*...*]

      That said, you may want to use a snippet to format your TV value. Most TV lists are output as item||item||item, so you would need a snippet to explode() that and use the parts to make up whatever structure you wanted.
        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
        • 24629
        • 370 Posts
        Hi,

        when i put [*expertise*] (the TV) in my template it turns out as item1item2item3 in the pipelines aren’t there.
        so an $arr = explode("||", $expertises); doesn’t work.

        in my template i’ve got
        [!getExpertises?expertises=[*expertise*]!] 


        and the snippet getExpertises:

        <?php
           $arr  = explode("||", $expertises);
           for ($i= 0; $i < count($arr); $i++) {
                   echo $arr[$i].'ccc <br>';
          }
        ?>


        and Although the value in the dbase is ’item1||item2||item3’ [*expertise*] results in item1item2item3

        what am i doing wrong?
        tnx
        R.

          • 29774
          • 386 Posts
          I think what you’re trying to do is create relationships between documents rather than templates. I wrote a snippet called Related last year that handles this in a variety of ways.

          For your requirement you would need to:

          * Create folders in the site tree with your two sets of items, eg ’Expertise’ and ’People’
          * Create a ’person’ template and an ’expertise’ template
          * Fill the ’Expertise’ folder and the ’People’ folder with documents based on the appropriate template
          * Create a new TV called ’expertise’:
                - Input Type: use Check Box (can also be DropDown List Menu or Listbox)
                - Input Option Values: @EVAL return $modx->runSnippet(’Related’, array("parents"=>"4");
                  (replace the ’4’ with the actual document id of the ’Expertise’ folder)
                - Assign the TV to the People template
          * Now you will have a checkbox for each expertise on pages based on the ’Person’ template

          There is also another snippet called Quill that does much the same thing, and will also allow you to output select menus within your web pages as well. (In fact i would recommend it over my own snippet unless your relationships are many-to-many).

          http://modxcms.com/extras/package/?package=372
          http://modxcms.com/extras/package/?package=355

          To display your relationships you can use Ditto’s tag parameters, eg to output a list of people with a particular expertise on the expertise page put this in your expertise template:
          [!Ditto? &parents=`40` &depth=`1` &display=`all` &tagData=`expertise` &tagMode=`onlyTags` &tagDelimiter=`,` &tags=`[*id*]` &sortBy=`pagetitle` &sortDir=`ASC`!]
          


          (where 40 is the docid of the People container)

          To do the reverse and output the expertise assigned to an individual on the person’s page you can use Ditto again in the person template:

          [!Ditto? &documents=`[*expertise*]` &depth=`1` &display=`all` &sortBy=`pagetitle` &sortDir=`ASC`!]
          



            Snippets: GoogleMap | FileDetails | Related Plugin: SSL