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

BR tags in admin submissions

(Page 3 of 4)
> > > >
Quote Reply
Re: [Paul] BR tags in admin submissions In reply to
In Reply To:
Code:
sub {
my ($full_Story) = GT::CGI::html_escape($_[0]->{Full_Story}) =~ s/\n/<BR>\n/g;
$full_story =~ s|(\S+@\S+\.\S+)|<a href="mailto:$1">$1</a>|g;
$full_story =~ s|(http://\S+)|<a href="$1" target="newwin">$1</a>|g;
return $full_story;
}


Hi Paul,

Can you tell me how I'd go about making this a global that I could pass "any" field into for formatting - not limiting it just to Description or full_Story in this case?

For eg. If I wanted to pass in "Description" or "ShortDescription" or "full_Story" or any other field I've got - this sub will handle them all?

Cheers,
Regan.
Quote Reply
Re: [ryel01] BR tags in admin submissions In reply to
My Xtended Add-Modify-Delete plugin will be able to post links with formatted text (formatted now means: formatted only with newlines). It converts all newlines to <BR> if needed. It is an optional feature, and can be turned off by admin anytime.

The plugin is not available yet. It is still under development. But almost all planned features was implemented & finished already. The admin interface and install script is still missing.

I can also implement, the linking feature of email or http addresses, if some of you ask for this feature.

If you are interested in a such plugin, watch the following thread for news about development state of the Xtended Add-Modify-Delete plugin:
[PLUGIN] Xtended Add.Modify.Delete plugin (XAMD) development news

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [ryel01] BR tags in admin submissions In reply to
You would change $_[0]->{Full_Story} to $_[0]->{$field} and then use:

my $field = shift;

Then you can do:

<%change_to_html($some_field)%>

I think that should work.
Quote Reply
Re: [Paul] BR tags in admin submissions In reply to
Hi!
Yes, I have previously attempted (with others on this thread) to resolve the [br] problem. Having seen that a page on this subject has been added to the resources section, and having re-read all the contributions to this thread, allow me to insist that for me at least the solutions advocated are not satisfactory. Let me add that I am working from a Mac - this may be significant. Here's my case study:

Implementing the following global (based on Alex's which satisfies others):
<%Content_Formatted%>

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

If I enter the following into my Content field:

this is all <B>about</B> me[cr] [cr] => an ordinary carriage return
and this is my second line after a carriage return

Using the global as indicated above, when viewing <%Content_Formatted%> on my browser (IE 5.15) I obtain:

this is all <B>about</B> me<BR>
and this is my second line after a carriage return

You will see that the global has NOT translated either the carriage return - or Bold tags.

Now if I delete from the global the line:
$content = GT::CGI::html_escape ($content);
the following is displayed:

this is all about me (the 'about' is, yes, in bold)

and this is my second line after a carriage return

You will see that the bold tag has been implemented but that now the [cr] has been translated not into a <BR> but a <P> !!

Finally if I display the Content field (ie. not via the global), I obtain:

this is all about me (the 'about' is, yes, in bold)
and this is my second line after a carriage return

and where the [cr] is a proper <BR> !!!

Be assured that I have read/re-read and repeatedly tested all the suggestions of this thread and do not find the solution. This is why I mention I am working from a Mac - when I presume most of you are on PCs. Is this a factor? (All this is important because I have large numbers of long texts where I want to avoid additional hard-coding with html tags.)

I hope someone can provide the explanation and solution.
Charly
Quote Reply
Re: [charly] BR tags in admin submissions In reply to
I am on a mac, and I use LSQL as a content management tool, rather than a link directory. Here is the thing: once you use this global, you cannot use html tags as well. You must choose. Use the global and no html, OR use html and no global. Not both.

I did, however, come up with a solution that allows me to mostly use the global, and sometimes NOT use the global (if I WANT) to use html on a certain page. It is very simple.

Create a global that accepts line breaks, [b], [i] and hotlinks urls and email addresses. This is for general submissions. Sort of like using markup on the forums here. (BTW: Full_Story is my Detailed column name)

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;
$Full_Story =~ s,(\S+@\S+\.\S+),<a href="mailto:$1">$1</a>,sg;
$Full_Story =~ s,(http://\S+),<a href="$1" target=_blank>$1</a>,sg;
$Full_Story =~ s,\[([/\w]+)\],<$1>,g;
return $Full_Story;
}

Then, create a new column in my Links Table, called: html
the colum has two radio buttons: html and markup, I set it default to markup.

Now, in my detailed.html template, I create an If statement.:
<%--this is where LSQL will format the text and accept line breaks and stuff. Defined by a template global in the admin--%>
<br><%if html eq "markup"%><%full_story_formatted%><%endif%>

<%--this is where LSQL will NOT format the text and accept line breaks and stuff. you can use html--%>
<%if html eq "html"%><%Full_Story%><%endif%>

Now, all links are defaulted to "markup" and will use the global, but if I sometimes want to use html, I just check the box when submitting or modifying a link, and it switches back to the old way of calling a column in the database.

Whew. I hope this helps!
You can't have it both ways at the same time!
Evoir

Last edited by:

Evoir: Sep 15, 2002, 10:23 AM
Quote Reply
Re: [Evoir] BR tags in admin submissions In reply to
I guess you can have it both ways if you use the following global (I took your and changed it slightly):
Code:
sub {
my $tag = shift;
$tag = GT::CGI::html_escape($tag);
$tag =~ s/\n/<BR>\n/g;
$tag =~ s,\[(/?i)\],<$1>,g;
$tag =~ s,\[(/?b)\],<$1>,g;
$tag =~ s,(\S+@\S+\.\S+),<a href="mailto:$1">$1</a>,sg;
$tag =~ s,(http://\S+),<a href="$1" target=_blank>$1</a>,sg;
$tag =~ s,\[([/\w]+)\],<$1>,g;
return $tag;
}
then you can just use

<%my_global($Full_Story)%>

in you template (or you can put <%Full_Story%> if you don't want the substitutions done). This works with any other tag, not only Full_Story.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] BR tags in admin submissions In reply to
Yogi,

are you saying that if I use your global (above) and use this in my detailed page:

<%my_global($Full_Story)%> I can then mix html and markup on my pgaes? Like if I wanted to add more complex html, like a nested table or a form (in html) I could as well as using markup like: [b] [i] and line breaks? I guess I don't understand, becasue if it is parsing urls and email addresses, then those could not be part of the html. [:/]

Curious....

Last edited by:

Evoir: Sep 15, 2002, 10:36 AM
Quote Reply
Re: [Evoir] BR tags in admin submissions In reply to
Evoir, thanks for the assistance. I'm testing it out. By the way, I'm also managing a content management system and it's with DBMan SQL.

What you made me realise is that I had probably misunderstood some basic terms. Correct me/ confirm my new understanding:

What you term 'HTML' is ordinary text that is processed by our gossamer engined sw to produce good old HTML that shows up nice in our browsers. and what you call 'mark up' is text where WE give it HTML tags BEFORE it is given to the sw.

Am I correct? (I fear I got it the other way around!!)

I'll test and get back on to you, because there's another aspect to this problem, namely the importing of text data from our dtabase programs (mine's Filemaker Pro)... more later, thanks
Charly
Quote Reply
Re: [charly] BR tags in admin submissions In reply to
well, I created a column, and called it html (just a name) and within it, I created two choices html/markup

Markup uses the global that recognizes , line breaks and urls and email addresses. I used the term markup because GF uses that term when you post on the forum here.

html uses the standard column (that allows you to use html tags in it) but does not understand what line breaks are or is.

Honestly, they are just names that I gave things. I hope that doesn't confuse it more.

The idea is that based on which choice you make when adding a "link" you can have it either use the markup global, or not. This way, when my editors want to add a story, they can do so pretty easily. Urls and email addresses are hotlinked automatically, line breaks are recognized. But sometimes I want to add pages that have a table in it, or a form, and I would choose the "html" option, and have it bypass the global.

Smile took me a while to figure it out, but it is a really simple solution.
Quote Reply
Re: [Evoir] BR tags in admin submissions In reply to
Hi again,
Here is the answer to my problem of invisible carriage returns, solution provided by Paul (thanks)

my global is called <%convert0B% and converts all occurences of hex 0B in the data records that I import into my DBMan SQL database.

sub {
my $tags = shift;
my $content = $tags->{Content};
$content =~ s/\x0B/<br>/sg;
return $content;
}

Now my un-tagged straight text (with paragraphs) gets correctly displayed - with paragraphs.
Phew, that was a long search!
Thanks all
Quote Reply
Re: [Alex] BR tags in admin submissions In reply to
Thank you everyone to provide skills. I add a bit to it.

sub {
my $tags = shift;
my $content = $tags->{Content};
unless ($content =~ /<br>/i or $content =~ /<p>/i) {
$content =~ s/\n/<BR>\n/g;
$content =~ s,(\S+@\S+\.\S+),<a href="mailto:$1">$1</a>,sg;
$content =~ s,(http://\S+),<a href="$1" target="_blank">$1</a>,sg;

}
return $content;
}

Then the system can smartly decided wether convert line break. If text contain <br> or <p> (it seemed a html content), it will show as is. Otherwise (it seemed a plain text), it will convert line break.
Quote Reply
Re: [cfox] BR tags in admin submissions In reply to
Hi,

I have a small problem with the conversion of URL's.

I use the following Global:

Code:
sub {
my $tag = shift;
$tag =~ s/\n/<BR>\n/g;
$tag =~ s,\[(/?i)\],<$1>,g;
$tag =~ s,\[(/?b)\],<$1>,g;
$tag =~ s,(\S+@\S+\.\S+),<a href="mailto:$1">$1</a>,sg;
$tag =~ s,(http://\S+),<a href="$1" target=_blank>$1</a>,sg;
$tag =~ s,\[([/\w]+)\],<$1>,g;
return $tag;
}

However - if a URL looks like:
http://www.oracle.com/me with a <br> right after it (or even worse some text) then the following URL is created...

<a href="http://www.oracle.com/me<BR>" target=_blank>http://www.oracle.com/me<BR>some text</a>


Any ideas?

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] BR tags in admin submissions In reply to
Got it sorted...

Code:
sub {
my $tag = shift;
$tag =~ s/\n/<BR>\n/g;
$tag =~ s,\[(/?i)\],<$1>,g;
$tag =~ s,\[(/?b)\],<$1>,g;
$tag =~ s,(\w+@\w+\.\w+),<a href="mailto:$1">$1</a>,sg;
$tag =~ s,(https?://[\w\.-/]+),<a href="$1" target="_blank">$1</a>,sg;
$tag =~ s,\[([/\w]+)\],<$1>,g;
return $tag;
}

http://www.ameinfo.com
Quote Reply
Re: [kuplo] BR tags in admin submissions In reply to
Hi Guys,

I was looking for the same solution and was forwarded to this thread. Suddenly I recalled something I've seen before by which you can format your input in textarea in WYSIWYG way. Then I found HtmlArea at http://www.interactivetools.com/products/htmlarea/. It's free and easy to add to your html input form.

This will get rid of all the pain adding <>s or []s.

Enjoy.

Thanks to this thread, it leads me to HtmlArea.

Long
Quote Reply
Re: [long327] BR tags in admin submissions In reply to
Hi,
I'm using this global, just to have a line break in the link description.

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

The global works fine on category pages, but it does not work in search results!
Did I miss something?
I can not find a description tag in the search_results.html template. So where is the description from?

Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] BR tags in admin submissions In reply to
Hi,

Erm, you sure you don't mean in link.html? search_results.html only has <%Description%> in the <%loop links_results%> loop.

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] BR tags in admin submissions In reply to
Hi Andy,
here is the important part in my link.html

<%if Description%><div class="linkdescription"><%if highlight%><%Links::Tools::highlight($Description, $query)%><%else%><%description_br%><%endif%></div><%endif%>

description_br is the name of the following global, which enables a line break on every page except in search results?

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

Again, the global works fine, but not in search_results.html. In search_results.html there are no line breaks???

Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] BR tags in admin submissions In reply to
Hi,

Do you have "highlighting" enabled?

My guess, is that this bit in link.html:

Code:
<%if Description%><div class="linkdescription"><%if highlight%><%Links::Tools::highlight($Description, $query)%><%else%><%description_br%><%endif%></div><%endif%>

...is running:

Code:
<%Links::Tools::highlight($Description, $query)%>

You could try this:


Code:
<%if Description%><div class="linkdescription"><%if highlight%><%set Description = Links::Tools::highlight($Description, $query)%><%description_br%><%else%><%description_br%><%endif%></div><%endif%>

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] BR tags in admin submissions In reply to
Andy wrote:
Hi,
Do you have "highlighting" enabled?

Hi Andy,
yes the error comes from the highlighting and your code works nearly fine, but now the hightlightning is disabled in description.
The css tags for the highlightning are only printed out as text?

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] BR tags in admin submissions In reply to
Hi,

Mmm.. you could try commenting out:
Code:
$Description = GT::CGI::html_escape($Description);

..so it looks like:

Code:
#$Description = GT::CGI::html_escape($Description);

It looks like its escaping the code from the "highlighting" bit =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] BR tags in admin submissions In reply to
Andy wrote:
Hi,

Mmm.. you could try commenting out:
Code:

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


..so it looks like:

Code:
#$Description = GT::CGI::html_escape($Description);


It looks like its escaping the code from the "highlighting" bit =)

