0

I have embedded view in a node with following code:

<?php
 $view = views_get_view('articles');
 $view->set_items_per_page(1);
 $view->set_offset(2);
 print $view->preview('page');
 $view->destroy();
?>

I just need to display only one specific row (that's why I'm using offset). I couldn't find a way to retrieve one specific row with any other method.

This code is acceptable but it has pager because that view has more than one row. Is there a way to remove pager like in Views UI? In Views there is a option to not use a pager but "Display a specified number of items".

I would like to remove it completely from code without CSS.

5
  • The simplest way might be to create a second display via the Views UI (call it offset_2 for descriptive purposes) that doesn't have a pager in it, eg, selecting Display a specified number of items instead of Paged Output and then calling that in your print $view->preview('offset_2');
    – Jimajamma
    Commented Nov 19, 2013 at 18:59
  • Yes, it's possible to do that way but I wanted to do this programaticaly. I want to optimize page as much as possible because that page has already too much queries.
    – Sacha K
    Commented Nov 19, 2013 at 23:11
  • It would be much better to do it from single display. I will need to create about 10 displays. it will clutter views ui. Reason I'm doing this is to have about 10 blocks placed on diferrent places on page. Think of metro ui.
    – Sacha K
    Commented Nov 19, 2013 at 23:21
  • well you can always modify the pager settings in a pre_render() or pre_build() hook much like you are doing in your question with other settings. google will be your friend here as there are many options. drupal.stackexchange.com/questions/86007/… might be a good starting place.
    – Jimajamma
    Commented Nov 19, 2013 at 23:36
  • you could also look at somehow overriding the appropriate theme template for this view. if you look in there you will see the pager is creating by just printing $pager so if you can figure out a way to target this instantiation of the view, you could just comment it out there.
    – Jimajamma
    Commented Nov 19, 2013 at 23:37

1 Answer 1

0

I ended up having to hide the specific pager with css in the case I did what you are trying to do...

3
  • I'm aware of display:none but I would like to remove it from code. CSS is last resort.
    – Sacha K
    Commented Nov 19, 2013 at 18:41
  • I understand that, I am saying that I was unable to find another way after much research...hopefully you can, unfortunately I don't think you will...
    – DrCord
    Commented Nov 19, 2013 at 18:45
  • If I stumble across anything I will certainly post it here.
    – DrCord
    Commented Nov 19, 2013 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.