How can I display the total number of rows shown in a Drupal view as well as the number of rows out of the total currently being shown?
print $GLOBALS['current_view']->total_rows; does not work
This question might be of help
$view->total_rows is wrong (sort of), I want "Items to display"
$view = views_get_view('MY_VIEW_NAME');
$view->set_display('MY_DISPLAY'); // like 'block_1'
$view->render();
print sizeof($view->result);
print sizeof($view->result);
does not work, because it returns the number of rows, not the number of total results. So if you have a pager, this doesn't work. You'll need
print $view->total_rows;
Another, even better solution would be to implement hook_views_pre_render()
function MYMODULE_views_pre_render(&$view) {
if ($view->name == 'MY_VIEW') {
$view->set_title(t('Search (#count results)', array('#count' => $view->total_rows > 0 ? $view->total_rows : 'No')));
}
}
Related
I'm using WC Ajax Product Filter for filtering options .
Unfortunately the price range is showing :
Min Price: ₹NaN
Max Price: ₹NaN
The actual price is not displaying. Please help me out . I'm new to woocommerce .
The issue found out !
The minimum and maximum price range difference for the products was very less. For example - minimum was $65 and maximum was $66, that was the issue.
I've found a temporary solution, edit the plugin file: wcapf.php :you can find this in the root of the plugin directory: wc-ajax-product-filter
Now search for the code: getPriceRange
This occurs in 2 spots around line #467 and line #773
On both 2 spots you see an if statement below which uses sizeof() function.
There seems to be some sort of issue with this.
I have fixed the issues of NaN by commenting out the entire if and else statement that uses the sizeof() function, see below code for example.
It's not the best solution, but well it works, untill update.. I will post this to plugin creator as well.
#469:
//if (sizeof($unfiltered_price_range) === 2) {
#522:
//}
#781:
//if (sizeof($price_range) > 2) {
#840:
//} else {
// empty array
// return array();
//}
Solved it this way.
Edit widget-price-filter.php file.
It's in the folder /ajax-product-filter/widgets/
Replace the following code in line 125:
<span class="wcapf-slider-value" id="wcapf-noui-slider-value-min"></span> - <span class="wcapf-slider-value" id="wcapf-noui-slider-value-max"></span>
By:
if ($min_val!=0 && $max_val!=0 ) {
echo '<span class="wcapf-slider-value" id="wcapf-noui-slider-value-min"></span> - <span class="wcapf-slider-value" id="wcapf-noui-slider-value-max"></span>';
} else{ echo '-';}?>
It will replace the NaN values bellow the slider by (-), just change the last line if you want another text there.
Rows are selected like that:
$book->getBookGenreToBooks()->???()
I want to change the column «checked» of all selected rows.
Your given solution in your answer is very inefficient since it creates for each update a new query. A better way is to do all changes in one query:
BookGenreQuery::create()
->filterByBookId($book->getId())
->update(array('Checked' => 1));
I don't know how exactly your relations and fields are named by you should get the idea behind it.
$genresToBook = $book->getBookGenreToBooks();
foreach ($genresToBook as $genreToBook) {
$genreToBook->setChecked(1); //Set any data here
}
$genresToBook->save();
This isn't exactly what I want, but that works fine to me.
I need create a loop with specifics post but I would like do it by position (not by id) of all of them. I want to use a single loop with specific position.
Example: (2, 5, 9, etc)
I tried to use wp_query methods but my php knowledge is little.
Outside the loop, create a counter variable:
$post_number = 1;
Then, while you're in the loop, you can check on the contents of the variable to see which post you are at. For instance, in the following example, only the first and second posts will be shown.
Just before you end the loop, add to the counter using $post_number++.
// Start loop
if ($post_number == 1 || $post_number == 2){
// standard loop contents ( the_title(), the_content(), etc)
}
$post_number++;
// stop loop
Why you not try inside a loop for an example:
if ($idpost == "4")
{
// print...
}
I need to access columns of infragistics ultragrid in same sequence in which they are being displayed in grid. If i can get the index of column in same sequence as they are visible on grid, i can fix my issues.
Thanks in advance.
Lalit
UltraGridColumn column = this.ultraGrid1.DisplayLayout.Bands[0].Columns[0];
Debug.WriteLine( "Columns in visible order: ");
// Get the first visible column by passing in VisibleRelation.First.
column = column.GetRelatedVisibleColumn( VisibleRelation.First );
while ( null != column )
{
Debug.WriteLine( " " + column.Key );
// Get the next visible column by passing in VisibleRelation.Next.
column = column.GetRelatedVisibleColumn( VisibleRelation.Next );
}
http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v8.2~Infragistics.Win.UltraWinGrid.UltraGridColumn~GetRelatedVisibleColumn.html
I suppose you could try to handle the event that is fired when the order is changed and keep track of all the changes, but this seems like it is asking for subtle bugs to creep in.
I considered looping through all the columns and trying to use some property that would tell me their current position (maybe the TabOrder?) and use that to compile an inorder list of the columns. I guess you might have to loop through each colum using the Column.GetRelatedVisibleColumn() method.
I have not actually implemented it yet as I have other higher priority issues but that may be the road I end up going down.
This is an old question, but I recently had same issue and solved it this way:
var selectedCells = this.Selected.Cells;
List<int> columns = new List<int>();
foreach (var cell in selectedCells)
{
if (!columns.Contains(cell.Column.Index))
columns.Add(cell.Column.Index);
}
columns.Sort((x, y) => this.DisplayLayout.Rows.Band.Columns[x].Header.VisiblePosition.CompareTo(this.DisplayLayout.Rows.Band.Columns[y].Header.VisiblePosition));
You can then use columns to access columns in order they are shown.
I want to compare rows of two grid views.GW1 and GW2.
When I click a Search Button ,I want to check the Values in the GW2,and if GW1 and GW2 have same PayID ,EmpID,then that specific row of GW1 must be disabled
Thanks
int i = 0;
while(i < GridView1.Rows.Count && i < GridView2.Rows.Count)
{
if(
GridView1.Rows[i].Cells[column for pay ID].Text == GridView2.Rows[i].Cells[column for pay ID].Text &&
GridView1.Rows[i].Cells[column for emp ID].Text == GridView2.Rows[i].Cells[column for emp ID].Text))
{
GridView1.Rows[i].Enabled = false;
}
i++;
}
Only way I can think of is to loop through table one and search for similar rows in table two. This is how you can do this:
Loop through the Table 1.
Use DataTable.Select to find if there are rows with same PayID and EmpID in Table 2.
If the method returns more than 0 rows, then disable the rows.
Apart from this, you can also think about writing/searching a method which can give you intersection of two tables. If these two columns are priamry keys, then this will work. If not, then you will need to tweak the code as per your need.
do something like this, its not the actual code, but you will have the idea.
for i=0 to gw1rowscount-1
for j=0 to gw2rowscount-1
if gw1(i)(column1)=gw2(j)(column1) and gw1(i)(column2)=gw2(j)(column2) then
end if
next
next