Recent Topics

Search Results Page Request

Started by on Nov 13, 2006 – Contents updated: Nov 13, 2006

Nov 13, 2006 05:38    

Could someone work on a Search Results page that displays results in a summary format like google.

[u]Blog Title #1[/u]
Followed by the first 20-50 words of the blog...
[u]Blog Title #2 [/u]
Followed by the first 20-50 words of the blog...
...
etc.
...

Any thoughts on this?

Nov 13, 2006 07:28

You could try something like this in your skin (where you currently only have $Item->content() )

if( !empty( $s ) )
{
	$Item->content = implode( ' ', array_slice( explode( ' ', $Item->content ), 0, 50 ) );
}
$Item->content();

¥

Nov 14, 2006 01:24

Could you comment on what page I'll need to edit?

I looked at my _main.php but couldn't find the "$Item->content() " line...

Thanks.

Nov 14, 2006 09:16

in your skins _main.php you should see a block of code that looks similar to this :-

		<h3 class="bTitle"><?php $Item->title(); ?></h3>
		<div class="bText">
			<?php $Item->content(); ?>
			<?php link_pages() ?>
		</div>

Change it to look like this :-

		<h3 class="bTitle"><?php $Item->title(); ?></h3>
		<div class="bText">
			<?php
			if( !empty( $s ) )
			{
			    $Item->content = implode( ' ', array_slice( explode( ' ', $Item->content ), 0, 50 ) );
			}
			$Item->content();
			?>
			<?php link_pages() ?>
		</div>

¥

Nov 15, 2006 02:49

Thanks a lot. I have it set up...

An extra feature - would be to have a "Read More" type of link so that people can click to get the full article.

Right now, they have the "Permalink" icon but that is not too obvious.

I tried adding

<a href="<?php $Item->permalink() ?>" title="<?php echo T_('Permanent link to full entry') ?>">READ MORE</a>

This creates a "Read More" link all the way at the top of the first line. I would want this type of link on the middle of the page after the last last character of the blog.

Even Better, it would be nice to make the "Blog Title" a Link to the full article...Like Google does.

Is this possible?

I realize you've helped a lot already so thanks a lot for this...

Edgar.

Nov 16, 2006 13:08

Making it jump to "+ 50 words" on clicking read more is probably more coding effort than it's worth, but if you want to give it a shot then you can probably do it like this (sorry, I can't test this as I don't have a 0.9.1 blog anywhere)

        <h3 class="bTitle"><a href="<?php $Item->permalink(); ?>&amp;myMore=1#myMore"><?php $Item->title(); ?></a></h3>
        <div class="bText">
            <?php
            if( !empty( $s ) )
            {
                $Item->content = implode( ' ', array_slice( explode( ' ', $Item->content ), 0, 50 ) );
            }
            elseif( param( 'myMore', 'integer' ) )
            {
                $Item->content = implode( ' ', array_slice( explode( ' ', $Item->content ), 0, 50 ) ).'<a id="myMore"></a>'.implode( ' ', array_slice( explode( ' ', $Item->content ), 50 ) );
            }
            $Item->content();
            ?>
            <?php link_pages() ?>
        </div>

¥

Jan 01, 2007 23:12

I tested the code and it also works on 1.8.5

I tried creating the "Read More" link right after the first 40 characters...but somehow the link kept appearing on the top of the blog text...

<?php
				 
            if( !empty( $s ) )
            {
$Item->content = implode( ' ', array_slice( explode( ' ', $Item->content ), 0, 40 ) );
$Item->content = $Item->content . $Item->permanent_link('Read More') ;
						}
            $Item->content();
           	 ?>
            <?php link_pages() ?> 

Not a biggie but if you have a chance to review and help - it will be great.

There's also a "google highlight search [url=http://b2evo.astonishme.co.uk/index.php?title=search-hi-lite-plugin&more=1&c=1&tb=1&pb=1#comments]here at astonishme.co.uk[/url] but it didn't work for me.

Jan 02, 2007 12:16

<?php
            
            if( !empty( $s ) )
            {
                 $Item->content = implode( ' ', array_slice( explode( ' ', $Item->content ), 0, 40 ) ).'< a href="'.$Item->permanent_url().'">Read More</a>';
             }
            $Item->content();
               ?>
            <?php link_pages() ?>

We haven't updated the search highlighter yet, hopefully we'll get a chance soon.

¥

Apr 20, 2007 14:26

Anyone tried?

I have tried, but not worked

Apr 08, 2008 06:20

I'm hoping this is the right place for this question.

I'm building a 400 x 300 Text Area in my main page.

In there, I want to place the text of my "last post".

To display one post is simple. I have my blog configure to show only one post.

What I can't seem to figure out is how to limit the amount of characters returned:

is there a way to have b2evo 2.4 return only the X number of text characters, and then output the "Read More" button?

The code above doesn't follow the format of the new skins. The _item_content.inc.php doesn't include a $Item-> clause.

Thanks for the help...

Apr 08, 2008 18:16

There's a function in the RSS Reader plugin that will cut content at ## words whilst preserving tags, you might be able to play with it to suit your needs ;)

¥


Form is loading...

powered by an open-source CMS – This forum is powered by b2evolution CMS, a complete engine for your website.