Jump to content

Soma

Moderators
  • Posts

    6,808
  • Joined

  • Last visited

  • Days Won

    159

Everything posted by Soma

  1. I understand your view. From your first post it's not clear at all, what form... what hook.. are you talking about? You can't assume everybody knows what tools and code you're using, not everybody uses FormBuilder, not everybody uses PW fields for forms. See? Adrian already spent his time and answered with what most would think from your question... after all it wasn't what you looked for. Of course FormBuilder is using InputfieldSelect, and is a general field. So setting a value to the field applies generally, assuming it's single select (multiple select would be different story again). Now here you're somewhat in the context of FormBuilder and you need a special hook in a special place to interact with the form, that is special to FormBuilder. Further, now that you have it working with FormBuilder how about sharing your solution?
  2. This should be in the FormBuilder support forum. We can't know you use FormBuilder... Maybe share you're code with us so we can see what you got? Have you tried something that doesn't work? Without testing or knowing, if you have the form object inside the hook function you should be able to $form->get("fieldname")->value = "subject1";
  3. Moved thread out of module board.
  4. Moved thread out of module board.
  5. Huh?? Well the first to xample...
  6. I don't think categories is the way to go here. 1. Nested Structure This is a good example where the date structure could be used to create the articles. Then you would a) have the urls already and b) an easy way to create lists and such. Additionally add a date field to the article template so you can choose the date and use that for additional searching. /dagboek/ /2008/ /januari/ // or use "01" as name whatever you like /article14012008/ /article15012008/ /februari/ /article01022008/ /2009/ /januari/ Then loop the years and months in a simple nested php script using API. You don't need to check if there's a year or month with articles if you create months manually. $years = $pages->get("dageboek")->children(); $out = ''; foreach($years as $year) { $out .= "<ul>"; $out .= "<li><a href='$year->url'>$year->title</a>"; if($year->numChildren) { $out .= "<ul>"; foreach($year->children() as $month) { $out .= "<li><a href='$month->url'>$month->title</a></li>"; } $out .= "</ul>"; } $out .= "</li>"; $out .= "</ul>"; } echo $out; Then on the years or months template file, you simply render out their children in any fashion you like and may add pagination using the built in Pager module. You'll have urls like /dagboek/2008/01/page1, dagboek/2008/01/page2 2. Flat The other route would be to use a flat structure and add articles to the /dagboek/ parent. Then add a date field to the article template you can define the day this article is for. Then use a script that checks for articles (oldest, newest) and generate a menu with virtual urls for each year and month that has articles. The URL then can be resolved using urlSegments to show a list of articles for the selected month. You'd have to enable url segments on the dagboek template to make this work. This is a script I created for generating a year month nested menu only for the ones that articles are found. $datefield = "mydate"; $template = "article"; $url = $pages->get("/dagboek/")->url; $newest = (int) date("Y",$pages->find("template=$template, $datefield>0, sort=-$datefield, limit=1")->first->getUnformatted($datefield)); $oldest = (int) date("Y",$pages->find("template=$template, $datefield>0, sort=$datefield, limit=1")->first->getUnformatted($datefield)); $out = ''; for($y = $oldest; $y <= $newest; $y++){ $out .= "<li>"; $out .= "<a href='#'>$y</a>"; $month_out = ''; for($m = 1; $m <= 12; $m++){ $month_start = strtotime("$y-$m-1"); $month_end = strtotime("$y-$m-1 +1 month"); $selector = "template=$template, $datefield>=$month_start, $datefield<$month_end"; if($pages->count($selector)) { // use count instead of find for fast query $month_out .= "<li><a href='{$url}$y/$m/1'>$m</a></li>"; } } if(strlen($month_out)) $out .= "<ul>$month_out</ul>"; $out .= "</li>"; } echo "<ul class='menu'>$out</ul>"; Then, on the dagboek template something like: if($input->urlSegment1 && $input->urlSegment2) { $year = (int) $input->urlSegment1; // 2008 $month = (int) $input->urlSegment2; // 02 $start = strtotime("$year-$month-01"); $end = strtotime("$year-$month-01 +1 month"); // find the articles for within that current month $articles = $pages->get("/dagboek/")->find("template=article, date>=$start, date<$end, sort=-date"); foreach($articles as $article) { echo "<h2>$article->title</h2>"; echo $article->body; } } Just rough examples.
  7. $thumburl = $image->width > $image->height ? $image->size(450,0)->url : $image->size(0,320); echo "<img src='$thumburl'/>";
  8. Moved to dev talk.
  9. I guess you are talking about template output only? You'd then have to build some additional logik and check which side is larger and resize that. You can get the size by $image->height and width.
  10. Huh? Do you mean the "parent_class" ? https://github.com/somatonic/MarkupSimpleNavigation/blob/master/MarkupSimpleNavigation.module#L26
  11. http://processwire.com/talk/topic/3299-ability-to-define-convention-for-image-and-file-upload-names/
  12. You sentence doesn't make much sense, but anyway, the image fields max width and height settings is for when uploading images and nothing else.
  13. There's a max width and max height settings on the image field input configuration. So use size() and keep aspect ratio you can leave on empty or 0, or use width(). $image->size(450,0)->url
  14. PW set's the locale with if($locale != '0') setlocale(LC_ALL, $locale); (LanguageSupport.module) and not LC_CTYPE ? ini_set("default_charset","uft-8") I think is used for header that is sent to browser, and you can also set it in htaccess.
  15. I can now see what you mean and it has to do with the setlocale. For german you have this set to de_DE, and in the default (if it's english) either you have entered en_EN or C (default), and it seems this has an effect on multibyte chars and string functions in PHP. http://stackoverflow.com/questions/5231620/what-does-set-localelc-ctype-c-actually-do around this issue. But since you're using different languages I don't see an issue using mb_'s in your templates.
  16. What I still don't get ( and I couldn't login on your site) is you're speaking of admin or front-end when you say it works/not works? Also do you use language fields or what setup do you have, because I see no language on your site. I can't reproduce this, nor have I experienced this when working with languages in PW.
  17. Ah, now I see you used strtolower(string) which isn't multibyte compatible and since in utf8 cyrillic chars are multibytes it doesn't work correct. It's a string manipulation in PHP and if you have special chars like "üäö" the returned string will get screwed. There quite a lot of string function that do this, and it's normal and expected behavior and there's nothing wrong. So as slkwrm suggested you have to use mb_strtolower(string). I'm not sure I understand what you mean with logged in vs logged out, because that doesn't make a difference. Edit: in fact you'll see the mb_ version of string function used all over in PW core if it's supported. For example https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/Sanitizer.php#L42
  18. Maybe best if you open a new thread with your question in the PW support forum...
  19. There's no thing as to change a file field to a image field on runtime just for if there's an image. There's no standard way as it's not meant to be used that way. The only easy way would be to create a new Pageimage with the file. This requires an image field attached to the page in question so it can use that. foreach($page->files as $f) { if($f->ext == 'jpg'){ $image = new Pageimage($page->images, $f->filename); echo "<img src='{$image->size(100,0)->url}'/>"; } }
  20. This isn't as simple as it may seems and even programmers have their difficulties, it can get very tricky and some approaches may get very inefficient. One way could be to get the oldest and newest article and cycle months and years, and output a menu entry only if at least an article found within that month. Before anyone going to code 1 hours for what you need, is the structure of your article as you show in your example already? Meaning are articles already in a date structure? /dagboek/2005/07/1/article1 ... If so, it would be very easy. If not, rendering the menu is a lot more complex and you also will need to use urlSegments for showing a list of articles of a month.
  21. Also never experienced this, and no clue as to why. It shouldn't make a difference if logged in or not. Try uncomment $config->dbSetNamesUTF8 = true; in site/config.php
  22. From this very thread http://processwire.com/talk/topic/530-profile-export-module-also-upgrade-pw-20-to-21/?p=4263
  23. Shouldnt it be $config->urls->templates ...? Path is for php and file system.
  24. If a field is used in a template you cant delete it anyway.. I don't think using tags would help that and I dont understand what davep problem has to do with op.
  25. I see the same on Mac as Ryan. NEver seen that, and let me says 3.5 mb for a bit of text is quite huge. Apart from that it will be out of date pretty quickly now.
×
×
  • Create New...