We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18913
    • 654 Posts
    Okay, here’s a little problem that a day’s worth of work hasn’t cracked.

    I have a template variable called "breakingnews", defined as text and associated with the Marquee widget. It stops on mouse hover and scrolls horizontally. It is assigned to a template and in the document associated with this template the TV’s value is

    @EVAL return $modx->runSnippet('Ditto', array('parents'=>14, 'tpl'=>'breakingnews_chunk'));
    


    At the moment, all the chunk does is return [+introtext+].

    And that’s where the problem arises.

    First, introtext is essentially a textarea variable. Can anyone tell me how I can squish it into one line which will scroll across the (variable width) content area of the page? I.e. if the line is longer than the content width, I don’t want it to wrap around. I’ve tried changing the call to run my own snippet which strips out ’\r\n’. But unless I did something wrong, that doesn’t work. Examing the generated frame source suggests that there aren’t any newlines. But it is in a tag that identifies it as a textarea with rows. So I need to figure out how to undo that, in a sense.

    The second problem is that I’d like someone to be redirected to the page from which the introtext is retrieved when they click on the marquee. The default Ditto template provides a hotlink, but only associates it with the title, I think. Can the marquee itself be associated with a page?

    Thanks in advance for any pointers, thoughts, etc.

    MattC
      • 18913
      • 654 Posts
      I guess the second part of the problem can be dealt with by EVALing a custom snippet that looks like this :

      <?php
      $url = $modx->makeUrl('14');
      $doc = $modx->getDocument('14', '*', '1');
      return '<a href="'. $url .'"><b>' . $doc['pagetitle'] .'</b> '.$doc['introtext'] . '</a>';
      ?>
      


      There are styling issues (i.e. all the text is underlined, rather than just - say - the page title) that would need to be cleaned up. Clicking the marquee does take one to the relevant document though.

      Still don’t know how to turn it all into one line, though.
      Matt

      UPDATE :
      Now this chunk looks like this :
      <?php
      $url = $modx->makeUrl('14');
      $doc = $modx->getDocument('14', '*', '1');
      $output .= '<a href="'. $url .'" style="border: none;"><b>' . $doc['pagetitle'] .'</b>   </a><a href="'. $url .'" style="
          background-color: transparent;
          border: none;
          color: inherit;
      //    font: inherit;
      //    list-style: none;
      //    margin: 0;
      //    outline: none;
      //    padding: 0;
      //    text-decoration: none;
      //    text-indent: 0;
      "  >' . $doc['introtext'] . '</a>';
      return $output;
      ?>
      

      ... thanks to hints on undoing default html styling found here :
      http://acjs.net/weblog/2004/09/15/undo_default_html_styles/

      So my second problem is taken care of.
        • 18913
        • 654 Posts
        A bit more insight now. It would appear that the width element of the template variable controls the wrapping of the text. So if you set it to something like 1000%, the text is in fact on one line. So the type of field that the info is coming from isn’t the issue.

        The problem is that this width seems to be relative to the screen/page width, not the content area. So at a large size, it overflows into any columns one might have set up. Also, it seems to internally pad out the text, resulting in the loop not appearing to start again until text that is 1000% wide is processed.

        What I’d like to do is get it to feed into the current content frame as a loop.

        Hopefully that clarifies the matter a bit or prompts some ideas.
        MattC