Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

BR tags in admin submissions

(Page 1 of 4)
> >
Quote Reply
BR tags in admin submissions
Hi,
I would like to know what I have to alter to make it so that when I paste in text in the admin section of adding a new link, so that it automatically places the line break html code,
so, if I put in

this place is all about me [br]
and what my dog does in it's spare time[br][br]


I dont want to type in the [br] tags is there someway to get links 2.04sql to insert the line breaks just the way I paste the text into the description?

Also, in the old links it wasnt difficult to use the detailed info page, how do I get that to work in the 2.04 sql version?

Note: < br > was replaced with [br] to make it show up in the forum here.


Quote Reply
Re: BR tags in admin submissions In reply to
regexp will do the trick...

Like:

Code:

$rec->{'ColumnName'} =~ s/\n/< br >/g;


Regards,

Eliot Lee Wink
http://anthrotech.com/
Quote Reply
Re: BR tags in admin submissions In reply to
For the detailed page link use:

<a href="<%build_root_url%>/Detailed/<%ID%>.html">Detailed View!</a>



________________________
Eraser
Insight Eye
http://www.insighteye.com
Quote Reply
Re: BR tags in admin submissions In reply to
< br > tags are so 1997.

my $placeholder = "<p>";
$placeholder .= $input->{Description};
$placeholder =~ s/\n|\r/<\/p>\n<p>/g;
$placeholder .= "</p>";


$input->{'Description'} = $placeholder;

Quote Reply
Re: BR tags in admin submissions In reply to
Could someone explain (in plain english) how one can make LinksSQL recognize line breaks as line breaks? I think the answer is already on this page, but I have no idea how to implement it. Anyone game for explaining this? :)

Quote Reply
Re: BR tags in admin submissions In reply to
Hi,

It's not Links SQL, it's HTML! HTML, or any browser such as Internet Explorer ignores line breaks. So if you have line breaks in your data and display that in HTML, your browser is going to ignore it.

What you want, is to convert line breaks to <BR> tags which your browser will display as breaks. You need a bit of code to do this. Lets say your field name is 'Review' that has a couple paragraphs in plain text that you want to convert to HTML for display. If you add to globals the tag:

Review_Formatted =>
Code:
sub {
my $tags = shift;
my $review = $tags->{Review};
$review =~ s/\n/<BR>\n/g;
$review = GT::CGI::html_escape($review);
return $review;
}

and then use <%Review_Formatted%> on your template, it will show up nice and formatted. =)

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: BR tags in admin submissions In reply to
Hey Alex :)

So, I added what you suggested:

Column name is Full_Story
so I added a globals tag called Full_Story_Formatted
and used:

sub {
my $tags = shift;
my $Full_Story = $tags->{Full_Story};
$Full_Story =~ s/\n/<BR>\n/g;
$Full_Story = GT::CGI::html_escape($Full_Story);
return $Full_Story;
}


in the globals description. I then called the column Full_Story with the tag of Full_Story_Formatted and what I get is a bunch of text that shows the <br>'s in the body of the text as seen through a browser. In other words, it didn't insert line breaks, it just inserted <br>'s into the output and I can see them in IE when looking at the detailed page.

Am I implementing this wrong?

Quote Reply
Re: BR tags in admin submissions In reply to
I may be way off but try removing:

$Full_Story = GT::CGI::html_escape($Full_Story);


Quote Reply
Re: BR tags in admin submissions In reply to
Bingo.

Thanks Paul :)

Quote Reply
Re: BR tags in admin submissions In reply to
Oops, no, change:

$Full_Story =~ s/\n/<BR>\n/g;
$Full_Story = GT::CGI::html_escape($Full_Story);

to:

$Full_Story = GT::CGI::html_escape($Full_Story);
$Full_Story =~ s/\n/<BR>\n/g;

The escape is used so if your story contains < or >, the browser doesn't think it's html.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: BR tags in admin submissions In reply to
Thanks, that worked too. :)

Quote Reply
Re: BR tags in admin submissions In reply to
Hello again. I know this wasn't specified in my first request, but I want my editors, upon submitting a "link" or an article, to be able to specify bold or italics while this text accepts a line break.

I've got the line breaks down now thanks to Alex's code snippet. But now, it won't parse any html code for bold or italics. What you got up your sleeve for this problem, Alex? :)

