Jump to content

Pete

Administrators
  • Posts

    4,056
  • Joined

  • Last visited

  • Days Won

    67

Everything posted by Pete

  1. I've not tested this thoroughly yet, but to hijack the thread slightly and go back to my earlier request - we don't need to. I realised the other day that if PW is just made to use the default theme (called "default") then we can just have additional CSS in the admin CSS file to override colours etc instead of my idea to somehow support multiple themes. So... ignore my previous posts asking about that. Back on topic, I'll try to test these changes over the weekend if I get time Soma!
  2. Thanks for that - unfortunately that was my fault for copying and pasting incorrectly, and my code does have it in the correct order. Unfortunately it still doesn't work and shows me that error with setOutputFormatting in the correct place. I've upgraded to the latest version of PW but that doesn't help either unfortunately.
  3. Hi folks I've got a hook that runs on page render: $this->addHookBefore('Page::render', $this, 'setCommonVars'); My function contains this code: public function setCommonVars(HookEvent $event) { $page->setOutputFormatting(false); $page = $event->object; $page->article_comments = $comments['total']; $page->save(); $page->setOutputFormatting(true); } $comments['total'] is from somewhere else - it's an integer and the field will accept an integer - I've removed a chunk of surrounding code for readability. Unfortunately when the hook runs, I get the following error, which makes little sense since I've already turned off outputformatting <b>Fatal error</b>: Exception: Can't save page 1414: /news/test/: Call $page->setOutputFormatting(false) before getting/setting values that will be modified and saved. [article_comments] Any ideas?
  4. Yup - you need to check in your template what size the image already is using $image->width() and $image->height() if you don't want things to be blown up by the $image->size() code in the template.
  5. It's like PEAR in that it's a library of useful functions, but this one is all worked on by one guy (as far as I'm aware) so it's far more coherent than PEAR. I'm using it for things like this: http://processwire.c...ndpost__p__2407 - it just allows previewing the last 10 emails of a given inbox - in this case it's a press email account so staff can read emails and write any news or other articles based on them. I toyed with the idea of being able to grab the email text and make a page automatically from it, but as anyone who's worked with emails knows you can end up with all sorts of formatting issues. Even if you remove all the formatting it does seem like overkill anyway. I basically lost all my progress on that when my hard drive died last year, but it's actually not that hard to do things like that with Flourish and PW. There is another topic on the forums where various newsletter systems were mentioned and that got me thinking (on a basic level) of something like PHPMailer too - before I remembered Flourish can cover that need - so there are things that PW can't do where it's useful to know about other well-coded classes and libraries to help out. Oh, and before I forget - try this in your config instead of that $_SERVER['DOCUMENT_ROOT'] netcarver: $flourish_root = wire('config')->paths->root . 'site/.flourish/'; Either will work of course, but I've had weird experiences with servers and paths in the past so I just felt a bit safer knowing I was definitely using the same paths throughout my code.
  6. Try this: echo "<h1>Tags pages</h1>"; foreach ($pages->find("tags.count>0, sort=title") as $tag_pages) { echo "<h3>{$tag_pages->title}</h3>"; echo "<dl>"; foreach ($tag_pages->tags as $tag) { echo "<dt>{$tag->title}</dt>"; } echo "</dl>"; } Not tested it but it should work. Basically, it should be iterating through the pages that have tags, and then the tags on those pages. This might seem like it's getting repetitive in that 10 pages might have the same tag and it feels like it might be fetching those tags 10 times, but if I'm right (and ryan or someone else more knowledgeable than me will have to confirm) those pages stay in memory until the end of the script.
  7. Thanks for that - it was infinitely simpler than what I'd managed to put together the last time - mich appreciated!
  8. Hmm, I'll have a look into that loop as well as maybe add an option to select individual users who you want to be able to see the site (it does make sense). As for PW in a sub folder - the only thing to ear in mind really is URLs in a TinyMCE field if you do any editing as they will use the path of wherever PW is at the time. In this case you can use ruan's PageLinkAbstracter module (see the modules page on the site) and set the body field accordingly. I doubt you'll need to use it in this case but it's worth knowing about.
  9. The chat on the forums does work, but as it's a free license it only accepts up to 5 users (not taht that's been a problem looking at the logs). Either way, a channel on Freenode is a great idea - I might fire up Trillian when I get some spare time and pop my head in.
  10. That's pretty neat Have you seen the cheatsheet though?
  11. I just remembered I've used the ZipArchive class recently too. I've got an inteanet system where zip files are uploaded and I have to check for a readme.csv file and it's perfect for that as there's very little overhead (as in it doesn't unzip the whole file but can search for a single file and pull it out very efficiently). That's not what we're doing here obviously, but it is cool!
  12. You're right there - that could cause issues, but what I don't like in other projects (and PW does this as well actually thinking about it) is when you have lots of different TinyMCE folders over time, each one with a different version number, so I'm not sure how that should be handled. The problem is if you start having too many different versions then you may as well not bother and stick the library in the module folder. I don't think that there will be too many modules requiring third-party libraries though - the two that I can think of at present are Flourish and the Google API, but I don't need the Google API for my YouTube module any more (going to use that open video thingy - can't remember what it was called bu it could grab from any video site) so it's just Flourish really. I think most good libraries will maintain some backward compatibiity anyway - just thinking about PHPMailer as well which I've been using for years and the dozen or so versions I've used all had the same function calls so there was no real issue. I think it might be interesting to have some checks in modules - suggest a minimum version for a library and somehow be able to check the version (I think most good libraries will give you access to a version number via some form of function wouldn't they?). In that case we should probably come up with a few good functions for modules to check versions of the main libraries we would use as and when we write modules for them. I know this might seem a bit overkill, but I really like the idea of having a module check for library dependencies and simply show a message if the user either doesn't have that library or if it isn't a high enough version. To me that is much more preferable to less technical users installing modules and facing a broken website and assuming the module doesn't work. It is then up to module authors to keep their modules working with the latest versions, but in the case of Flourish and PHPMailer they're quite good at being backwards-compatible like I said.
  13. In fact this sounds like a similar issue I was having - I bet you anything that the entry is still in the database for these tags but the value is empty.
  14. I would say that this actually sounds like a bug - before you had any tags produced a different result to when you added and deleted one and tested it again and that's not right...
  15. There is a module to automatically put you back to the right place in the page tree (ListAfterSave) that can speed things upa bit when adding lots of new content, but that's not quite the same. I do miss some options I had in MODx - Save & Contnue Editing, Save and Exit and Save & Add Another Page (can't remember the short names for them any more). I do like your idea of next and prev as well, and would be reasonably easy to do in PW. I keep meaning to have a look at this so might give it a dabble this weekend.
  16. Try this: <?php // Link to title of each page that shares one or more tags with this one // --- // find this pages tags //$this_pages_tags = $page->tags; // Not really needed as we can just use $page->tags as below // each tag, find other pages that match the tag // TODO limit the find? $other_pages = $pages->find("tags=$page->tags"); // $page->tags when used in a selector will be something like 123|32|667 (page IDs separated by a pipe character, which means OR) // Following is not needed as we grabbed them all via the above find() /*foreach ($this_pages_tags as $tag) { $other_pages = $pages->find("tags=$tag")->not($page); }*/ // output title of foreach ($other_pages as $matched) { echo "<a href='{$matched->url}'>{$matched->title}</a> "; } ?> It'll display all pages linked by tags this way, but won't give you access (easily anyway) to what they matched on. That would be harder to accomplish, but it would maybe allow you to prioritise and have pages with more related tags appear higher up the list. I'd question how useful it would be beyond just being cool though
  17. I think these two are the solution: http://www.tinymce.com/wiki.php/Configuration:editor_css (which I assume corresponds to ui.css in a skin folder) http://www.tinymce.com/wiki.php/Configuration:popup_css (popup.css in a skin folder) Between these and content_css this might be a way forward. If we set a standard folder in the templates-admin folder (/editor-style/ maybe?) and somehow have it check that folder using some PHP - if it finds the folder and the required files it can use that template, else stick with the default.
  18. Thanks Soma Cirkuit also works well - think I used it because I was getting my admin templates mixed up at the time, but it does look good with your template. Anything to stop a /wire/ folder update overriding the edits currently needed in the TinyMCE folder to choose a custom template would be much appreciated Then, when this gets merged with the core (reasonably sure ryan would be happy once it's been tested) it would be another thing to help customisation of the editor as well as custom admin templates I guess that the best place for the custom TinyMCE template would be the templates-admin folder so they can be packaged with the admin template.
  19. So we can specify different editor template sets as well? I don't like the default (doesn't fit well with your asmin theme Soma) so manually change it to 'cirkuit' every time is a bit of a chore so getting around that would be most welcome
  20. The best bit for me is the Json error - "expecting false but found fish"
  21. Just updated that post above, so there's possibly more things to try
  22. You're fine up until 4. 4. Create a tags template and make sure your tag pages use that template - you can link tags to it from your other pages that have the tagging field by doing something like: foreach ($page->tags as $tag) { echo "<a href='{$tag->url}'>{$tag->title}</a> "; } The tags will be separated by a space and link to something like /tags/tagtitle/ Then in the tags template you can do: $tagged_pages = $pages->find("tag=$page"); // assuming "tag" is your tag field name. $page is the current page object, so this may seem odd but when echo'd or used as part of a selector this actually outputs the page ID, so this is the same as $page->id but shorter, which is nice foreach ($tagged_pages as $tagged) { echo "<p><a href='{$tagged->url}'>{$tagged->title}</a></p>"; } Then I think you can skip your remaining steps. Hope that helps. In terms of other examples, I posted some earlier that do similar things in a different scenario: http://processwire.c...ndpost__p__9564 That set of examples doesn't really tell you what to do with templates, but does hopefully give you a few more ideas about how to find related data.
  23. Tom - I only found out about ternary operators last year I think (I must have been under a rock until then). They have their uses but sometimes I end up over-complicating things with them by trying to nest them and do weird stuff you would usually see in an Excel formula - whichever produces the more readable code is usually the best way, though in this case it's pretty legible either way. I keep forgetting that PW already handles empty fields well so the check is unnecessary. Steve - Chester's not bad thanks. Certainly wasn't sunny last weekend, but looks like it will be this weekend - that must make it beer o'clock at some point on Saturday avo Whereabouts are you? As for Flourish, before I lost a load of data in a hard drive failure (my poor SSD!) I actually had an integrated email fetcher type program sitting in the PW admin page. The idea was that for one project I was going to have it list the last 10 email titles and they opened up in a modal window when clicked. I had this working and even submitted comments to add a sort option to the mail functions with Flourishlib (rather bizarrely, if you access a mailbox and pull out 10 emails it pulls out the oldest 10 rather than the newest 10 - I can't think of any reason why you would want the oldest mail from an inbox Sadly that code hasn't been implemented but it's in the bug tracker system there if anyone needs it). It is an excellent library indeed. I am also using Google's PHP API on a project at the moment and was unsure of the best place for it so it doesn't just get tied to one module's folder. I suspect we could do with some sort of convention for this - perhaps a site/lib folder? That way you could single-file modules in site/modules and multi-file modules in site/modules/your-big-module using one set of library files rather than packaging each module with the same libraries over and over). I know that you can pretty much do whatever you want with ProcessWire, and that's part of the beauty of the system, but I think that as more modules are developed with 3rd party library dependencies it might be best if everyone agrees on where to put them, and maybe (just throwing this out there) have an empty site/lib folder in the master branch for PW on GitHub? What do other module authors think? I understand an empty folder could cause confusion, but that can easily be fixed by sticking a readme file in it clearly explaining its purpose.
  24. Yup - I didn't need the !empty() bit in mine it turns out so I'll nip back and edit that post to avoid confusion.
  25. Try this: <? $image = $profile->images->first(); echo "<img src='{$image->url}' height='{$image->height}' width='{$image->width}' alt='" . ($image->description ? $image->description : $image->name) . "' />"; ?> Hehe, posted at the same time more or less netcarver
×
×
  • Create New...