buothz Posted April 18, 2012 Share Posted April 18, 2012 I would like to sort the results page with - The last 3 inserted pages - The most visited pages for the last three pages inserted I used the following code $yachts = $pages->find("template=newyachts, limit=3, sort=-date"); foreach($yachts as $s) {... The problem is that do not sort them by date... I do not know if you need to add a field "date", or it is generated automatically (as I thought I had read in the API). Instead to select the most visited pages is there a way? Thanks a lot... Link to comment Share on other sites More sharing options...
teppo Posted April 19, 2012 Share Posted April 19, 2012 You can find a list of built-in page fields here: http://processwire.com/api/variables/page/. As you can see, "date" is not among them. What you seem to want here is "created." If you need the value of that field to be easily editable later, you could also create your own date field and apply some magic to that -- check "Default to today's date", hide field and show when needed / show always and handle pages with date value cleared somehow etc. Hope this helps! 2 Link to comment Share on other sites More sharing options...
teppo Posted April 19, 2012 Share Posted April 19, 2012 Sorry, completely missed your other question, about most popular pages. I don't recall PW having anything like that built-in, but you could always build something of your own; every page load increase hit counter or something like that - although that seems a bit hacky to say the least. If you need more sophisticated solution, you could always integrate with Google Analytics or some kind of Apache log parser, adding relevant statistic data to pages on a daily (nightly?) basis. 1 Link to comment Share on other sites More sharing options...
DaveP Posted April 19, 2012 Share Posted April 19, 2012 Although I haven't done it myself, I understand that Piwik has an API you could use for page view counts and more. 1 Link to comment Share on other sites More sharing options...
ryan Posted April 19, 2012 Share Posted April 19, 2012 Just wanted to follow-up to say that there isn't anything built-in that can tell you what the most visited pages are. You could certainly add a hit counter field to a page and increment it, and save on every page view, but I think that would be kind of inefficient. It would also prevent you from using any cache features if you are having to save a page on every view. I think the best bet is to do what these guys suggested, or subscribe to a hit counter service that bundles this info into an RSS feed or JS widget. 1 Link to comment Share on other sites More sharing options...
buothz Posted April 20, 2012 Author Share Posted April 20, 2012 thanks for all the answers, then as soon as I will post the code here also to helppeople who want to get my same results Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now