Recent Topics

1 Apr 03, 2008 09:56    

My b2evolution Version: B2 version: 1.10.3

I'm sure someone knows how this is done...

B2 version: 1.10.3

I've added the Facebook Share-link (http://www.facebook.com/share_partners.php) to every post on my blog, but I'm having some problems with the meta information.

For those unfamiliar with Facebook: Facebook sharing relies on two meta-tags (meta name="title" and meta name="description"). These two meta tags have the following properties: "title" should be the headline of the post, and "description" should be a short preview of what the shared item contains. I've added the following to "title":

        <meta name="title" content="<?php
                $Blog->disp('name', 'htmlhead');
        ?>" />

(http://agaricdesign.com/sharing-drupal-pages-on-facebook shows how the tags work)

So far -- so good: this works 100% :-)

Now, the problem is that I would like to use a similar kind of code to display either the first paragraph or the first 20 words (whichever is easiest) from the post in the meta name="description".

If first paragraph or first N words is difficult (or impossible), as a last resort, would it be possible to display the entire post as "description" (the blog posts are only short, 2 or 3 paragraph news items)?

Can this be done?

2 Apr 04, 2008 20:22

yes ;)

You'd need to get $Item out of $MainList and then remove all tags and cut the content at the length that you want

¥

3 Apr 08, 2008 00:27

¥åßßå wrote:

yes ;)

You'd need to get $Item out of $MainList and then remove all tags and cut the content at the length that you want

¥

Thanks for your reply (I've been away for the weekend, sorry for the delay), but this seems like quite a job, removing all tags and so on, and I'm not sure how to go about doing it.

If it's easier than I assume, I'd really love some hints on how to do it, but if it is as complicated as it seems, then it's really no big deal -- I'll manage without :)

By the way, I guess you can never get this often enough; b2evolution is a great -- fantastic -- piece of software, and time and time again I'm impressed by the community here on the forums. So thanks anyhow -- you're all doing a great job!

4 Jul 31, 2008 19:51

¥åßßå wrote:

yes ;)

You'd need to get $Item out of $MainList and then remove all tags and cut the content at the length that you want

¥

I've just been trying to do this exact same thing.


		$sfItem = & mainlist_get_item();
		$description = $sfItem->get_excerpt( 'entityencoded' );

The problem I'm having is that if I add the above to _html_header.inc.php it looks like that's iterating something* that means when the main code calls it (where it's supposed to be) it misses the first one (so if it's a one-post display there is no post! :( )

Is there some way of preventing this?

* I'm guessing because that "$Item = mainlist_get_item()" call is used as the condition in a while loop in the main body.

BTW rlyeh, the PHP function [url=http://www.php.net/strip_tags]strip_tags[/url] should get you in the right direction if you can solve the issue I'm having.


Form is loading...