dmendez12 Posted July 22, 2011 Share Posted July 22, 2011 Hi, I have this piece of code that I can´t make it work. To give you a little background, this is not in a php file itself, it is part of a component in Joomla, which is based in php, and there is a section where I can input PHP code to modify some output. The only thing I am pending is to add target="_blank" so it can open in New Window. I have tried all sort of things and nothing is working. Here is the line that it WORKS but I need to add the target. $items["title"]["value"] = "<a href=".$items['title']['value'].">Download Document</a>"; Please help me! Quote Link to comment https://forums.phpfreaks.com/topic/242602-problem-with-and-variable/ Share on other sites More sharing options...
cssfreakie Posted July 22, 2011 Share Posted July 22, 2011 have a look at the following, note though i added a line break on purpose so you can see what parts this link consists of. <?php $items['title']['value']= 3; // just some value because i have no idea what is in there. $items['title']['value'] = //note the single quotes!! '<a href="' //note the single quotes around the first part and the double quotes to surround the attribute property .$items['title']['value']. //note the appending dots '" target="blank">Download Document</a>'; //note the single quotes around the last part and the double quotes for the attribute property echo $items['title']['value']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/242602-problem-with-and-variable/#findComment-1246023 Share on other sites More sharing options...
dmendez12 Posted July 22, 2011 Author Share Posted July 22, 2011 Thanks but that didn´t work. I have tried that. Just to make it clear, the echo of that is a filename. echo $items['title']['value']; // the result of that is FILENAME.pdf Any other idea? Or is there a way to declare the target attribute of <a> somewhere else? Quote Link to comment https://forums.phpfreaks.com/topic/242602-problem-with-and-variable/#findComment-1246029 Share on other sites More sharing options...
cssfreakie Posted July 22, 2011 Share Posted July 22, 2011 the above just works, so you might want to run as stand alone. and see why it works also pay attention to the difference between double and single quotes! Quote Link to comment https://forums.phpfreaks.com/topic/242602-problem-with-and-variable/#findComment-1246036 Share on other sites More sharing options...
QuickOldCar Posted July 22, 2011 Share Posted July 22, 2011 $items['title']['value'] = "<a href='".$items['title']['value']."'>Download Document</a>"; echo $items['title']['value']; Quote Link to comment https://forums.phpfreaks.com/topic/242602-problem-with-and-variable/#findComment-1246038 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.