Posted by manorius on February 10, 2010 at 11:23am
Hi,
I'm trying to change the drupal pagination and replace the '<<' and '>>' with images.
The problem I'm facing is when I add the <img> tag it's being escaped what can I do to prevent that.
I'm trying to override the bellow code
function myTheme_views_mini_pager($tags = array(), $limit = 10, $element = 0, $parameters = array(), $quantity = 9) {
global $pager_page_array, $pager_total;
// Calculate various markers within this pager piece:
// Middle is used to "center" pages around the current page.
$pager_middle = ceil($quantity / 2);
// current is the page we are currently paged to
$pager_current = $pager_page_array[$element] + 1;
// max is the maximum page number
$pager_max = $pager_total[$element];
// End of marker calculations.
$li_previous = theme('pager_previous', (isset($tags[1]) ? $tags[1] : t('<<')), $limit, $element, 1, $parameters);
if (empty($li_previous)) {
$li_previous = " ";
}
$picture
$li_next = theme('pager_next', (isset($tags[3]) ? $tags[3] : t('!image',array('!image'=>'<img src="images/left_arrow.gif" alt="go back arrow">'))), $limit, $element, 1, $parameters);
if (empty($li_next)) {
$li_next = " ";
}
if ($pager_total[$element] > 1) {
$items[] = array(
'class' => 'pager-previous',
'data' => $li_previous,
);
$items[] = array(
'class' => 'pager-current',
'data' => t('@current of @max', array('@current' => $pager_current, '@max' => $pager_max)),
);
$items[] = array(
'class' => 'pager-next',
'data' => $li_next,
);
return theme('item_list', $items, NULL, 'ul', array('class' => 'pager'));
}
}thanks a lot
Comments
Here's one approach. Not pretty.
A better solution probably exists by doing it only in CSS. But to have a look at what you want to do...
<?php$li_next = theme('pager_next', (isset($tags[3]) ? $tags[3] : t('!image',array('!image'=>'<img src="images/left_arrow.gif" alt="go back arrow">'))), $limit, $element, 1, $parameters);
?>
t('!image', ...there is no good, Just return the HTML. Translating that won't fix achieve anything.Note that your path to the image src is probably wrong, so you'll need to fix that (eg with path_to_theme())
But anyway. If you want to dig into the code, look at http://api.drupal.org/api/function/theme_pager_next/6
although I'd consider just taking over and rendering your own link at this point in your code - if you can figure what it's doing.
The bit that is escaping the HTML and bugging you is theme_pager_link ... and it does NOT allow HTML or the link attribute 'html'=>true to pass through to the l() function it uses.
So you are S.O.L. there.
So to do it at the lowest level:
Copy the entirety of
theme_pager_link<code> to <code>mytheme_pager_linkAnd change the last line
<?phpreturn l($text, $_GET['q'], array('attributes' => $attributes, 'html' => true, 'query' => count($query) ? implode('&', $query) : NULL));
?>
And it'll start letting html in there.
It sure seems pretty inelegant. Looks like it wasn't thought of.
Really, you'll be better of with some css image replacement trick instead.
.dan. is the New Zealand Drupal Developer working on Government Web Standards
You should do that in css
You should do that in css that would be much more easier to maintain and replace.
Hide text add background and style a tag easy.
$|#|@
Thanks guys that's excellent,
Thanks guys that's excellent, thanks a lot.
ofcourse! CSS! I tend to overcomplicated things!