Recent Topics

1 May 02, 2005 15:47    

I must be missing something basic here. Every time I try to assign $Item->title() to a variable, it just displays the title.

$variable=$Item->title()

What's the syntax to assign that title to a variable, but suppress the display?

Same thing happens when I try to assign $Item->Content()

ALSO: The syntax for changing a character to something else looks like:

$link = str_replace(" ","_", $link);

In this case a space is converted to an underscore.

How do I convert a " to a space?

Thnks. What can I say, it's Monday. (I'm trying to find a way to get convert any double quotes that are in a title, to something else).

-stk

2 May 02, 2005 16:28

I don't now on the top of my head, but it must be something with secondlast parameter
the way you do it know involves automaticaly a display.
You can return the content of the content...
look for all the parameters of that 'thing'...

3 May 02, 2005 16:29

Hi Scott,

Have you tried :-
$variable=$Item->title;
$othervariable=$Item->content; (note, your post will be unformatted)

$link=str_replace('"',' ');

?

4 May 02, 2005 16:46

topanga:

with content(), I tried every form of the second-to-last deal conten('','',''...'raw/xml/etc') ... but each time (tho the format changed), it continued to shove it to the screen (which is not what I want). Just want it in the variable, so I can do stuff to it.

Yabba:

I haven't tried your single-quoted str_replace yet. that was my first thought, but then the kid woke up and it's now the middle of breakfast. Think that should work. (thought maybe I could escape the " with a /" too, but didn't have time to try it.

DID try $variable=$Item->title() AND $variable=$Item->content(), but each time, keeps shoving it to the screen (displaying it) and I just want it in the variable. I want to supress the display, assign it to a variable, do stuff to it, THEN display it.

Seems crazy, but I can go to my _main.php file and where it currently says:

$Item->content('#','#','Read full story...','- -');

I can assign it to a variable

$test=$Item->content('#','#','Read full story...','- -');

, go to our page ... and it looks the same. ($test may vary well have been assigned, but the content() is still displayed.

Don't want that. Want to assign content(), in whatever format, to $test.

ACK - Yabba ... just noticed the difference in what you wrote. NO I havent' tried that. Hang on.

You're right ... works a treat! Thanks.

As a test

 took: $Item->content('#','#','Read full story...','- -');
commented it out, then wrote:
$test = $Item->content;
which yielded only titles on our page (yay ... no content), then:
$test= $Item->content;
echo $test;
and our pages returned.  YAY!

Must just be bypassing the function?

-stk

5 May 02, 2005 16:53

Hi Scott,

you must have misunderstood me a tad. Try it without the brackets

$variable=$Item->$title;

not :-

$variable=$Item->$title();

?

6 May 02, 2005 16:59

Yeah ... still blurry eyed, I guess! (see above ... finally saw it).

Didn't I say it was Monday? ha ha. THKS.

7 May 02, 2005 17:31

?????,

Today, you're my Monday's hero! Both title suggestions worked a treat.

What I was doing. I'm enhancing a little "email-your-friend" tool, which is functional on our site (near the bottom of each post, "Email Story").

I wanted to have the link title attribute display the blog title (and in my nerdy little way, have the title enclosed in quotes). But the thing was breaking whenever the blog title already HAD quotes.

Problem now solved (thanks to you).

title=" $#34;<?php $ttl=$Item->title;$ttl=str_replace('"','', $ttl); echo $ttl; ?>$#34; "

Where $#34; = ISO 8859 Char for double quotes " (replace $ with &)

Now comes the next task. I'd like to convert the $Item->content to just text, and (maybe?) allow a "include text of this entry in your email" check box. This is probably more involved, but ideally, would like to include it.

Cheers,

stk

PS - While I typed this, the kid ripped up one book, tore into a flat of onions that WERE destined for planting, ripped up a bunch of toilet paper & is now poopy. Being a stay-at-home dad is great ... but you just can't get squat done! ;)

8 May 02, 2005 17:59

Lol, I'm sure they make up for it in other ways ;)

The only problem I can see you having is that you lose all of the formatting of the content.

You might get away with :-
$email_body=str_replace("/n","<br />",$Item,->content);

?

9 May 02, 2005 18:26

Well ... all it takes is one ear-to-ear smile or laugh, then all the anguish seems worth it. Kids ... love'em, can't control them, can't chain them up. :D

Sad part 'bout using "content" instead of "content()", is that I could use content() to strip the HTML code out content('','',..,'format'). (The 2nd to last one, like Topanga said).

Yeah, "content", I figured I'd have to first convert all the <br /> and/or </p>'s to /n, then strip out the remaining <html> tags with a "like <%%>" (or something like that). Figured that I could find something about using PHP to strip out HTML on the 'net somewhere.

Of course, the next step is to successfully pass it off to another PHP file. (Always something) ;)

What's the diff between /n and /r ?

10 May 03, 2005 01:02

What's the diff between /n and /r ?

Damn, they musn't teach the alphabet to cannuks, one comes after m and the other doesn't :|

I believe one is newline and the other is return.... dunno how things work nowadays, but when I were a lad, one was chr(13) and the other was chr(10) ;)

