We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26401
    • 247 Posts
    Howdy folks

    I needed to look through all the template variables to make sure all the files linked properly.
    I spent a bit of time on this, so maybe I can save someone else the hassle
    here’s the snippet I’ve created, that I call from an unpublished resource

    note that I have specified the tmplvarid as 13, this will differ in your case


    echo "<b>Check if all files are linked properly<br/></b>";
    
    $sql = $modx->db->select("value,contentid", $modx->getFullTableName('site_tmplvar_contentvalues'),"tmplvarid=13");
    $resultArray = $modx->db->makeArray( $sql );
    
    foreach($resultArray as $item)
    {
    	$link=$item["value"];
    	//echo "-". file_exists($link)."\n";
    	if(file_exists($link)){
    		echo 'ok -'.$item["contentid"].' - file "'.$link.'" exsists<br/>';
    	}else{
    		echo ' x -'.$item["contentid"].' - file "'.$link.'" does not exsist<br/>';
    	}
    }
    



    hope this helps smiley