Recent Topics

1 Mar 20, 2007 17:30    

My b2evolution Version: 1.9.x

Hello,
I'm messing with the $Item->content(XXX) bit of my template. I understand that you can pass an array by listing the information in the correct order, but what I don't get is how can I pass some information for something at the end of the list without passing information to everything before it? For this particular tag, I want to specify a value to the $cut... part (I don't know the terminology!). I tried using a bunch of empty quotes (i.e. '#', '#', 'Continue...', '', '', '', '', '150') but it just gave me an error.

Are the workings of the PHP templates explained anywhere? I understand the most basic PHP programming, but it's hard for me to figure out what exactly is happening when I put these tags into my template.

Thanks for the help!

3 Mar 21, 2007 11:48

Thanks for the reply.

What do you mean about XML type? Where is that specified?

I tried both:

$Item->content( '#', '#', 'More', '#', '#', '#', 'htmlbody', 10);

and

$Item->content( '#', '#', 'More', '#', '#', '#', 'htmlbody', '10');

and I get no errors, but it doesn't truncate anything.

4 Mar 21, 2007 11:57

I read this at the manual:


  void content( [mixed $disppage = '#'], [mixed $dispmore = '#'], 
[string $more_link_text = '#'], [string $more_anchor = '#'], 
[string $before_more = '#'], [string $after_more = '#'], 
[string $format = 'htmlbody'], [integer $cut = 0], 
[boolean $stripteaser = false], [string $more_file = '']  )


as:

$Item->content( '#', '#', '#', '#', '#', '#', 'htmlbody', 10);

.
The integer (10) should not be between brackets ('').

The XML type is probably a feed (rss) rather than a post.

5 Mar 21, 2007 13:21

I see. Too bad :( I'm making a skin for mobile devices, where screen space is limited ;)

6 Mar 21, 2007 14:05

blueyed wrote:

Please note that you have to pass all params before $cut with their default value and that $cut only works for "xml" type..

I have read this as: it doesn't work in posts (they are not stored as xml) but I may be wrong. You mention that you want to display the blog on a mobile device. that opens a new possibility: you can write a blog with only the rss as skin. This skin could be truncated the way you wanted to. It's even possible to force a css specially for mobile devices.

I had this question: why do you want the complete array to get to the cut part. Doesn't this line:

$Item->$cut(10);


work?

7 Mar 21, 2007 19:58

You are using format "htmlbody" in your code above. That's what has to be "xml" for cut() to work.

$Item->$cut(10); won't work.. unless $cut is set to a method name that exists in the Item class.

Just look at the source of the content method, if you only want to use that functionality. There may even be better PHP examples for something like "first x words" out there.

Instead of using the content() method, you could also use the $content property ($Item->content), which holds the raw content (but maybe not processed by renderer plugins).


Form is loading...