I'm running in a problem with cakephp pagination. Currently, my pagination is rather standard. After x results, it creates a second page. And so on.
What i would like to do is to order them by month. As it is a news archive, I would like to be able to select the month instead of the page.
So instead:
Page 1
Page 2
Page 3
I would like to have:
January 2010
February 2010
March 2010
How is this possible? I can't seem to find it. My current code:
var $paginate = array('limit' => 50, 'page' => 1, 'order'=>array('Newsitem.created'=>'DESC'));
thanks in advance!!
Pagination is a function of LIMIT row counts and offsets of number of records, not by data conditions. Therefore, you will not be able to use the pagination function in cake to accomplish this. You will need to create a custom solution to accomplish this. If you continue to solve this with the build in cake pagination, you will continue to hit a brick wall.
Now, that being said, one solution is to paginate by month. So you could have different links down the left showing the months (i.e. January 2010, February 2010, etc.), when they select one of those options, it will paginate all of the results for the given date.
This might be an alternative you'd consider (it doesn't match your requirement directly).
CakePHP Filter Plugin
What it would allow you is filtering paginated data by any column in the recordset.
Under any header (<th>) you'll be able to add an input where you can enter filter criteria (e.g. for Newsitem.created you could enter: 2010-08 to display/paginate only Newsitems for Aug. 2010). You then click the filter button and your page reloads showing only the records that match the filtered criteria. Works with Ajax pagination also.
I tested this today with this screen:
Related
i have a content type, say named material, with fields and all, and users can create, modify and delete all nodes of content type material.
The task i need to do, is have a report on the activity of each user, in a per month, or a per year basis. Example user 1, has created the following nodes, in January, updated these nodes and how many times each node was updated by the particular user.
Is there a module, or a view that could help me do something like this?
Or should i go to MySQL and run a query there?
And how then this query should look like?
(I am still on version 7 of drupal)
for example the following will return will select all nodes created within the past hour (3600 seconds).
$result = db_query("SELECT nid, title FROM {node} WHERE created > :created", array(
':created' => REQUEST_TIME - 3600,
));
But what i need is also all updates done by a certain user, for a certain period of time given...
Any example would be highly appreciated.
I'm working with the Blog app and I see how to filter the Blog posts by year using the Visual Query Designer. I use the querystring value that has the year and in the ValueFilter and my properties are as follows:
Attribute: PublicationMoment
Value: [QueryString:year]-01-01 and [QueryString:year]-12-31
Operation: between
How would I get the posts from a specific month and year, if those values are passed via query string parameters. Because the months of the year have a varying number of days, I'm not sure how you would accomplish this in the Value field of the ValueFilter. Currently I'm passing the 2 digit month as the parameter.
I tried something like: [QueryString:year]-[Querystring:month]
Operation: contains
but the above operation doesn't really work because the datatype is a DateTime object.
I could do it in the razor view but I'm afraid that the paging datasource would have too many pages in it since it would be based on the larger subset of posts for the given year that was passed in the querystring parameter.
Is there any way to do this with the filter?
Basically dates are not perfectly handled yet, but there are a few ways to do it using the visual query:
Use the correct date in the query like between [QueryString:Start] and [QueryString:End] and calculate the correct dates there where you generate the links
Since your main problem with the "between" filter is actually that it would include the last day too, you could also use a two filters a >= first date and another < second date, so the first-date would be the year/month and day 1; the second one is year-month and day 1 as well
Last but not least: if you do it with razor and LINQ you shouldn't run into any performance issues - it's technically the same thing the pipeline does and it's been tested to perform well with tens of thousands of records.
I'm all about recycling-)
I have report that user want to run for selected number of month back (let say from 1 to 12).
If they selected 6 month back (Jul-13 thru Jan-2104, then I need to produce 6 pages with monthly report on each of them, and sp is the SAME for all reports just different time params.
How I can reuse my code??
For now I have 12 Tablix(s) with New Page=START, Hide condition set based on datediff(m,startDate,endDate) individually for each Tablix.
Then I need to run same sp with diff params, can I add some dynamics into it? or I better to have 12 sp(s)?
Thanks
Mario
You can achieve this with a single dataset and a List Report Item with an embedded Tablix:
Set the List Grouping to Group/Sort first by: =Year(Fields!YourDateField.Value) and then by =Month(Fields!YourDateField.Value).
Set the Page Breaks on the List Grouping to "Between each instance of a group".
Drag your Tablix inside the List Report Item.
Let me know if you need more detail.
I am trying to move reports that currently run in SQL Server to Crystal Reports.
Essentially the statement I want to reproduce is:
SELECT DATEPART(DD,DATE), COUNT(*)
WHERE FOO = 'BAR'
GROUP BY DATEPART(DD,DATE)
Count the occurrence of records that match a criteria, grouped by date.
I have used the Selection Expert to generate a equivalence relation (to evaluate the records) and would like to use the datepart function in a group by statement. I have gotten the GROUP BY selection expert to group by date - but it is the full timestamp (SS:HH:DD:MM) not by specific day i.e. March 1 2010.
I am sure there is a way to achieve what I want but have yet to find a tutorial explaining this scenario.
Any help you could lend would be appreciated
As with any other SDK/Language, there are many ways to do this. Here is the first one that I can think of:
Get the raw data into Crystal. (Sounds like you already did this)
In Crystal, make a new formula, call it "GroupByDate". In the formula editor, enter:
datepart("yyyy-mm-dd",{mytable.mydatefield})
Go into the Group Expert. Group your report by GroupByDate.
Make a new formula, call it "AddMe". In the formula editor, enter:
iif({mytable.foo="bar",1,0)
Drag & drop your AddMe formula into the details section. Right-click on it to Insert->Summary. Set your summary location as the group footer.
Preview your report and you should see the total counts in every group footer. To simplify the appearance of the report, you can also suppress the display of the detail and grouper header sections.
Again, there are many ways to do this. You can also get creative with a Running Total function. The Crystal Formula Editor has very useful help files. Use the Functions pane to select a function, press F1, and you'll get criteria, examples, etc.
Magento database name convention is not trivial. How to get these fields below for last 7 days?
Last Name
First Name
Address
City
State
Zip
Phone
Email
Amount
Order #
Item #
I could not tell if you were looking for some PHP/Magento code or if you are looking to access the database directly. It might be "better" to create yourself a custom module that fetches this info using the Magento/Zend framework, but since I don't know the code off the top of my head I'll redirect you to the following link which has a very nice SQL query that will pull that info for you (and more).
http://www.magentocommerce.com/wiki/groups/207/fedex_-_shipping_view
You probably just need to add something like this to the end to filter the last 7 days
where so.created_at > NOW() - INTERVAL 7 DAY