-
Posts
6,808 -
Joined
-
Last visited
-
Days Won
159
Everything posted by Soma
-
Cool! I think you only need this line: $field->derefAsPage = FieldtypePage::derefAsPageOrFalse; Edit: just reading again... you want to select fields not pages? Why not just use a simple select? I think ASM select and the others depend on the fieldtype page, which hold the setting to select multiple or only one. Not sure if there's a way to use ASM select for this, as it's always possible to select multiple.. just 1 will be saved. I need to think again what you're really trying Edit: oh and in modules you can always just use. $this->modules->get("nameofmodule"). Edit: I recently used something like this in my DataTable module, maybe this is of help too. $field = $this->modules->get("InputfieldSelect"); $field->attr('id+name', 'filter_template'); $field->label = "Filter by Template"; $field->description = "...."; $field->addOption('', 'Show All'); foreach($this->templates as $t) { $name = $t->name; if(($t->flags & Template::flagSystem)) $name .= "*"; if($this->optionTemplate == $t->name) { // optionTemplate is just example, depending on how you save the settings in your case $field->addOption($t->name, $name, array("selected"=>"selected")); } else { $field->addOption($t->name, $name); } } }
-
Thanks wes for submitting! I got another issue which was reported already by me and someone else. When I add an new repeater element on a page with text, image field, and upload an image only, after saving the page, the element disappears. Though after adding an new one again, the image is still there. Though after saving it then again it stays there as it should. And to add it once again: When cloning pages that has repeater fields. The repeater elements added on the orginial page suddenly get lost, and the new cloned page doesn't have them copied over.
-
Looks ok, though I would use "name". Not sure what's not working. Can you make sure the $featuredTag is really the page returned? You could try a different version. $featuredTag = $pages->get('/tags/featured/'); // use the path $featuredPages = $page->children->find("tags=$featuredTag"); What does it?
-
As per https://github.com/r...essWire/pull/84 Nice! Although it isn't very useful when adding a bunch of modules at once. Also if a module has multiple, with dependencies, it's likely that the links jump to the non-installable version(s). Although there's a note in the description if module dependencies is set. So what if they're also an anchor to the intallable module mentioned? If there is any way to make this a little more clever it would be awesome. We already discussed this a while ago but can't find thread.
-
Most likely you got a page title that is empty, thus the error. Every page in PW needs at least the "title" field which is mandatory. You can't save a page without giving it a title. Is there any entries with no title in your csv?
-
Formmailer you should be able to do something like this (needs allow_url_fopen php server setting to be on), but I guess the rss module also uses it so it will work. Simply use this in the template where you markup cache or xml code is to check if url is available, if not it returns false, the @ is just to surpress any error it would throw. if($file = @file_get_contents("http://domain.com/the/path/to/xml")) { // or @simplexml_load_file echo $file; } else { // do something else echo "not available"; }
-
I spoted an issue when using this on repeater fields list. The percent text doesn't stay after saving the field.
-
http://pw2-dev.ch/pr...ter1122&modal=1 The pages_id 1002 is the page, but the image is saved elsewhere of the page the repeater creates.
-
It's what I did aswell. You're right that before opening an bug report it should be posted in the forums... my brain fart was mainly due to the issue that I aswell started posting in main threads like here, instead of simply a new one, and it get's lost and I don't like to repeat asking and I feel for Ryan. So it's mainly my issue posting my bug in here. --- I just tested and got same behavior as Sevarf2. I added simply a date field autopopulate todays date and after adding new element on page, and hit save... I actually got additional one! Once I try to delete them and hit save. I gets more and more and more new items. I can reproduce, got same issue here. Plain install, no other modules except language. Simple repeater with text field and image field. Users not admin/superuser user can't upload images.
-
Thanks apeisa, I'm currently again testing with repeaters and there seems an issue with cropimages (not sure if images suffer the same) when I add a new repeater element on page with an cropimage field and upload an image, after saving the page the added element dissapears. Though after adding an element again there's still the image uploaded before (already reported issue on repeater thread, but think not solved yet). But after saving the page again then, it stays there and when clicking the "thumbnail" link a new window opens with this error: Fatal error: Call to a member function get() on a non-object in /Applications/XAMPP/xamppfiles/htdocs/pw-dev/site/modules/Thumbnails/ProcessCropImage/ProcessCropImage.module on line 50
-
Before adding any more features () can someone have a test with thumbnails in repeater fields? I doesn't seem to work, as the opening page to make the thumbnails isn't showing any image (just empty) but the layout is there. Previously I even had at some point showing an error that the page can't resolve. I think I posted this issue already elsewhere but can't remember as I thought it was here.
-
Thanks apeisa for the reminder I also updated my post previously already as I remembered
-
I think we need bug reports using github. This isn't well for Ryan, as he misses things in the threads. I posted earlier, that I experienced weird issue when cloning pages that has repeater fields. They suddenly get lost. I think Ryan simply missed it in the flood of posts. Along with some others I already reported and didn't get fixed for whatever reason. Also I think this repeater stuff still needs throughout testing as it is still very fresh and not tested a lot. I'm considering using it in the next project but with all those issues arising it will only be good for not so important/test projects. What you think? EDIT: Just realized that the repeater module anyway is still noted as "BETA TEST ONLY, NOT FOR PRODUCTION USE." But still some place to have a better overview of issues/bugs would be great.
-
No Safari can't drag and drop (yet).
-
This is a method to strip html tags: preg_replace('#<[^>]+>#', ' ', $page->body) If you're picky to get 2 spaces to 1 you could do instead. trim(str_replace(" "," ",preg_replace('#<[^>]+>#', ' ', $page->body))) But in html they collapse if there's more than 1 space except so I think it doesn't matter much.
-
What adam said. public function wordLimiter($str = '', $limit = 120, $endstr = '...'){ if($str == '') return ''; if(strlen($str) <= $limit) return $str; $out = substr($str, 0, $limit); $pos = strrpos($out, " "); if ($pos>0) { $out = substr($out, 0, $pos); } $out .= $endstr; return $out; } Cut's between words.
-
No, it works like a charm here safari 5.1.2 osx 10.6.8. I can see the image select resize and insert it.
-
Adding and Assigning Fields without using gui?
Soma replied to neildaemond's topic in API & Templates
This is the way to create template and fields with API: // new fieldgroup $fg = new Fieldgroup(); $fg->name = 'new-template'; $fg->add($this->fields->get('title')); // needed title field $fg->save(); // new template using the fieldgroup $t = new Template(); $t->name = 'new-template'; $t->fieldgroup = $fg; // add the fieldgroup $t->noChildren = 1; $t->save(); // add one more field, attributes depending on fieldtype $f = new Field(); // create new field object $f->type = $this->modules->get("FieldtypeFloat"); // get a field type $f->name = 'price'; $f->precision = 2; $f->label = 'Price of the product'; $f->save(); // save the field $fg->add($f); // add field to fieldgroup $fg->save(); // save fieldgroup All pretty much standard OO one can figure out looking at core and PW modules. But not someone unexperienced would figure out by themself. I think at some point we need to cover these in a documentation.- 25 replies
-
- 16
-
-
You could output a json config object using php , then it will be available in your js. before your scripts in the header: <?php $jsconfig = array( 'root' => $config->urls->root, 'domain' => $config->httpHost ); echo "<script>var config = " . json_encode($jsconfig) . ";</script>"; ?> this will output an json object <script>var config = {"root":"\/","domain":"pw2-dev.ch"};</script> you can access in js like this <script> $(document).ready(function() { $('#header').click(function(){ window.location = "http://"+config.domain;; }); $('#search_form').click(function(event){ event.stopPropagation(); }); }); url = config.root; </script> This is the most easy and convenient way for me.
-
I made an update to the module. If you get the latest version you'll get new features. Added support for custom selector: Instead of adding more options to exclude pages, since PW is so open as to how to set up you pages/template stucture, I've implemented the option to specify a PW selector. So some of the power of it comes into play. (Remember it's always best-practice to sanitize values that may come from user input you can trust. This module doesn't do any) You can for example hide page(s) with a certain or parent(s): echo $tree->render( array("selector" => "parent!=1008|1002") ); And child pages from those parent will not be rendered. Or if you want to exclude page(s) with certain template(s) you would do : echo $tree->render( array("selector" => "template!=news-item|event-item") ); Or you could limit the items per level: echo $tree->render( array("selector" => "limit=5") ); Added support for "first,last" class: A new option that is off by default, that will output extra class to links. You can turn it on with the options "css_firstlast_on" set to true array('css_firstlast_on' => true) Minor changes: Done some renaming and restructuring. Also removed some newlines in the markup output.
-
Hey tnt, thanks for posting a modified version. - That's a good addition to exclude page per template, it can make sense in the example with news pages. I will implement it as an option. - Hehe, yes I'm not native english speaker, so I often use false words like "childs" instead of children. Thanks for pointing out. - Your right the markup outputted could be improved, but I mostly use a web inspector anyway so that it wouldn't matter much. - I'm not sure if I think about it, last and first is something that can be done more easy with css using li:first-child, li:last-child. And if implemented I would see it as turn on/off feature like the levels-. I don't want that outputted by default. EDIT: Thinking about setting classes, I thought it way could make sense to have an option for where to put the item classes, either <a> or <li>. EDIT: Oh and I would be good to may use github "fork" to then make a pull request so I could implement or merge additions. Or even easier, make a feature request. Same with bugs. It would help not having multiple version around, as people start copying your code and would may lose it after updating it with the github version.
-
Thanks for putting this up here. Interesting read for sure!
-
Nice catch! Thanks sinnut, will update.
-
doh! I was going to wait for 10'000 th posts for launching the fireworks!