kevincompton Posted March 29, 2007 Share Posted March 29, 2007 I'm trying to have it show the pdf icon if there is a pdf attached to the node. Heres the code: <?php foreach($node->files as $file){ if(preg_match('.pdf$',$file->filename)) print l('<img src="files/icons/pdf.gif"/>',$file->filepath);} ?> heres my errors: warning: preg_match(): No ending delimiter '.' found in /var/www/html/CEC/themes/abac/node.tpl.php on line 11. Quote Link to comment Share on other sites More sharing options...
jscix Posted March 29, 2007 Share Posted March 29, 2007 "/\.pdf(\?.*)?$/i",$file->filename that should work.. Quote Link to comment Share on other sites More sharing options...
kevincompton Posted March 29, 2007 Author Share Posted March 29, 2007 ok its showing, thanks! But its showing the text, not the actual image. How do I get it to show the linked image? heres the page http://nufish.com/CEC/?q=taxonomy/term/2 i want it to show the icon Quote Link to comment Share on other sites More sharing options...
jcbarr Posted March 29, 2007 Share Posted March 29, 2007 Would probably need to see some more code... Quote Link to comment Share on other sites More sharing options...
kevincompton Posted March 29, 2007 Author Share Posted March 29, 2007 heres the whole section... <?php if ($page == 0): ?> <h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?> <?php foreach($node->files as $file){ if(preg_match("/\.pdf(\?.*)?$/i",$file->filename)) print l('<img src="http://nufish.com/CEC/files/icons/pdf.gif"/>',$file->filepath);} ?> </a></h2> <?php endif; ?> thanks guys!! Quote Link to comment Share on other sites More sharing options...
AndyB Posted March 29, 2007 Share Posted March 29, 2007 <a href="/CEC/?q=files/4-102%264-103.pdf"><img src="http://nufish.com/CEC/files/icons/pdf.gif"/></a> That's from view-source of the url you gave. See the problem? Quote Link to comment Share on other sites More sharing options...
kevincompton Posted March 29, 2007 Author Share Posted March 29, 2007 Yes i can see how that wouldn't work How do i fix it? In case this helps, this is going through a drupal site. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.