¥

11 May 03, 2005 03:21

Hey mate, they BOTH come after M! (At least in the English alphabet). Don't know what you chaps use in Blackpool, but here in Canada it's M,N,O,P,Q,R !! :lol:

Darn, ¥åßßå, you just went from Hero to Zero all in one day!

12 May 03, 2005 11:04

To quote homer simpson.....

DOH

:oops: :P

?

13 May 03, 2005 11:11

We went to blackpool last Monday. I was amazed that there were people there who could operate a computer, let alone program...

(No slight on you, but all the chav's / dole-ys must drive you nuts!)

14 May 04, 2005 09:07

all the chav's / dole-ys must drive you nuts!

Damn, you must have gone to the posh bit ! :|

It's not that they're not intelligent enough to operate a computer, it's just that they get confused by anything with more buttons than a fruit machine ;)

¥

15 Jun 27, 2005 23:57

Darn all these $Item things!

I'm now having a similar issue with $Item->issue_time()

I'd like to store the issue_time (formatted) into a variable and then use it for a branch statement ... like this:

$start = $Item->issue_time('h:i:s');
if ($start == "10:30:59") { do this
} else { do this }

Does anyone know how to do this? Each time I do it, the bloody time is shown on the screen. It's like $Item->issue_time means "display issue time". I tried ye olde $start=$Item->issue_time; but that didn't yield anything that was "echoable". I tried $Item[issue_time], with the same result.

Argh!

I'm about to reach into the database with a mysql query and grab the bloody issue_time by the throat and drag it out of the DB, rather than rely on these $Item arrow dealies ... which never seem to behave as expected.

I'm obviously missing something here! Any enlightening words to set me on the straight and narrow?

-stk

16 Jun 28, 2005 01:43

then strip out the remaining <html> tags with a "like <%%>" (or something like that).

Easy peasy.

$content = $Item->content;
$content = str_replace(array('<br />','</p>'),array('\r\n','\r\n\r\n'),$content;
$content = strip_tags($content);


Also, you should check out the /b2evocore/_class_item.php file. There are a lot of functions that allow you to suppress the output by sending in "false" (boolean constant, that is - no quotes) as the $disp parameter.

17 Jun 28, 2005 18:41

isaac,

Some time ago (around the beginning of May), I found a bit of php code that does exactly that (and more, as the array is larger), but the effect is the same. It looks for and replaces specific HTML code with whatever deemed necessary, converting an HTML page to a text-only page. Works a treat and is implemented in the [url=http://www.randsco.com/index.php/2005/05/01/email_blog_entry]email a blog entry to a friend[/url] script, which I've made available for public consumption.

The current, specific php code used:

			if($Item->status=="published"){
			$blog = format_to_output($Item->content,'htmlbody');
			/* Text-only: Search & Replace HTML tags & entities */
			/* Entities are ISO 8859-1 - Will need to change if
			   your site uses a different Character Set         */
			$search = array (
			           "'<script[^>]*?>.*?</script>'si",  // Identify Java 
                 "'<code>.*?</code>'si",  // Identify Code
								 "'<img.*?>'si",          // Identify Images
								 "'<[/!]*?[^<>]*?>'si",   // Remove HTML tags 
                 "'&(quot|#34);'i",       // Replace HTML entities 
								 "'&(amp|#38);'i", 
                 "'&(lt|#60);'i", 
                 "'&(gt|#62);'i", 
                 "'&(nbsp|#160);'i", 
                 "'&(iexcl|#161);'i", 
                 "'&(cent|#162);'i", 
                 "'&(pound|#163);'i", 
                 "'&(copy|#169);'i", 
								 "'&(reg|#174);'i",
								 "'&(deg|#176);'i",
								 "'&(plusmn|#177);'i",
								 "'&(bull|#8226);'i"
								 );
      $replace = array (
			           " [JAVASCRIPT - SEE LINK] ", 
                 " [CODE - SEE LINK] ",
								 " [IMAGE - SEE LINK] ",
								 "",
                 "\"", 
                 "&", 
                 "<", 
                 ">", 
                 " ", 
                 chr(161), 
                 chr(162), 
                 chr(163), 
                 chr(169), 
								 chr(174),
								 chr(176),
								 chr(177),
								 chr(187)
								 ); 
      $text = preg_replace($search, $replace, $blog); 

You can see that certain tags and what they contain (images, javascript, code) is collapsed and replaced by some text that indicates to look at the (linked) HTML entry. And then certain entity values are replaced with values that are more meaningful in a text-only world.

Cheers,

-stk :D


Form is loading...