Jump to content

adrian

PW-Moderators
  • Posts

    10,902
  • Joined

  • Last visited

  • Days Won

    349

Everything posted by adrian

  1. Stefan, I believe the only reason why your code wasn't working is because you were using $this->addHookAfter. You'll notice that the code I put together uses $this->addHookBefore. You need to populate the value before rendering the field. As for the automatic filling error. Ryan has autocomplete="off" set for the form when editing an existing page. I have also seen this browser produced warning - it is not actually an error. Did you try the module I put together? You can easily change the fields that are being dynamically set to whatever you want.
  2. Horst - I don't think that module will work for the title field, will it? Although I am still not sure if bytesource is looking to make the title field unique anyway - I guess we'll wait and see
  3. Hey Ryan, Some feedback from the dev on these issues: https://github.com/ed-lea/jquery-collagePlus/issues/6#issuecomment-22058143 https://github.com/ed-lea/jquery-collagePlus/issues/5
  4. I think this would actually be quite easy to implement, and yes you might well be able to make use of the code that is used for the module recommend button. In fact, here is the javascript that is used for that recommendation button: http://modules.processwire.com/site/modules/FieldtypeLikes/likes.js The "number_of_likes" field could have its visibility set to "Hidden, not shown in the editor". I actually think a new option to show field values, but make them read-only would be really nice in the admin (but I digress). You could make use of diogo's http://modules.processwire.com/modules/process-admin-custom-pages/ module to easily create the table of liked pages. Before we go reinventing things, let's see what Ryan says about handing over the php code that processes the ajax call from the likes.js file.
  5. Just curious - you say that you want to make the title field unique, but in your code you are trying to set the value of the invoice_number field. This should do what you want, assuming you actually want to set the title field. <?php class MarkupTitleField extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Markup Title Field', 'version' => 100, 'summary' => 'Set the title field to predefined value', 'singular' => true, 'autoload' => true, ); } public function init() { // add before-hook to the inputfield render method $this->addHookBefore("Inputfield::render", $this, "renderField"); } public function renderField(HookEvent $event) { // // get the current field $field = $event->object; if(($field->name == 'title' || $field->name == '_pw_page_name') && $field->value == '' ) { $last_page_id = wire('pages')->get("include=all,sort=-id")->id; $id = date("Y") . "/" . ($last_page_id+1); // example for a possible id value $field->set('value', $id); } } } Edited code to get the id of the page that is about to be created. Not sure if this is completely robust. You might want to consider a different unique identifier.
  6. Glad you got it working. Have you seen the API cheatsheet? http://cheatsheet.processwire.com/ path vs url is explained there for use in both $page-> and also $file-> Your best way to really figure some of this stuff out is to echo the results to the page. echo 'url: ' . $child->webfont_archive->url . '<br />path: ' . $child->webfont_archive->path; That way you can see exactly what is being returned.
  7. Welcome to PW! Try using "->path" instead of "->url" as you need the full path to the file on the server when using include. That said, do you really want to "include" the stylesheet? Do you simply want: <link rel="stylesheet" href="'.$stylesheet.'" type="text/css">
  8. Glad you found a solution. By chance, do the links from the slider images go to other pages on your site? Maybe they don't, but if by chance that is the case the approach I use is a single image field in the template for the pages you want to link to. Then you can do something like: $out .= ' <ul class="slideshow">'; foreach($pages->find('template=basic-page|another-template, slider_image!='', limit=4') as $slider){ $out .= '<a href="'.$slider->path.'"><li><img src="'.$slider->slider_image->url.'" /></li></a>'; } $out .= ' </ul>';
  9. Well as you suggested, that is more of a challenge and I expect to do it nicely would require a module to add an additional field to the image. Ryan provides the code to do this here: http://processwire.com/talk/topic/417-extending-image-field/ A cheat's way out would be to use the description field, for both parts. This is very hackish, but will work. You could split the description field with a delimiter - maybe a pipe - eg: this is the description|http://link.tothe.image.com/ The you could use something like: $description_link = explode("|", $image->description); $description = $description_link[0]; $link = $description_link[1]; Depending on the client this might be too confusing for them to manage.
  10. 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.
  11. Thanks Ryan - that works perfectly and makes total sense.
  12. 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.
  13. 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
  14. 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.
  15. 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?
  16. 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.
  17. 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.
  18. 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.
  19. 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
  20. 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"
  21. 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!
  22. 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
  23. 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();
  24. 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.
  25. I wonder if that line in the function should actually read: if(!$onlyVisible) return $this->settings['numChildren'];
×
×
  • Create New...