Recent Topics

1 Feb 28, 2006 13:15    

I want to adapt the << Previous Page :: Next Page >> to my needs but I don't know how.

First I want to remove the "<<" and ">>" but I don't know where I have to remove those.

The second thing is that I would like to add css classes to the previous and next Links so that it looks like this

<a class=" prev" href="xyz">Previous Page</a> :: <a class="next" href="xyz">Next Page</a>

Any ideas how I can do that? I searched already the forum but couldn't find a solution.

I tried to add the classes to

/*
 * link_pages(-)
 * vegarg: small bug when using $more_file fixed
 */
function link_pages( $before='#', $after='#', $next_or_number='number', $nextpagelink='#', $previouspagelink='#', $pagelink='%d', $more_file='')
{
	global $id, $page, $numpages, $multipage, $more;

	if( $before == '#' ) $before = '<p>'.T_('Pages:').' ';
	if( $after == '#' ) $after = '</p>';
	if( $nextpagelink == '#' ) $nextpagelink = T_('Next page');
	if( $previouspagelink == '#' ) $previouspagelink = T_('Previous page');

	if ($more_file != '')
		$file = $more_file;
	else
		$file = get_bloginfo('blogurl');

	if( $multipage ) { // && ($more)) {
		echo $before;
		if( $next_or_number == 'number' )
		{
			for ($i = 1; $i < ($numpages+1); $i = $i + 1)
			{
				$j = str_replace('%d', $i, $pagelink);
				echo ' ';
				if( ($i != $page) || ( (!$more) && ($page==1) ))
					echo '<a href="'.url_add_param($file, 'p='.$id.'&amp;more=1&amp;page='.$i).'">';
				echo $j;
				if( ($i != $page) || ( (!$more) && ($page==1) ))
					echo '</a>';
			}
		}
		else
		{
			$i = $page - 1;
			if( $i )
				echo ' <a class="prev" href="'.url_add_param($file, 'p='.$id.'&amp;page='.$i).'">'.$previouspagelink.'</a>';

			$i = $page+1;

			if( $i <= $numpages )
				echo ' <a class="next" href="'.url_add_param($file, 'p='.$id.'&amp;page='.$i).'">'.$nextpagelink.'</a>';
		}
		echo $after;
	}
}

But it's still not shown on the source code of my site. I have no idea where and what to change then.

2 Feb 28, 2006 14:06

In your skins use :-


<?php 
echo '<span class="prev">';
previous_post( 'Previous posts' );
echo '</span><span class="next">';
next_post( 'Next posts' );
echo '</span>';
?>

¥

3 Feb 28, 2006 16:01

Thanks but this doesn't help me much. I don't want to add span tags which have no use other than adding a class which usually is added directly to the link tags. I simply want to add the classes to the <a href=....>. There must be some part in the code of the script where to do it. I just haven't found it. It's definitly not in the skin files but probably somewhere in the functions.

4 Feb 28, 2006 17:01

In that case you need to look in b2evocore/_functions_b2posts.php (or something like that) for the two functions that you need to hack. A minimal hack would be to add a parameter for the class name, that way you'll have less work to do if you ever upgrade (or if they change the params).

function next_posts_link($label='#',$link_class = 'next', $max_page=0, $page='')
{
	global $p, $paged, $result, $request, $Settings;

	if( $label == '#' ) $label = T_('Next Page').' >>';

	if ($Settings->get('what_to_show') == 'paged')
	{
		global $MainList;
		if (!$max_page)	$max_page = $MainList->get_max_paged();
		if (!$paged) $paged = 1;
		$nextpage = intval($paged) + 1;
		if (empty($p) && (empty($paged) || $nextpage <= $max_page))
		{
			echo '<a href="';
			echo next_posts($max_page, $page);
			echo '" class="'.$link_class.'">'. htmlspecialchars($label) .'</a>';
		}
	}
}



/**
 * previous_posts_link(-)
 *
 *
 */
function previous_posts_link($label='#',$link_class = 'prev' ,$page='')
{
	global $Settings;

	if( $label == '#' ) $label = '<< '.T_('Previous Page');

	global $p, $paged;
	if (empty($p)  && ($paged > 1) && ($Settings->get('what_to_show') == 'paged'))
	{
		echo '<a href="';
		echo previous_posts( $page );
		echo '" class="'.$link_class.'">'.  htmlspecialchars($label) .'</a>';
	}
}

and then call them in your skin with

previous_posts_link( 'Previous posts' , 'my_previous_class');
next_posts_link( 'Next posts', 'my_next_class' );


¥

5 Feb 28, 2006 22:18

Thanks a lot. It didn't work for me how you suggested since I couldn't find the place in my skin but anway I changed it directly in the functions

     echo '<a class="prev" href="';
      echo previous_posts( $page );
      echo '" class="'.$link_class.'">'.  htmlspecialchars($label) .'</a>'; 

But without your help I simply didn't find the place in the functions although searching.

At least this works for me.

6 Nov 11, 2006 00:14

Nice tip. Helped me a lot. Thank you.


Form is loading...