Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Search

 
Advanced search

8043 Posts in 1856 Topics- by 2099 Members - Latest Member: roi
Calendar Script CommunityCustomizationHacks and Mods (Moderators: scott, DanO, Marty)text only event description
Pages: [1]   Go Down
Print
Author Topic: text only event description  (Read 977 times)
0 Members and 1 Guest are viewing this topic.
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« on: March 01, 2007, 06:05:00 PM »

is there a way i can modify:

<%= $EVENT->{'details'}->{'description'} %>

to have it ignore any html tags?  just return raw text without formatting?

i still would like to keep the html when viewing the event, but i have other uses for the event description where i only need the text.

i would hate to have to create another field for text only and have to manage to versions of each event description

[This message has been edited by beneath_the_ashes (edited March 01, 2007).]

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #1 on: March 01, 2007, 07:24:00 PM »

&HTML::filter( $EVENT->{'details'}->{'description'} )

The above would strip HTML tags from $EVENT->{'details'}->{'description'} but how exactly it would be used would depend on where exactly it is being used in the script.

JMO

Dan O.

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #2 on: March 01, 2007, 07:38:00 PM »

<A title="<%= &HTML::filter( $EVENT->{'details'}->{'description'} ) %>" HREF=blablabla

you can see it if you hover over the event title from today (March 1st) from http://www.wearemanalive.com/cgi-bin/calendar/calendar.pl

if you click on the event, you can see all the formatted garbage i have just to test it with....the result im looking for from the event description would be...

test descr2007-03-0117:27:53ip??tionnnn

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #3 on: March 04, 2007, 04:30:00 PM »

You're right, it doesn't do what you want. It only turns HTML tags into displayable characters.

Try:

<%= $EVENT->{'details'}->{'description'} =~ s/<[^>]*>//gm %>

Dan O.

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #4 on: March 04, 2007, 05:02:00 PM »

it seems to be doing the same thing.  i cant even begin to understand what all that code means either to try to edit it!

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #5 on: March 04, 2007, 05:22:00 PM »

** it seems to be doing the same thing. **

It shouldn't be. It is working code taken from another application I use. Are you certain you made the changes in the correct place in the template and uploaded the freshly edited template to the server?

** i cant even begin to understand what all that code means either **

Much of it is covered in the Perl: Start tutorial I linked to previously, in the 'Substitution and translation' and 'Regular expressions' sections.

JFYI

Dan O.

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #6 on: March 04, 2007, 05:50:00 PM »

well actually....it is returning an odd number.  im not sure where it is getting it.  you can see it here. http://www.wearemanalive.com/cgi-bin/calendar/calendar.pl

to make sure i was adding that code to the right place, i added the word 'dude' after it.  if you hover over the titel on March 2nd, the tooltip says '23dude' now.  but if you look at the event, the description doesnt have '23' in it at all.

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #7 on: March 05, 2007, 01:01:00 AM »

** the tooltip says '23dude' now **

I have no idea where that could be coming from. You can try putting the statement in brackets to see if it makes a difference:

<%= ($EVENT->{'details'}->{'description'} =~ s/<[^>]*>//gm) %>

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #8 on: March 05, 2007, 02:39:00 AM »

hmm same thing...im reviewing that documentation to see if i can find some minor detail, but that is really stranger

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #9 on: March 05, 2007, 02:55:00 AM »

the number is echoes is how many instances it removed from the string...still trying to figure out how to make it dispaly the text left over though...

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #10 on: March 05, 2007, 03:15:00 AM »

so i found out how to do it, but its a really dirty way to do it...

code:

<%= ($EVENT->{'details'}->{'description'} =~ s/<[^>]*>//gm) %> title="<%= $EVENT->{'details'}->{'description'} %>" href="url">link title</a>


gives me this:
code:

<a 23 title="no html tags description" href="url">link title</a>


notice the number in between '<a' and 'title'

any idea what i can do to clean that up?

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #11 on: March 05, 2007, 12:04:00 PM »

The <%= ... %> tag is telling the script to print the value in the middle. If you just wanted the code acted upon but not printed, remove the "=" from it. Eg.

<% ($EVENT->{'details'}->{'description'} =~ s/<[^>]*>//gm) %>

Dan O.

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #12 on: March 05, 2007, 02:11:00 PM »

i actually had tried that but got a syntax error

syntax error, near ") print"

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #13 on: March 05, 2007, 03:40:00 PM »

Instead, try:

<% $EVENT->{'details'}->{'description'} =~ s/<[^>]*>//gm; %>

Dan O.

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #14 on: March 05, 2007, 03:47:00 PM »

perfect!  thanks!

------------------

Logged
Pages: [1]   Go Up
Print
Jump to: