We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21475
    • 80 Posts
    Yeah!
    It works again, many thanks grin
    Now i got strange characters (\r and \n), but they may come from the datas stored in the base, i’m going to check that.
    Strange, because in the 0.92 they didn’t appeared.

    Thans again for your help! smiley

    Edit : In fact, these escape characters don’t come from the DB, and stripslashes() don’t seem to have any effect...?!
    Well, i’ll see tomorrow smiley
      • 25663 MODX Staff
      • 12,272 Posts
      Any updates here?
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 22303 MODX Staff
        • 10,725 Posts
        Quote from: nicpan at Dec 27, 2006, 01:40 PM

        Yeah!
        It works again, many thanks grin
        Now i got strange characters (\r and \n), but they may come from the datas stored in the base, i’m going to check that.
        Strange, because in the 0.92 they didn’t appeared.

        Thans again for your help! smiley

        Edit : In fact, these escape characters don’t come from the DB, and stripslashes() don’t seem to have any effect...?!
        Well, i’ll see tomorrow smiley
        Yes, any new information on this would be helpful. I have a few other potential solutions to try, but I’m not having any luck reproducing the output of escaped characters with any of them. Can you explain more about this @EVAL script or post it here so I can get the full scenario?
          • 21475
          • 80 Posts
          Hi,
          I still have the problem. I forgot to write you back embarrassed
          In fact, i have 3 tvs, 1 is OK, the 2 others are not.
          The first one extract quotes from the db to display them in a widget (Ticker):
          @EVAL
          $reponse = $modx->db->select("*", "citations", "", "rand()", "3");
          $out = '';
          while ($cit = mysql_fetch_array($reponse))
          	{
          		if ($cit['date_citation'] == 0000-00-00)
          			{
          			$date_cit = "?";
          			}
          		else {
          			$date = $cit['date_citation'];
          			list( $annee, $mois, $jour ) = explode( '-', $date ); 
          			$date_cit = $jour . '/' . $mois . '/' . $annee;
          			}
          		$texte = stripslashes($cit['texte_citation']);
          		$out .= '<p class="textecitation">';
          		$out .= '<strong>' .$cit['auteur_citation']. '</strong>, le ' .$date_cit. ' :';
          		$out .= '<br />';
          		$out .= '<em>' .$texte. '</em>';
          		$out .= '</p>||';
          	}
          return $out;

          The widget works fine, but the displayed text have some \’, \r\n that shouldn’t be display.

          The second one display a random image from the plogger gallery.
          @EVAL
          $reponse = $modx->db->select("*", "plogger_pictures", "", "rand()", "10");
          $out = '';
          while ($img = mysql_fetch_array($reponse))
          	{
          	$id=$img["id"];
          	$path=$img["path"];
          	$number=strrpos($path, '/');
          	$number=$number+1;
          	$url=substr($path, $number);
          		$out .= '<p class="RandomImage">';
          		$out .= '<a href="plogger/?level=picture&id=' .$id. '"><img src="plogger/thumbs/' .$id. '-' .$url. '" /></a>';
          		$out .= '</p>||';
          	}
          return $out;

          For this one, normally displayed in a ticker widget, nothing appears.
          But i have this in the source :
          <script type="text/javascript">	document.setIncludePath('manager/media/script/bin/');	document.addEventListener('oninit',function(){document.include('dynelement');document.include('ticker');});	document.addEventListener('onload',function(){	var o = new Ticker('tvRandomImage','30000','1'); 	o.addMessage('<p class=\\\"RandomImage\\\"><a href=\\\"plogger/?level=picture&id=2\\\"><img src=\\\"plogger/thumbs/2-pict6965.JPG\\\" /></a></p>');	o.addMessage('<p class=\\\"RandomImage\\\"><a href=\\\"plogger/?level=picture&id=22\\\"><img src=\\\"plogger/thumbs/22-pict6985.JPG\\\" /></a></p>');	o.addMessage('<p class=\\\"RandomImage\\\"><a href=\\\"plogger/?level=picture&id=10\\\"><img src=\\\"plogger/thumbs/10-pict6973.JPG\\\" /></a></p>');	o.addMessage('<p class=\\\"RandomImage\\\"><a href=\\\"plogger/?level=picture&id=16\\\"><img src=\\\"plogger/thumbs/16-pict6979.JPG\\\" /></a></p>');	o.addMessage('<p class=\\\"RandomImage\\\"><a href=\\\"plogger/?level=picture&id=6\\\"><img src=\\\"plogger/thumbs/6-pict6969.JPG\\\" /></a></p>');	o.addMessage('<p class=\\\"RandomImage\\\"><a href=\\\"plogger/?level=picture&id=4\\\"><img src=\\\"plogger/thumbs/4-pict6967.JPG\\\" /></a></p>');	o.addMessage('<p class=\\\"RandomImage\\\"><a href=\\\"plogger/?level=picture&id=13\\\"><img src=\\\"plogger/thumbs/13-pict6976.JPG\\\" /></a></p>');	o.addMessage('<p class=\\\"RandomImage\\\"><a href=\\\"plogger/?level=picture&id=8\\\"><img src=\\\"plogger/thumbs/8-pict6971.JPG\\\" /></a></p>');	o.addMessage('<p class=\\\"RandomImage\\\"><a href=\\\"plogger/?level=picture&id=15\\\"><img src=\\\"plogger/thumbs/15-pict6978.JPG\\\" /></a></p>');	o.addMessage('<p class=\\\"RandomImage\\\"><a href=\\\"plogger/?level=picture&id=5\\\"><img src=\\\"plogger/thumbs/5-pict6968.JPG\\\" /></a></p>');	o.addMessage('');	});</script><script type="text/javascript">Ticker.Render('tvRandomImage','100%','100%','','');</script>

          As you can see, i have too much \

          These TVs were OK in the 0.92 (even if the code might be largely improved wink)

          Well, i’m not really a php coder so i might have done mistakes, hope these informations are helpfull...
          By the way, if you have some advices / improvement about these TV, i’ll be glad read this!
          Oh, and forgive me about my english... i’m not as good as davidm smiley
          Thanks!
            • 33372
            • 1,611 Posts
            You can also just put your @EVAL code in a snippet and run it from the TV like so:

            @EVAL return $modx->runSnippet(’yourSnippetName’);

            or like so if you need to pass variables to the snippet:

            @EVAL return $modx->runSnippet(’yourSnippetName’, array(’onePassedVar’=>11,’anotherPassedVar’=>56));

            I almost think that this should be the standard way to execute PHP code from a TV and multi-line @EVALs should be deprecated because it’s much easier to organize and edit your code this way.
              "Things are not what they appear to be; nor are they otherwise." - Buddha

              "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

              Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
              • 21475
              • 80 Posts
              Thanks for the advice smiley
              I’ll try this out.
              Any news for the \r\n and \ unwanted characters?
                • 22303 MODX Staff
                • 10,725 Posts
                Quote from: nicpan at Jan 03, 2007, 02:41 PM

                Thanks for the advice smiley
                I’ll try this out.
                Any news for the \r\n and \ unwanted characters?
                No, but it does not seem related to the multi-line @binding issue. This is a problem with the widgets you are using in my best estimation.
                  • 21475
                  • 80 Posts
                  Hi!

                  I made the modifications, indeed its easier to manage these snippets smiley
                  For the character problem, it seems that your right, it’s probably due to the Ticker Widget.

                  Thanks again for your help, i’ll wait for the next version smiley