Cheers

Upps,
that's not a good idea. It destroys the layout of the desription field :-(

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] BR tags in admin submissions In reply to
Hi,

Can you paste an example of the code that is showing escaped? (i.e the HTML output). Should be able to do a reverse conversion =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] BR tags in admin submissions In reply to
Hi Andy,
here a some weird descriptions after I uncommented escape html.
http://www.gpaed.de/Unterrichtsmaterial/Arbeitsblaetter/Deutsch/index.html

Perhaps its only that part ---> that causes the problem.

Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] BR tags in admin submissions In reply to
Hi,

Are you refering to this kind of thing?

Quote:
Erarbeitung der Buchstaben U, u neu

visuelle Diskriminierung U, u
- AB Gedicht: Uhu Ulu --> visuelle Diskriminierung U, u
--->
- AB U prickeln, schreiben
- AB U legen, schreiben
- AB U Schreibblatt Diff leicht
- AB U Schreibblatt Diff leicht
- AB u prickeln, schreiben Diff leicht
- AB u prickeln, schreiben Diff schwer
- AB u legen, schreiben
- AB u Schreibblatt
- AB Stempelblatt U, u (angepasst an den Leselehrgang Lernen mit Hand und Fuß)
- AB Gedicht: Der Wurm macht nachts --> visuelle Diskriminierung U, u
- AB Gedicht: Uhu Ulu --> visuelle Diskriminierung U, u

Another option - do you need the highlighting? It does complicate things somewhat =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] BR tags in admin submissions In reply to
Hi,

I've been having a play on your site, and got it to work fine =)

I made a new global, <%description_br_search%> - with this code:

Code:
sub {
my $tags = shift;
my $Description = $tags->{Description};
$Description = GT::CGI::html_escape($Description);
$Description =~ s/\n/<br>\n/g;
$Description = Links::Tools::highlight($Description, $IN->param('query'));
return $Description;
}

Basically, what it does - is does the "highlight" AFTER the <br /> tags have been done. This way, it works perfectly, as its not trying to encode the highlight HTML :)

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
> > > >