Quote Reply
Re: BR tags in admin submissions In reply to
Try:

$Full_Story =~ s,\[(/?b)\],<$1>,g;

and

$Full_Story =~ s,\[(/?i)\],<$1>,g;

So you'd use [b][/b] and [i][/i]


Last edited by:

PaulWilson: Sep 9, 2001, 4:44 AM
Quote Reply
Re: BR tags in admin submissions In reply to
Thanks Paul,

Just to clarify: Do I add those two lines to the global I defined as Full_Story_Formatted

so now it would look like this:

sub {
my $tags = shift;
my $Full_Story = $tags->{Full_Story};
$Full_Story = GT::CGI::html_escape($Full_Story);
$Full_Story =~ s/\n/<BR>\n/g;
$Full_Story =~ s,\[(/?i)\],<$1>,g;
$Full_Story =~ s,\[(/?b)\],<$1>,g;
return $Full_Story;
}

IS this correct? It seems like what this does is diss-allow any html unless we specify it is allowed, is this correct?

Quote Reply
Re: BR tags in admin submissions In reply to
The way you have it above it will turn newlines into <BR> tags and b and i markup tags will be converted into the proper html

Eg.......

Entering:

Hello my name is

[b]Paul[/b]

and I like [i]food[/i]

.....would result in......

Hello my name is <BR> <b>Paul</b> <br> and I like <i>food</i>



Quote Reply
Re: BR tags in admin submissions In reply to
.......and woiuld look like:

Hello my name is

Paul

and I like food


Quote Reply
Re: BR tags in admin submissions In reply to
If you wish to allow more options you could just use....

$Full_Story =~ s,\[([/\w]+)\],<$1>,g;

So then anything inside [] would be converted to html including

[b]
[i]
[br]
[hr]
[li]

etc.......



Quote Reply
Re: BR tags in admin submissions In reply to
Yippee!

Last edited by:

Evoir: Sep 9, 2001, 12:25 PM
Quote Reply
Re: BR tags in admin submissions In reply to
Does

$Full_Story =~ s,\[([/\w]+)\],<$1>,g;

Take care of bold, italics and all the others you listed? Or do I add this to the global in addition to the bold and italics?

Thanks again Paul, this is really helpful!

Quote Reply
Re: BR tags in admin submissions In reply to
Just that one line will do everything apart from tags with attributes...

But things like...

[li]
[table]
[tr]
[td]
[br]
[li]
[hr]
[script]
[style]

....and more... would all work.



Quote Reply
Re: BR tags in admin submissions In reply to
Hokay so I'm bored.......

Using this:

$str =~ s,\[([/\w\s#"=;:{}]+)\],<$1>,g;

Will support stuff like:

[style]
.{ font-family: verdana; font-size: 10px; }
[/style]

Hello my name is [b]Paul[/b] and [i]I like FOOD![/i]

Hmm what [br][br]is [font color="#ff3333"]your[/font] name?

[li]Bill?[br]
[li]Ben?



Quote Reply
Re: BR tags in admin submissions In reply to
Thanks again.

How would I add this to the resource section? I think this thread would be really helpful for others, too.

Quote Reply
Re: BR tags in admin submissions In reply to
one last ninny question:

If I use Alex's code snippet:
$Full_Story =~ s/\n/<BR>\n/g;

with your code snippet:
$str =~ s,\[([/\w\s#"=;:{}]+)\],<$1>,g;

will the system allow folks to have breaks in lines

like this and will they show up as line breaks, as well as allowing all the [b] codes you just demonstrated?

This is so cool Paul. Really really helpful!

Does one cancel out the other at all?


Last edited by:

Evoir: Sep 9, 2001, 12:55 PM
Quote Reply
Re: BR tags in admin submissions In reply to
Both lines should work together.

Alex's code will convert hidden newlines into br tags and my code will convert [br] into <br>

I'm expecting a reply from Alex any minute hammering my code :)

You can add the thread to the resources section by going to Support > Resources > Add/Update


Quote Reply
Re: [PaulW] BR tags in admin submissions In reply to
ok...another addition to this request.

Is there a way to get this global to recognize email adresses and url's? & automaically parse an email adress or url, so if I type evoir@mail.com, it would automagically make it a hyperlink? (All within this global, of course.)

Couldn't hurt to ask. Cool

> >