-
Posts
6,798 -
Joined
-
Last visited
-
Days Won
158
Everything posted by Soma
-
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!
-
You are save to just replace the files. No need to uninstall, as it doesn't install something or depend on something. Although because it was at first "autoload" and I changed that, you should check in the db table "modules" if the col "flags" of this module is set to 1 and not 3. If it's at 3 it you can just change it manually to 1.
-
Thanks Marc! Well not with the module, usually you make the pages you don't want to appear status "hidden". BTW. I just commited a new update and added support for max level. You can now use 'max_levels' => 2.
-
I just implemented a new option to prepend the rootpage to the navigation. echo $treeMenu->render( array('show_root' => true) ); Thanks Ryan! Yes I wasn't sure if that makes sense, now as you're saying it... So could I make it so that it isn't autoload and load it once before the call, and then you would have the $treeMenu->render variable? Like $treeMenu = $modules->get('MarkupSimpleNavigation'); echo $treeMenu->render(); I will change it I think, as it's better performancewise. EDIT: Just commited new version and updated first post and readme.
-
solved Is URL segment setting no longer as per the docs?
Soma replied to alan's topic in General Support
Thanks, already fixed! -
solved Is URL segment setting no longer as per the docs?
Soma replied to alan's topic in General Support
Hi and welcome to the forums. It's a fault, and should be "Urls" tab not "Advanced". Thanks for mention it! -
I took the chance to make a simple navigation module: http://processwire.c...mplenavigation/ Just commited it for download a post in the module forum. It enables you to do something like this everywhere in your templates: echo $treeMenu->render();
-
Markup Simple Navigation Module While there was a lot of people asking how to make navigation, and there were many examples around already (apeisa, ryan...) I took the chance to sit down 2-3 hours to make a simple navigation module. It has even some options you can control some aspects of the output. Installation: 1. Put this module's folder "MarkupSimpleNavigation" into your /site/modules folder. 2. Go to your module Install page and click "Check for new modules". It will appear under the section Markup. Click "install" button. Done. Technically you don't even need to install it, after the first load call ( $modules->get("MarkupSimpleNavigation") ) it will install automaticly on first request if it isn't already. But it feels better. However, it will not be "autoloaded" by Processwire unless you load it in one of your php templates. Documentation: https://github.com/somatonic/MarkupSimpleNavigation/blob/master/README.md Modules Repository processwire.com mods.pw/u Download on github https://github.com/somatonic/MarkupSimpleNavigation Advanced example with hooks creating a Bootstrap 2.3.2 Multilevel Navbar https://gist.github.com/somatonic/6258081 I use hooks to manipulate certain attributes and classes to li's and anchors. If you understand the concept you can do a lot with this Module.
-
Apeisa is right and it's by far the best approach. Don't worry even simple minded non tech people will understand how to add a page that will serve as a category. It doesn't need to be hidden, only the "/catergory/" page that holds the categories. It can't get any simpler than having a page called Categeory, then click it and click "new". Voila. You can even setup the template to only allow "category" templates as childrens under the tab "Family" in the template settings. After that you can in future even add fields like description and images, so the category could have meta data displayed. And as apeisa mentioned it even allows for multiple categories selected, the page inputfield will allow very versatile usage. There's a real connection that is most flexible. Your solution is very limited and unflexible and to my understanding even more complicated to the site admin to add a weird 1:=Label and it allows for errors very easy. No way to screw up with the page select approach. Anyway you could try this with your code, it was a real mess I guess no problem this "should" work: $features = $page->children("magazine_section=A"); if ($features->count() > 0){ echo "<h2>Feature Articles</h2>\n<ul>"; foreach($features as $feature) { echo "\n\t<li><a href='{$feature->url}'>{$feature->article_title}</a></li>\n"; } echo "</ul>\n"; }
-
Thanks Ryan, it was autoloading the js on module page even though it shouldn't (?). SInce the module isn't loaded there's missing config it would spit out. I renamed the js and load it explicitly on init to avoid this problem.
-
I just updated the cheat-sheet to avoid confusion. Thanks! They're always are cheating!