bradkenyon Posted April 29, 2008 Share Posted April 29, 2008 I ran into this problem before, but I think its a little harrier this time. An example would be putting this into a textarea field: <a href="http://www.yahoo.com">yahoo.com</a> Then when I display it to update it, it displays as: yahoo.com</a>"><a href="http://www.yahoo.com">yahoo.com</a> I want it to display as what I typed it in, then when it displays in the news page, to display as yahoo.com, as a link. Any help would be appreciated, as I have looked into htmlentities, htmlspecialchars_decode, and htmlspecialchars. Quote Link to comment Share on other sites More sharing options...
Fadion Posted April 29, 2008 Share Posted April 29, 2008 Dont know if im getting this right, but what im understanding is u want the url to be parsed and instead of showing just a text, show it as an url. U could have a regular expression who searches for "www.something.com" or "something.com" and replace it with <a href="http://www.something.com/">www.something.com</a> Quote Link to comment Share on other sites More sharing options...
bradkenyon Posted April 29, 2008 Author Share Posted April 29, 2008 I'll type in the a href = into the textarea as well, so I want it to display <a href="http://www.yahoo.com">yahoo.com</a> in the update text area form, and a linked yahoo.com within the site side of the news item. so when the user views it on the website, they will see yahoo.com as a linked item they can click to go to yahoo.com, and when you go to the backend to update the news item, it will display as <a href="http://www.yahoo.com">yahoo.com</a>, so i want the site side code to translate the <a href=""> and </a> to a link. Quote Link to comment Share on other sites More sharing options...
Fadion Posted April 29, 2008 Share Posted April 29, 2008 Writing html elements in a textarea, unless u used htmlentities(), theyll show as html elements. I think i get what u want to achieve by replacing the html link with just a website.com, but it would be technically overwhelming. Basically: - Retrieve the text from the database - Run a regex to remove html anchor tags - Display the data to the input field - When the form submits, run again a regex to add html anchor tags to the text, wherever it finds "website.com" - Update the database If this is for a client or someone who isnt technically profficient, id suggest using bbcode similiar to those used in forums. So a link would be: [url=http://www.yahoo.com]Yahoo[/url] You could only parse the bbcode on the showing part, but leave it in the backend, as it is pretty easy to understand. Im sure there are pretty good tutorials out there to achieve this. Quote Link to comment Share on other sites More sharing options...
bradkenyon Posted April 29, 2008 Author Share Posted April 29, 2008 all i want to do is be able to type in html code as well as plain text and for the html code to display as it should. so for an image, i want <img src="/images/image.jpg"> to display the image in the news item, and when i go to edit that news item, it shows the html code. that is all. 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.