We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21671
    • 244 Posts
    Hi All,
    on http://uniquenantucket.com/portfolio.html i have a ditto call that populates a wedding planner’s portfolio page. For each wedding that she planned there are different vendors involved. Somtimes there are florists, photographers, event suites, reception sites, rehearsal dinners. So I set up a bunch of Template variables so that for each wedding the planner could fill in all of the applicable template variables. Thus in my chunk, the Tvs are text inputs, the widget is html generic tags, that are all dd tags. In each tv I define the class of each tv, but have left the id field blank.
    However when the chunk outputs there are multiple instances of the same (and thus non validating) id. How do I remove the id?
    Here is the ditto call

    [!Ditto?startID=`48` &tpl=`MyEventChunk` &extenders=`summary` &display=`all`  &debug=`0` &dateSource=`mydate` &sortBy=`menuindex` &dateFormat=`%c` &sortDir=`asc` !]


    with the MyEventChunk code as
    <div class="port_vendors span-3">
    	
    <h5 class="port_title"> <a href="[~[+id+]~]"> [+pagetitle+] </a> </h5>
    <a class="noBorder" href="[~[+id+]~]"><img src="[+jobImg+]" alt="the Happy Couple" /></a>
    
    <a href="[~[+id+]~]"> +go to page</a>
    	
    <dl>
    <dt>Photos courtesy of:</dt>
    [+photographer+]
    <dt>Flowers:</dt>
    [+florist+]
    <dt>Ceremony:</dt>
    [+ceremony+]
    <dt>Reception:</dt>
    [+reception+]
    </dl>
    </div>
    


    and when page outputs the html it looks like:
    <div class="port_vendors span-3">
    	
    <h5 class="port_title"> <a href="bodenstab-boyle.html"> Bodenstab / Boyle </a> </h5>
    <a class="noBorder" href="bodenstab-boyle.html"><img src="assets/images/portbodenstab.jpg" alt="the Happy Couple" /></a>
    
    <a href="bodenstab-boyle.html"> +go to page</a>
    	
    <dl>
    <dt>Photos courtesy of:</dt>
    <dd id="tvphotographer" class="photgrapher">Claudia Kronenberg</dd>
    <dt>Flowers:</dt>
    <dd id="tvflorist" class="florist">Soiree Floral</dd>
    <dt>Ceremony:</dt>
    <dd id="tvceremony" class="ceremony">First Congregational Church</dd>
    <dt>Reception:</dt>
    <dd id="tvreception" class="reception">Wingspread Lane</dd>
    </dl>
    </div>


    How do I remove the ids ie id="tvflorist" from the output?

    Many Thanks in advance,

    Noah
      • 22427
      • 793 Posts
      It’s hard to guess if you won’t give us your [*florist*] TV ... wink
        • 33337
        • 3,975 Posts
        Check to see if you are using Widgets with your TVs? to do this edit your TV and see what you have on that screen.
          Zaigham R - MODX Professional | Skype | Email | Twitter

          Digging the interwebs for #MODX gems and bringing it to you. modx.link
          • 16278
          • 928 Posts
          There’s no need to set a Widget in your TV - why not leave it blank and apply the class in your template?
          <dl>
          <dt>Photos courtesy of:</dt>
          <dd class="photographer">[+photographer+]</dd>
          etc.
          </dl>

          KP
            • 36527
            • 120 Posts
            Hi KP,

            I came across the same issue when getting the HTML Generic Tag to spit out LI’s - it places an ID on each rendered item. So needs a core fix in real terms.

            The same issue is happening here with the DD’s.


              • 21671
              • 244 Posts
              hi all,

              I’ve attached an image of the florist tv below.


              @kp52, I thought of doing it your way previously but I have another tv that I use on each invidual wedding’s page that is used to select all the different vendors for the wedding. It is called [*vendor_select*] It set up with the following input values:
              Photographer =={{photographer}}||Flowers=={{florist}}||Rehearsal Dinner=={{rehearsal}}||Ceremony=={{ceremony}}||Reception=={{reception}}
              

              Each of the chunks are formatted like this {{florist}} chunk:
              <dt>Flowers:</dt>
              [*florist*]
              


              this [*vendor_select*] appears in the template as:
               <dl>[*vendor_select*]</dl>
              


              So my goals were to:

              • have a manager page like the attached manager page that would make it easy for the client to select which vendors helped to put the wedding together
              • make it easy for the client to enter names of vendors into idiot proof text input Tvs
              • have the data populate the ditto call on the main portfolio page
              • have the data populate the dl on each wedding’s portfolio page (see attached portfolio image)
              • I wanted to use the generic html widget instead of kp’s suggestion because with the generic widget if there is no input, there is no dd outputted.

              All these things worked out fine, but when I went to validate my page, I saw that there was an id attached to each dd, which then invalidated the page. you can see the results at this link:
              http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Funiquenantucket.com%2Fportfolio.html

              I am all ears for a better solution and hope to learn a more simpler and more elegant way of solving the problem.

              many thanks in advance,

              -Noah







                • 3749
                • 24,544 Posts
                The quickest fix would probably be to find the code that generates the DD ID, add a counter variable, and append the value of the counter to the end of the ID so they would all be unique.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 10449
                  • 956 Posts
                  Does the Tag ID field accept snippets? If yes, write a little "random id" snippet and just enter [!uniqueDIV!]. If that’s not possible, wrap the snippet in a {{chunk}}

                  Something like

                  $divID = '';
                  $abc = range("a", "z");
                  $ABC = range("A", "Z");
                  shuffle($abc);
                  shuffle($ABC);
                  $num = mt_rand(1, 94839);
                  $a = $abc[0];
                  $A = $ABC[0];
                  $sha = sha1("$num$a$A");
                  $cut = substr($sha, 0, 3);
                  $divID = "$a$A$num$cut";
                  return($divID);
                  
                    • 16278
                    • 928 Posts
                    I think you want no ID attribute at all, rather than modifying the auto-generated ones to make them vaild. Two ways to get rid of them would be: (1) hack the core files to suppress generation of ID if none is specified in the TV definition, or (2) adapt to the fact one will be generated, and delete it when the placeholder is used.
                    (1) is undesirable, (2) is entirely possible using PHx, which is bundled with Ditto even if you don’t have it as a plugin.
                    You can create the following custom PHx modifier as a snippet called it phx:stripId
                    <?php
                    // phx:stripId - remove ID attribute from tag in placeholder output
                    
                    $out =  preg_replace('/(<.+)\sid=".+"(.+)/U','\1\2',$output);
                    
                    return $out;
                    ?>

                    This uses a regular expression to leave the id attribute behind and return the string preceding and following it. (The U following the regex is needed to make it "ungreedy" and stop at the quotes following the ID name). In your template, you add the modifier within the placeholder thus:
                    [+photographer:stripId+]

                    laugh
                    KP
                      • 21671
                      • 244 Posts
                      smiley

                      Hi All,

                      Thank you so much for all your help!

                      @kp52 - That was exactly what I was looking for!

                      MANY MANY THANKS!

                      -Noah
                      here is the validation link http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwww.uniquenantucket.com%2Fportfolio.html