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. Link to comment https://forums.phpfreaks.com/topic/44843-errors-in-my-little-snippet/ Share on other sites More sharing options...
jscix Posted March 29, 2007 Share Posted March 29, 2007 "/\.pdf(\?.*)?$/i",$file->filename that should work.. Link to comment https://forums.phpfreaks.com/topic/44843-errors-in-my-little-snippet/#findComment-217775 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 Link to comment https://forums.phpfreaks.com/topic/44843-errors-in-my-little-snippet/#findComment-217783 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... Link to comment https://forums.phpfreaks.com/topic/44843-errors-in-my-little-snippet/#findComment-217785 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!! Link to comment https://forums.phpfreaks.com/topic/44843-errors-in-my-little-snippet/#findComment-217790 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? Link to comment https://forums.phpfreaks.com/topic/44843-errors-in-my-little-snippet/#findComment-217799 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. Link to comment https://forums.phpfreaks.com/topic/44843-errors-in-my-little-snippet/#findComment-217805 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.