We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3528
    • 2 Posts
    Hi there,
    I’ve got the following snippet code (using modx1.0.2)
    <?php 
    error_reporting(E_ALL); 
    ini_set("display_errors", 1); 
    
    $out2 = null; 
    $picdir = "./_g/"; 
    
    function getRandomPic($photos,$dirname) { 
    $out = ""; 
    $rand =rand(0, count($photos)); 
    $out .= "<div style=\"text-align: center;\">"; 
    $out .= "<img src=\"".$photos[$rand]."\" alt=\"\" style=\"border-width: 0;-moz-border-radius: 15px;-webkit-border-radius: 15px;float: left\" >"; 
    $out .= "<br />".$dirname; 
    $out .= "</div><br clear=all>"; 
    return $out; 
    } 
    
    function dir_list($d){ 
    foreach(array_diff(scandir($d),array('.','..')) as $f)if(is_dir($d.'/'.$f))$l[]=$f; 
    return $l; 
    } 
    
    function file_list($d,$x){ 
    //preg_match("/".$x."/i", $f) 
    foreach(array_diff(scandir($d),array('.','..')) as $f)if(is_file($d.'/'.$f)&&(($x)?@ereg($x.'$',$f):1))$l[]=$d."/".$f; 
    return $l; 
    } 
    
    $verzeichnisse = dir_list($picdir); 
    foreach ($verzeichnisse as $verzeichnis) { 
    $photos = file_list($picdir."".$verzeichnis,"_thumb.jpg"); 
    $out2 .= "<a href=\"bilder-galerie.html?p=".$verzeichnis."\">".getRandomPic($photos,$verzeichnis)."</a>"; 
    } 
    echo $out2; 
    ?> 
    


    Template
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>[(site_name)] | [*pagetitle*]</title>
    
    <link rel="stylesheet" href="style.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="jquery.twitter.css" type="text/css" media="all">
    <link rel="stylesheet" href="jquery.spotlightwrapper.css" type="text/css" media="all">
    <link rel="stylesheet" href="jquery.fancybox-1.2.6.css" type="text/css" media="all">
    <link rel="stylesheet" href="jquery.cj-image-flipbox.css" type="text/css" media="all">
    
    <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="jquery.twitter.js"></script>
    <script type="text/javascript" src="jquery.spotlightwrapper.js"></script>
    <script type="text/javascript" src="jquery.cj-image-flipbox.js"></script>
    
    <!-- <script type="text/javascript" src="jquery.fancybox.easing.1.3.js"></script> //-->
    <script type="text/javascript" src="jquery.fancybox-1.2.6.pack.js"></script>
    <script type="text/javascript" src="jquery.config.js"></script>
    
    </head>
    <body>
    <div id="wrapper">
    	<div id="header">
    		<div id="logo">
    			<h1><a href="./home.html">familie</a></h1>
    		</div>
    	</div>
    	<!-- end #header -->
    	<div id="menu">
    		[!menu!]
    	</div>
    	<!-- end #menu -->
    	<div id="page">
    		<div id="content">
    			<div id="banner"><img src="images/img07.jpg" alt="" /></div>
    			<div class="post">
    				<h2 class="title">[*longtitle*]</h2>
    				<div class="entry">
    					[*#content*]
    					<!-- <p class="links"><a href="#" class="more">Read More</a>        <a href="#" class="comments">Comments (33)</a></p> //-->
    				</div>
    			</div>
    			<div style="clear: both;"> </div>
    		</div>
    		<!-- end #content -->
    		<div id="sidebar">
    			<h2>Gezwitscher</h2>
    			[!UserTwitLink!]
    			<div id="twitter"></div>
    			<ul>
    				<li>
    					<h2>Neuigkeiten</h2>
    					<ul>
    					[!NewsListing?newsid=13&title_only=1&show_date=1!]
    					</ul>
    				</li>
    			</ul>
    		</div>
    		<!-- end #sidebar -->
    		<div style="clear: both;"> </div>
    	</div>
    	<!-- end #page -->
    </div>
    <div id="footer-content">
    	<div class="column1">
    		<h2>Zufallsbilder</h2>
    		<p>[!Zufallsbild!] </p>
    	</div>
    	<div class="column2">
    		<ul class="list">
    			<li id="dropmenu"><a name="dropmenu"></a><h2>Online:</h2>
    			[!OnlineUser!]
    			</li>
    		</ul>
    	</div>
    </div>
    <div id="footer">
    	<p> Design by <a href="http://www.nodethirtythree.com">nodethirtythree</a> and <a href="http://www.freecsstemplates.org">Free CSS Templates</a>.</p>
    </div>
    <!-- end #footer -->
    </body>
    </html>
    

    When inserted into a blank template it works like a charm, but as soon as I change the page template to my own, the server sends a blank page, no error messages or anything to give me a hint.
    What’s the problem here?
    Regards,
    blafsel
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Does your template work without the snippet call? Does the Reports -> System Events log have anything to say?
        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
        • 1122
        • 209 Posts
        2blafasel
        You had to be careless in some way with inserting this snippet, because I imported both your template and snippet into my environment (1.0.2, too) and it gives me regular output. Due to the lack of appropriate stylesheets, the output I get is not very beautiful, but it occurs with no errors.
          • 3528
          • 2 Posts
          too bad. i can´t get any clue what the problem is. the template is working, the php code is working but the combination of the two gives no result.
          what else could i try?
          regards,
          blafasel