Jump to content

adrian

PW-Moderators
  • Posts

    11,185
  • Joined

  • Last visited

  • Days Won

    372

Everything posted by adrian

  1. Well, depending on your needs, if you are setting up a gallery of images, you could have a page tree like this: Gallery --Nature --People ----Photo1 ----Photo2 --Action The template for the pages that contain the individual photos (eg Photo1, Photo2) could have the following fields: -Title (obviously as this is required) -Link (this is the field you are looking for) -Photographer -Date photo taken -Location -ETC Of course this structure may be overkill for your needs, but works really well if you want a gallery type setup, so hopefully this might be of some help.
  2. Thanks Ryan - that works perfectly and makes total sense.
  3. Hey Macrura, Thanks for the suggestions. Lots of simple modules ways of doing this - could probably even override the default name on save, but I was hoping Ryan might consider it a useful addition to the core. I am not too worried about it for my needs, but I think it would be a nice refinement still.
  4. Hey Ryan, When entering page titles for things like news articles that have very long titles, these often exceed 128 characters. I think it would be nicer if PW truncated to a whole word, rather than possibly one or a few letters of the last word after a dash. I know the client could manually edit the name, but they never pay attention to things like this Thanks for considering, Adrian
  5. Ok, if you are setting up a page tree of front-end page authors (that are not PW admin users), then I would suggest a page tree like: Authors (template: authors) --John Smith (template: author) --Mary Brown (template: author) The author template could have your portrait image field for each author along with other details about them. Not sure how they are authoring these pages, but presumably through a front end form? As the author creates the page, just assign their ID to the page in an author field. To delete an author and have all their pages deleted could be done easily through the API by using a selector to grab the array of pages with the appropriate author and foreach'ing through, deleting each one. This very rough idea would set all the pages with the assigned author to unpublished. If you want you could obviously delete instead. foreach($pages->find("author=ID") as $selected_page){ $selected_page->addStatus(Page::statusUnpublished); } You might want to do this through the admin by setting up a special page. You could create a simple module, or make use of diogo's http://modules.processwire.com/modules/process-admin-custom-pages/ module - it is really cool for things like this.
  6. Maybe you are referring to avatar type images for admin users? In that case, you can add an images field to the user template. It might be best to limit it to one image, so it that case you would want a new image field as the one that comes with the default profile allows multiple images. Are either of us on the right track with your question?
  7. Everything I have ever read on the subject suggests that DomDocument is much more robust than regex when parsing HTML tags. That said, in this situation, it may well be overkill. I have certainly used regex for the same thing in the past with no problems.
  8. I am sure that it is a line of debug code that diogo was using to check those paths. Note the: //exit on the next line. If you uncomment that, then the echo line will show the from and to paths which are about to be copied. In other words, that line does nothing and the || are just his means of separating the two paths - nothing to do with the PHP "OR" operator.
  9. I just updated the module code above. I was having a blank about how to prevent the duplicate filename issues. Of course it was quite easy - just needed to grab the ID of the page that the image belongs to from the number in the path of the src attribute. Thanks to Martijn's ImageInterceptor I realized this and unashamedly stole a few lines of code from there. I don't think I am ever going to bother posting this to the modules directory in this form. I think a few tweaks to ImageInterceptor will make it a one-stop-shop solution for formatting RTE embedded images. If you don't care about using the ALT tag for the caption, then you should probably use the module from Teppo that he mentions above. For now, my code is still the best solution for me though, so someone might also find it useful.
  10. Yeah, I see that is has evolved for sure I actually don't think you should necessarily grab the alt text from the RTE as the default. Maybe make it an option. See my reasoning in the first two bullet points in this post: http://processwire.com/talk/topic/1344-captions-for-images-in-tinymce/?p=40291. This is why Teppo's solution doesn't work for me. One more thing - it seems the pattern match for the Additional Inline Styles field is maybe a little off. You are using: ([\w-]+:[0-9\w .]+;\s?)+ But this doesn't allow for # which is necessary if someone wants to add a hex color, eg: color:#990000; I think you should also include an example of the required format here, eg: font-size:0.8em; making note that the ";" is also required. I actually had to look at the source of the page to see the regex to figure out what to enter here
  11. Ok, I just installed your module but I don't want to use the percent, width etc settings. I really just want the captions option. So, I emptied those dimensions fields, but the width is a required field. Can you have an option to disable this part of interceptor's options? Also, noticed that it resizes images up. I wonder if those dimension settings should be max so that images will only be sized down (or at least make it an option) - sizing up could result in some blurry images. Minor text correction: Append the style attribut to images. should be "attribute"
  12. No worries about using $page as the variable name - I just didn't look back far enough. I see the preg_match_all and the logic you have for getting the id of the page where the image is from. Seems to me you have a great solution in this module - thanks!
  13. Hi Martijn, I had seen your module, but not the new image caption option - nice work. A couple of quick questions though - does your module handle images inserted from other pages? The following snippet makes me think that it doesn't, but maybe I am missing something in your code. // All image fields of the page $imageFields = $page->fields->find("type=FieldtypeImage"); Also, it looks like it uses the description field associated with the image in the images field, rather than the one used to create the ALT tag when inserting the image in the RTE field. Is that correct? This is actually what I built my module for btw so this would be a good thing
  14. I haven't tested, but does this help: http://processwire.com/talk/topic/1272-new-page-nav-in-admin/?p=11276 $pl = $this->modules->get("ProcessPageList"); $pl->set('id',1001); // or any other parent page return $pl->execute();
  15. I am using getInputfields() and processInput($input->get) to build and process a front-end form. I was using POST, but just changed to GET to handle pagination and bookmarking of results. Only catch is that I end up with the fatal "This request was aborted because it appears to be forged." error. Removing the token from the URL and reloading the page works fine, as does setting $config->protectCSRF = false; in config.php Anyone know why I can't use this with GET forms? If course I could potentially do some hacky things redirecting to remove the token in the url etc, but I think I must be missing the right way to make this work.
  16. I wonder if that line in the function should actually read: if(!$onlyVisible) return $this->settings['numChildren'];
  17. I wonder if this feature could be easily added to this module: http://modules.processwire.com/modules/page-list-better-label/
  18. Just noticed that: $config->scripts->append($config->urls->adminTemplates . "scripts/cookie.js"); results in an error, because cookie.js is not included in the theme download.
  19. Sorry Ryan - I think Chrome or my internet connection was bogged down with something else. I had uninstalled the module and tested again and the images showed within a few seconds, so I had assumed the module was generating images on the fly. I have reinstalled now and restarted my browser and it seems fine now. Am I correct in assuming that no images will show until all have been loaded? This might be an issue still if there are lots of images on a page - a loader/spinner might be nice. The only other comment I have is that when there is only one image on the page, it stretches it to full width which looks a little ugly. Thanks for the great addition.
  20. Hey Ryan, This looks really nice - definitely a big improvement on the existing layout. Only catch I am seeing at the moment is that with really large images, it takes a long time (almost a minute in one case) to load the thumbnails. Obviously I am not displaying these high res images on the site, but they are being made available for download - linked from an automatically generated screen-sized version.
  21. Thanks for all the feedback everyone. There are a few reasons I didn't go with JS (which I have used for several years for making image captions from ALT fields). I wanted to use the Image description field that is with the image in the images field, rather than the one that is added when inserting the image into the RTE (and becomes the ALT tag). This is what Lars asks for in post #3 above, but more importantly, this has the advantage of keeping the ALT for its intended purpose which is to describe the contents of an image for screen-readers/search engines - eg. "clothes on a clothesline". This allows the image caption to be more relevant to the context of the image in the text. eg. "Hanging your laundry outside saves energy, money, and the environment." I also wanted to be able to define which images get the caption added. This way you can still maintain your accessibility (for screenreaders etc) by always having an ALT tag, but leave the description field blank if you don't want a caption. I wanted to restrict the the production of captions to textareas only, without relying on a container div for determining which images get processed. Doing this server-side just seems cleaner somehow Teppo - I could just as easily have used a regex, but domdocument just seems easier to me when it comes to tasks like this. I am still looking for a way to solve the issue of two images with the same filename somewhere on the site. Again, this only comes up if your pages are drawing content from other pages, but I do this often, so would like to solve - any ideas?
  22. Thanks Ryan, I glanced over it and I think I have the idea on how to set up what I have been talking about. Not something I need right now, but I am sure I'll use it in the near future.
  23. Thanks Marty, I think it's a reasonable start. It would be a lot simpler to just go with the description field at image insert (ie the resulting ALT tag) as this avoids all the issues of searching through the page tree looking for the image description by filename. I'll wait for a little more feedback and ideas for solutions regarding the duplicate image filename issue and then I'll start adding some config options.
  24. I have hacked this module together which seems to work pretty well. It wraps the image in a div and grabs the caption from main description field within the images field. I think this is what you were looking for. This is all done with PHP, rather than JS. Probably not a very elegant approach, but I needed something quickly. After some feedback, I would like to add some config options for formatting of the caption and whether you want the caption from the images->description field (as it currently is), or simply the one that becomes the ALT tag in the RTE textarea. Also, the module should perhaps named as a textformatter? Any thoughts? EDIT: I just replaced the attachment with v1.01 which now handles pages that include textareas with embedded images from other pages in the tree. One concern with this is that if an image with the same filename exists anywhere else on the site, it won't know which one to use. Not sure how to get around this yet. EDIT: 1.02 makes sure there is appropriate content on the page to prevent warning error. EDIT: 1.03 makes use of some code from Martijn's Image Interceptor to grab the id of the page the image is from, to deal with the potential duplicate filename issue. Available at: https://github.com/adrianbj/ImageTextCaption
  25. Hey Nico, You have a couple of instances of $config that need to be changed to wire('config') Thanks!
×
×
  • Create New...