Jump to content

Pete

Administrators
  • Posts

    4,054
  • Joined

  • Last visited

  • Days Won

    67

Everything posted by Pete

  1. I'd personally go for building the profile editing page yourself - your list of fields doesn't sound very hard to implement and you'd have more control over how it looks.
  2. I moved from MODx to PW and wouldn't want to move back. Don't get me wrong, MODx (Evo) was a great tool and really useful, but to do anything more complex you have to learn their markup and terms whereas PW doesn't force you to work any particular way. As such, I suspect all of my MODx sites will eventually be moved to PW - the point they make the switch for each will be the point at which being on MODx becomes a restriction (at present, they work so if it ain't broke...). Sorry, I'm not adding much here but since the only other project I currently work on is an intranet system that's home-grown and I can't think of another system I'd need to use besides PW for everything else. That said, I'm getting into Lemonstand for an e-commerce site at present. It's a little bit of a learning curve as they don't have a cheatsheet (ever project should have one since I'm so reliant on Soma's ) but there is great flexibility to be had behind the scenes. They could do with changing their coding to a jQuery style (because I'm lazy) but aside from that if it doesn't have what you need it's easy enough to program something, as well as being easy enough to create custom calls to the database.
  3. If you do have entries in yor list for every year though then the suggestion from another post would be to simply find your oldest article instead of iterating trough all of them and simply start your years from there to the current year, or even hardcode it into the template. If I did have an article for every ear, I'd probably hardcode the start and check the date of the latest article instead - not everyone manages to pen an article on January the 1st as some of us wake up feeling a bit groggy
  4. I found it. Well, the troublesome script at least. I changed this line in wire/core/ProcessWire.php: $logMessage = "Page: $path\nUser: $userName\n\n" . str_replace(" ", "\n", $message); to this: $logMessage = "Request: " . $_SERVER['REQUEST_URI'] . "\nPage: $path\nUser: $userName\n\n" . str_replace(" ", "\n", $message); @ ryan, looking again at the error code in that file, wouldn't it be better if this: $path = ($config ? $config->httpHost : '') . ($page ? $page->url : '/?/'); was actually this: $path = ($config ? $config->httpHost : '') . ($page ? $page->url : $_SERVER['REQUEST_URI']); to potentially give a bit more info, or is there a reason why the fallback is set to /?/?
  5. I've been noticing this message come up recently at random - sometimes several at a time and sometimes spread out a lot. I updated the wire directory and it still happens, however I was wondering if anyone could shed some light on what it actually means, or suggest a way to determine where the problem is? 2012-05-31 03:36:51 guest http://www.mysite.co.uk/?/ Error Exception: Can't save page 0: : Pages of type NullPage are not saveable (in /home/strategy/public_html/wire/core/Pages.php line 463) It's almost certainly an issue with something I've coded, but for the life of me I can't think where to look and I can't reproduce it myself whether I'm logged in or not.
  6. Well somewhere between not that much and every day. Maybe a few times a week. After a while some of it sticks (or so I tell myself), so I don't ened to refer to it all the time It is invaluable though for when I draw a blank and want to check whetner I can do something a certain way.
  7. Thanks Soma - I use this on every PW install. Sure, most of those are just on my local server, but that still counts.
  8. Thanks ryan, I keep forgetting the issue reporting on Github - and thanks Soma as I'm glad I'm not just going crazy
  9. Cheers for that ryan - makes my code a bit lighter again
  10. That's true of my site nowadays, however this was used originally in an articles section where we went months without an article, so I didn't want to display links to months where there were none. It probably would have been easier to simply find the oldest article and display the links anyway and simply return zero results, but I didn't like that from a user point of view. For the news section though it makes perfect sense and I'm kicking myself for not thinking of that earlier
  11. The joys of recursion
  12. For te second question, yes there's only one folder depth and the folder name must be the same as the module file name. For the first question, had you tried it in site/modules ? wire/modules is for core modules only. The idea is that you don't touch the /wire/ folder as when you upgrade you can simply replace that folder and your other modules and templates in /site/ remain unaffeccted (simple upgrades ).
  13. We're working on something
  14. I've just created a tab to put a collection of fields in and noticed that autocompleters don't work in a tab - specifically the PageAutoComplete fieldtype. Can anyone else confirm this? Ta Pete
  15. Something like this then, but I've chopped a lot of code away to just give the essentials and therefore it might need some testing first. I'm also aware that there could be some better error checking too. Something like this should be at the top of your news template before including the head.inc file, as if you put in a year with no articles manually into the address bar, or mis-spell a month name or type in garbage then it should redirect you to the root news page: if ($input->urlSegment2 && strlen($input->urlSegment1) == 4) { $input->urlSegment1 = (int)$input->urlSegment1; $input->urlSegment2 = (string)$input->urlSegment2; if (in_array(strtolower($input->urlSegment2), array('january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'))) { $monthnum = date('n', strtotime('1 ' . $input->urlSegment2 . ' ' . $input->urlSegment1)); $filter = ', publish_date>' . mktime(0,0,0,$monthnum,1,$input->urlSegment1) . ',publish_date<' . mktime(0,0,0,$monthnum+1,1,$input->urlSegment1); } else { $session->redirect($pages->get('/articles/')->url); } } elseif ($input->urlSegment1) { $input->urlSegment1 = (int)$input->urlSegment1; if (strlen($input->urlSegment1) == 4) { $filter = ', publish_date>' . mktime(0,0,0,1,1,$input->urlSegment1) . ',publish_date<' . mktime(0,0,0,1,1,$input->urlSegment1+1); } else { $session->redirect($pages->get('/articles/')->url); } } And then where you want your archive links you'll want something like this to build an array of years and months: $dates = array(); $articles = $pages->find('template=news, sort=-publish_date'); foreach ($articles as $article) { $articletime = strtotime($article->publish_date); $articleyear = date('Y', $articletime); $articlemonth = date('F', $articletime); if (!isset($dates[$articleyear])) { $dates[$articleyear] = array($articlemonth); } elseif (!in_array($articlemonth, $dates[$articleyear])) { $dates[$articleyear][] = $articlemonth; } } And finally, to output your list of links, something like this (but check the $rootNewsPage variable): <ul> <?php $rootNewsPage = '/news/'; // Set this here somehow - my code did something complicated so you'll want something simpler like this probably foreach ($dates as $year => $months) { $class = ($input->urlSegment1 == $year) ? ' class="active"' : ''; echo " <li><a href='" . $rootNewsPage . $year . "/'{$class}>" . $year . "</a>"; if ($input->urlSegment1 == $year || (empty($input->urlSegment1) && $year == date('Y', time()))) { echo "<ul>"; foreach ($months as $month) { $class = ($input->urlSegment2 == strtolower($month)) ? ' class="active"' : ''; echo "<li><a href='" . $rootNewsPage . $year . '/' . strtolower($month) . "/'{$class}>{$month}</a></li>"; } echo "</ul>"; } echo " </li>"; } ?> </ul> That last bit should also put a class called "active" on the links so you can highlight which year/month you're viewing. So there we go, not the prettiest but it should be more or less functional. I'd love to know if there's a better way than looping through all articles though, but I suspect that's a necessity. The only way you'll be able to get around what seems like an expensive selector (especially if you end up running through thousands of articles further down the line) is to cache it somehow and make a module so that it's only ever re-built on page save or even via a CRON job - something I've been meaning to do for a while now. If you cached an array of the month then in theory such a module would simply need to read in that cache file and append a month and occasionally a year as necessary rather than iterating through ALL of the pages - much more efficient on larger sites so I might look into that. Funnily enough I've already got a home-brewed module called ContentCache that caches various bits and pieces like this already
  16. The only way I found was with URL segments and then iterating through all news articles and assigning any new months and years to an array and then doing some checks for those URL segments to filter the news by: http://www.strategycore.co.uk/articles I guess that was pretty much what you had in mind? If so I'll dog out my code when I'm at my PC if someone doesn't beat me to it with their version.
  17. Although I'm sure many PHP veterans already know, that's Hebrew for :: It does baffle me why they've never changed the error name.
  18. Version 2 (the one that pops up when you visit that site) has many more options that I found useful on a site recently so I'd be sure to grab the latest version.
  19. Pete

    Movie Talk

    Absolutely awesome film with Hulk stealing scenes all over the place with his comedy antics.
  20. The only things I've needed I do use a Google library for YouTube (very specific) as well as Flourish for reading a mailbox's contents (again very specific). Other than that a HTML email class like PHPMailer is always useful as it just offers much more than PHP's mail functions. Again, HTML emails sent using SMTP (there are some good reasons not to use mail() on some servers) are pretty uncommon needs so I think of my three this is the only one I'd use regularly in projects and even then not all the time.
  21. Would it be possible to customise a dashboard per user role? That way you could really tailor it on large sites for the needs of different editors.
  22. Thanks for posting that Soma - invaluable for something I'm working on right now
  23. Good question - I'll log out and check it again.
  24. When using search on a site, it shows up the repeater pages as well - is there a way to stop this as I suspect it's not supposed to happen?
  25. Thanks for updating the API ryan - I've imported all the necessary data already but will definitely test it on something else soon
×
×
  • Create New...