Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/01/2013 in all areas

  1. Btw, this might be a good place to mention that PW 2.3 dev adds a new Page::getUnknown hook (soon to be committed). That function gets called whenever a field is accessed that didn't resolve to anything. So you could [n the near future] do this (below) and you could call $page->some_radio_button_group on any page (specifically those that didn't already have the field) and have it resolve to what you want to. wire()->addHookAfter('Page::getUnknown', function($event) { $page = $event->object; $name = $event->arguments(0); if($name == 'some_radio_button_group') $event->return = new NullPage(); });
    3 points
  2. Hi, Valan. I guess you should try to log the inputfield name in a cycle just before LanguageSupport.module on line 380 so you could understand when it breaks. Also try to substitute line 379 temporary just to see if the problem remains: if(!$value && (!$inputfield instanceof Inputfield)) continue; Seems like you have some problem with an instance of a wrong class. Have no idea what causes this error. Cheers.
    2 points
  3. For pages that you want to automatically direct to the first child, I would make them use a template that has this in it's code: <?php if($page->numChildren) $session->redirect($page->child()->url); If you add a new child page, and they aren't sorted by date added (descending) then the newly added page isn't likely to be the first child. If no default sort is selected, then it'll add it as the last child. So if you wanted to redirect to last page (rather than the first) then you'd want to do this: <?php if($page->numChildren) $session->redirect($page->child("sort=-sort")->url); By the way "sort" is just a name representing the order that pages have been dragged/dropped to. That's the default value if a page doesn't have another field selected as it's default sort field. The minus sign "-" in front of it represents descending sort. Without the minus sign, it would be ascending. Since you want to select the last page, that's why it's "-sort" rather than "sort". Or if you wanted to make it select the most recent page added by date: <?php if($page->numChildren) $session->redirect($page->child("sort=-created")->url); The above is also descending since most recent added would be the highest date.
    1 point
  4. Nothing earth shattering, but easy to implement. <ul class='breadcrumb'> <?php foreach($page->parents as $parent): ?> <li itemscope itemtype='http://data-vocabulary.org/Breadcrumb'> <a href='<?php echo $parent->url; ?>' itemprop='url'> <span itemprop='title'><?php echo $parent->title; ?></span></a> <span class='divider'>›</span> </li> <?php endforeach ?> <li><?php echo $page->title; ?></li> </ul> It's based on the breadcrumbs in the default PW profile, but the presentational markup is Bootstrap flavoured. Try it and copy the resulting html snippet into Google's rich snippets testing tool - http://www.google.com/webmasters/tools/richsnippets.
    1 point
  5. Hi, I'm currently working out PW a line at a time by pulling apart each Site Profile found in the Modules section, referring to the cheat sheet and the great help docs. Thanks Ryan, Joss, Martijn-geerts and Soma I would love to see more Site Profiles uploaded! I'm being cheeky here, but are there any more users that would like to share their creations? Thanks in advance. Sorry, I have just noticed I posted this request in the wrong section. It should of gone in the Modules/Plugins!
    1 point
  6. Hi. I'm new to this CMS, but truly love some of its solutions. I'm about to build a community website, with a wiki a forum and some other stuff we can come up on the way, i was using pyrocms lest time, but i wasn't very happy about how Codeigniter made the development difficult. Now, in the last days I made a quick user registration front-end for PW, but iv got concerns about its capabilities. I plan to use PW mainly as a user management and sorting platform for other systems (no blog in sight yet), and since this system absolutely doesn't emphasize these features (no sorting, fields, management of users, no registration etc.), I might be wrong choosing it. I'm not concerned about missing features since I love to solve problems, my concern: Can this system handle thousands of users/related pages/numbers of posts etc, can it be scaled up without problems, registration, activation, or am I on the wrong path? Anyone has any experience? maybe its not built for such tasks Thanks
    1 point
  7. 1. The upload max width and height setting is a way to avoid having the user upload 4000x10000px images. Remember it's a "max" size setting not a "thumbnail" setting. See it more as a original image that should be un-cropped. This keeps it flexible and simple to start with and if you maybe want to change the image size you still have the original image. Note that there's also several API calls in the image file to check for original and variations. Theres modules or simple ways for creating cropped images - as per Thumbnails module http://mods.pw/1b - or to requires a certain format http://processwire.com/talk/topic/3476-fixed-image-size/?p=34110 (add "min" size settings to image fields) - or a way to resize images on upload using simple module http://processwire.com/talk/topic/3718-lots-of-images-to-resize-timeout-in-frontend/?p=36291 2. Again it's not meant as a cropping setting for uploaded images. It works this way that if you set width "1000" and height "500" the image upload will be resized either in with or height or both depending on which side is larger than 1000px or 500px. That's why it checks both separate, at least I think so. 3. Most of the times you upload images and on output in the template file you generate the image size $image->size(520,261)->url and it will only create it if it's not already found and it will also recognize your crop settings. It creates a new copy and names it with the size you specify beside the original. This is the most straight forward way to work with images and there's not much more about it. But the system still allows to build on that and extend and change behavior of the image field if you wish.
    1 point
  8. You can always make a copy of a particular module, rename it and install it as a different module so you can change its functionality without losing the original or losing your changes if/when the original is updated. There is at least one thread in the forum on the subject but I can't find it just now, even thru Google.
    1 point
  9. One way I like to get around this problem is to have a 'list' template which just displays an unordered list of the page's children, like a menu, and use it for the parent pages (Employee, Department & Year). Then you can use breadcrumbs (good for usability) and it will allow an experienced visitor to navigate by editing the url if they so wish. I suspect it would also be helpful from an SEO and spidering perspective, but that's just a hunch. Depending on your navigation and menu structure, those pages might never or rarely be seen, but, for the work involved, it can't hurt.
    1 point
  10. Batcher has saved me major time on a few occasions too. Definitely a must-have module.
    1 point
  11. A field's name is almost like an id and it shouldn't be changed. This might happen when you start but once you setup your fields they most likely also are referenced by their name in template files or other settings and changing the name will break your code or output. In a perfect world this module maybe would have some configuration you could define the field by reference. Using the id here you'd have to get the field first. I changed the code var $field to $inputfield, to avoid confusion as it's actually the inputfield and not the field (as the hook already suggests). Inputfields have no id. They serve mostly as the input that interacts with the user. If you get the id of the inputfield you'll get the Inputfieldimage_fieldname, which is used for the markup when it's rendered. It's the fieldtype that is the one that has a id property, the id you see when editing a field and in DB. To debug the module it's a little special, but it can be easily done by using a simple trick. Add this in the hook function echo $inputfield->id; exit(); or die("id:" . $inputfield->id); Now if you upload an image it will stop there and you should see what it outputs. If you're using ajax upload, this is seen in the ajax request response if you look in the developer tool. It will show "InputfieldImage_yourfieldname". Now to get the actual field you get it via the "name" of the field using $fields API. $fieldID = $this->fields->get($inputfield->name)->id;
    1 point
  12. I'm not sure about this one or exactly how to reproduce from here. But if you want to give me a login to this site and tell me what/where to click to reproduce it, I'd be happy to take a closer look. Also let me know what version of PW you are using and whether dev branch or not.
    1 point
  13. You may want to set $select->required = true; so that there isn't an unselected option. Rather than removing all the options and adding them back, you should just be able to set the 'value' attribute to whatever you want the selected option to be: $select->attr('value', $selected_page_id); Note that "kg" is your label rather than the value, so you are going to know the ID of the page with name/title "kg" in order to make it selected.
    1 point
  14. I'm not enough of a Javascript expert to say for sure here. But I do know that jQuery provides some pretty reliable functions for this use: $(window).width(); // returns width of browser viewport $(document).width(); // returns width of HTML document No need to worry about session IDs with ajax requests. The server and browser are all handling this behind the scenes in the same way they do with a regular request.
    1 point
  15. Just used this to remove over 900 pages, while keeping about 50 valid pages. Saved at least hour of work. Just a brilliant module, thanks Wanze!
    1 point
  16. Hi Ryan Thanks for your help! You where completely right. There was a link in the module to one of TinyMCE's javascript files. (tiny_mce_popup.js). I changed the path and now it works perfectly. By the way, I'm a big fan of Processwire. I always kept my hands off all CMS, because it seemed so difficult to me to have functionality and freedom for the design at once. With PW everything seems possible. Great work! tron1000
    1 point
  17. Thanks Ryan. It was really massive learning to write this together. In fact I have (re)written it three to four times. Every time I want it to do something from what I don't know the PW-way, I have done it old-schooled first. Then a few days later, I've found informations here in Forum or in the docu that show me how to do it better. And I have rewritten it. Much work, much fun, me.better PW.coder now. ( but also much.much.much.more to learn ) The only downside with that project is that I now don't like my (before LocalAudioFiles) new created (but still not finished) portfolio site any more. I have trashed it and started new from scratch. With it there are new things like sessions, redirects, cookies and, ... yes, again: much.learning!
    1 point
  18. Microdata is always good to have, thanks for sharing this! Personally I wouldn't depend too much on data-vocabulary.org though. Their home page makes it pretty obvious that schema.org is the new toast of the town. With schema.org vocabulary breadcrumbs could be implemented like this: <body itemscope itemtype="http://schema.org/WebPage"> ... <div itemprop="breadcrumb"> <?php foreach($page->parents as $parent) { $end = ($parent === $page->parent) ? "" : " > "; echo "<a href='{$parent->url}'>{$parent->title}</a>{$end}"; } ?> </div> <!-- this follows strictly schema.org example --> Or with markup matching above example: <body itemscope itemtype="http://schema.org/WebPage"> ... <div class='breadcrumb' itemprop='breadcrumb'> <?php foreach($page->parents as $parent): ?> <li> <a href='<?php echo $parent->url; ?>'> <span><?php echo $parent->title; ?></span> </a> <span class='divider'>›</span> </li> <?php endforeach ?> <li> <?php echo $page->title; ?> </li> </ul> <!-- this isn't exactly what schema.org describes but should still be valid.. --> There's quite a bit of discussion floating around whether schema.org version of breadcrumbs is actually useful, but it is what their example currently suggests. Note also that breadcrumb is a property of WebPage, ie. you'll have to be in that context in order to use this properly.
    1 point
  19. Oh, another owzim question $val = $pages->find("template=mytempl, sort=-counter, limit=1")->first->counter + 1;
    1 point
  20. Hi, and welcome Judging by this sentence, I would say you are in the right place. Still, I would advise you to read Ryan's answer to this post to make a decision about building something like this with PW http://processwire.com/talk/topic/3549-can-i-build-my-project-using-processwire-events-ecommerce-trip-sharing-community/ About your concerns: Yes, the system can handle thousands of users/related pages/numbers of posts etc and it can be scaled up without problems. Scalability is one of the strong points of ProcessWire.
    1 point
  21. Hello, I was experimenting with comments manipulation through the API and found that saving modified comments works when you specify the field name when saving your page. For example, the following does not work: $page->of(false); $page->comments->get(0)->status = -2; $page->save(); But the following does: $page->of(false); $page->comments->get(0)->status = -2; $page->save('comments'); Seems you need to specify the comments field name explicitly when saving the page.
    1 point
  22. Hi Peter, That's because all the API variables like $users, $page, $pages... are not known to the function. PHP - scope problem. The solution is to use the global wire() function from Pw to get the API variables: $vista = wire('page')->vista; // ... if (wire('user')->language->title != 'no')) { // ...
    1 point
  23. Ok! Then i tried to do a checklist: Translate the documentation in this order Brief description of PW Installation of PW Installation of language pack Start to translate also this part: http://processwire.com/api/ (PDF) Collect all the italian sites for a little showcase (i have only 1 site really active, the rest is on development) http://www.estreti.it/ http://smartenergysite.infofactory.it/ (Under development, on the next week is completed). http://sincronpolis.infofactory.it/ (Under development) Check if we use Ryan hosting or my server or whatever other hosting. Make the site! Any suggestion are welcome!
    1 point
  24. .. and now it should definitely be password-protected, hidden or removed to avoid unnecessary confusion / people browsing that instead of real site. Good point, @owzim
    1 point
  25. Hi, Doolak. I think there's some confusion going on Search module (ProcessPageSearch)is purposed solely for back-end usage: it runs when you hit search in the admin interface (and you get to the back-end search page whare you can see the default settings you mentioned). The default settings of this module don't affect your template code, they are totally independent. Your selector, access rights and page status are three things that define the results you get when you search via api. It seems though, there's no way to search repeater fields with ProcessPageSearch at the moment. Correct me if I'm missing something.
    1 point
  26. a. Looks ok except you get the page with the argument given to saveReady $page = $event->arguments(0); I often use a little trick to debug to find why it doesn't work. Enter $page = $event->arguments(0); echo $page->title; exit(); In the hook function, if the hook works you should see a white screen and the page title. b. Remove the trailing ?> at the end, not needed and could give header already sent errors. c. Other than that I can't produce the session error (what was it exactly?) Module works, install uninstall ... Why do you wanted to uninstall the module? To change something in modules you usually don't have to uninstall it, except if you change stuff that would need to have it installed from scratch. If you run into problems with a module, you should remove files AND the entry in the DB table "modules" for the module. Then start again.
    1 point
  27. My very first PW site: http://fantastique.ch/ Launched a week ago. The bulk work was not design or scripting / CMS-related, but writing copy and choosing what work to include and what not. Oh, and exporting tons of data from MODX Evo and import to PW (lots of data was in an ancient site / on another domain). It was a great learning process, and I must say it's a real pleasure working with PW. Thanks for all the help I got so far with my n00b questions in here. I'm not happy yet with the frontpage (should add more content and probably more visuals). I'm gonna add some case studies (simply describing a project from start to finish in more detail). And if I really have a full week or two, add a german version as well. Initially, I wanted a multilingual version from the get-go, but I decided it's better to launch something, rather than nothing. In June, I'll launch my 1st PW-powered client site. Looking forward to discover even more PW awesomeness along the way.
    1 point
  28. I think this method will work even if you expand it out. I changed a few things up, but hopefully it makes sense. Product pages use "template product", all other catalog pages use "template catalog". Catalogue -- Men ---- Shoes ------ Product 1 ------ Product 2 ---- Hats ------ Product 1 ------ Product 2 -- Women ---- Shoes ------ Product 1 ------ Product 2 ---- Hats ------ Product 1 ------ Product 2 Categories (these pages only a template with a title field) -- Brands ---- Brand 1 (title only template) ---- Brand 2 (title only template) -- Type ---- Type A (title only template) ---- Type B (title only template) -- Collections ---- Collection A (title only template) ---- Collection B (title only template) catalogue.php template & product.php template (same contents) <?php /* There might be a better way to accomplish this. The only reason to have 2 templates is to give find() a way * to only return the actual product pages, and not all the parent pages as well. * * update: You may want to look into using the alternative template method: * * * With this approach you would create a real file (product.php) for the product template, * catalogue template would have no file associated, but point to product.php under the advanced settings tab. */ include("./site/templates/head.inc"); include("./site/templates/product-view.inc"); include("./site/templates/foot.inc"); product-view.inc <?php $brand = ""; $type = ""; $collection = ""; if ($input->urlSegment1) $brand = ",brand.name=".$input->urlSegment1; if ($input->urlSegment2) $type = ",type.name=".$input->urlSegment2; if ($input->urlSegment3) $collection = ",collection.name=".$input->urlSegment3; if ($input->urlSegment4) { // if Segment 4, then we know what page to get $product = $pages->get("name=$input->urlSegment4"); echo $product->title; } else if ($input->urlSegment1){ // check if we are using URL segments if ($input->urlSegment1 == "all"){ $products = $pages->find("has_parent=$input->urlSegment2, template=product"); } else { $products = $pages->find("has_parent=$page->path, template=product, . $brand . $type . $collection"); } foreach ($products as $p){ echo $p->title; } } else { $products = $pages->find("has_parent=$page->path, template=product"); foreach ($products as $p){ echo $p->title; } } Looking at example URLS to see how the selector would get populated: /catalogue/brand1/ Brand1 is a url->segment1 so the elseif evaluates to true, and the selector gets populated to become: $products = $pages->find("parent=/catalogue/, template=product, brand.name=brand1"); /catalogue/brand1/casual/ elseif evaluates to true, and the selector gets populated to become: $products = $pages->find("parent=/catalogue/, template=product, brand.name=brand1, type.name=casual"); /catalogue/brand1/casual/trendy/ $products = $pages->find("parent=/catalogue/, template=product, brand.name=brand1, type.name=casual, collection.name=trendy"); /catalogue/men/ $products = $pages->find("has_parent=men, template=product"); /catalogue/all/shoes/ $products = $pages->find("has_parent=shoes, template=product"); /catalogue/all/hats/ $products = $pages->find("has_parent=hats, template=product"); /catalogue/men/shoes/ no URL segment here, so the if/elseif are false, so we get: $products = $pages->find("has_parent=/catalogue/men/shoes/, template=product"); /catalogue/men/shoes/brand1/ Brand1 is a url->segment1 so the elseif evaluates to true, and the selector gets populated to become: $products = $pages->find("parent=/catalogue/men/shoes/, template=product, brand.name=brand1"); you get the idea. Again, untested and coded in the browser — but hopefully thought out enough to get you started.
    1 point
  29. Truth of the day: - WordPress is one of the most downloaded CMS so they must be doing something correctly. - specially for the germans: BILD-zeitung is the most selled Newspaper, so they must be doing something correctly. Yes of corse they will do something correctly, but what does it tell me about the quality / usability of it? --- Petsagouris, I have had two quick views to this lib, and it is like it is with most others of them: 1) sharpening - https://github.com/avalanche123/Imagine/blob/develop/lib/Imagine/Gd/Effects.php they have 1 pattern! That's that pattern that is into all libs that have sharpening and of corse you can find it all over the web. (php.net usernotes, stackoverflow, etc, etc). With the new addition to ImageSizer we now have 3 patterns (soft, medium, strong). (and they are well tested over a set of 30 images, from lowkey to highkey covering not only most common scenes). Maybe that in a year the other libs have them included too, because they have found them here in PW. who knows And, last but not least: sharpening isn't a _effect_, sharpening is essentially image processing. And there exists more than 20 different common methods to apply sharpening to an image. One of that is added to the ImageEditors sharpening method, it's called multistep-sharpening! So with it we now have 4 different patterns available, and you also may pass an array to the method with your own pattern, if the available do not suite your needs in some cases. (with this the advanced users have much more than 4 patterns that they can apply to an image) I don't know who are the people what have done all those libraries. They may be good or very good developers or enthusiats and they may have done really good work or awesome work, - but one thing is fact: I'm sure there are no photographers with them. ;-) (Don't go to a butcher when you want to buy a bread!) 2) there should be only the basics in it, in ImageSizer and in ImageEditor. But these should be robust and with a high comfort for users who don't know much about image-processing but may expect an equal behave like they know from PW. And with ImageSizer this is allready reached because of The only thing what was really needed and wasn't in there was a good sharpening. There is all in what is needed to do a perfect job with resizing, - regardless of image formats, filenames, transparencies, and what ever. But not more! And ImageEditor should be like that with what could be usefull for most users handling images in an CMS, and not more! At first it should be a tool for module authors who want to deal with images, so that they haven't to go and take a sharpening method from somewhere in the web without really knowing what it does / how it works. They should be able to simply resize an image, and sharpening is applied automatically. (They even have not to know about the fact that images could/should be sharpened when resized, - like I can store some Text into a PW-Page without have to know how a DB works on that).
    1 point
  30. I agree with renobird that it's pretty rough on the eyes, though I can see how it would appeal to kids. I get the impression that the designer must know his/her audience well. And we aren't that audience. But I can respect what they are doing here. I have to admit this reminds me a bit of geocities time when the web was a lot less designed, less serious, and more playful place. Not that I long for that period at all. But the period definitely had its own [youthful, tacky, random?] style about it.
    1 point
  31. @teppo WoW thanks for your code, it worked perfectly! Didn't know about the .isFunction. Commited version 1.0.3 to GitHub. The user needs permission 'batcher' to see the page in admin. If you update, please create the permission manually and add it to the user role. (Thanks Soma for the hint!) Fix javascript to support jQuery .live function for older Pw installations
    1 point
  32. I like this because it was already what I was doing The closing PHP tag is something I've picked up from coding with PW.
    1 point
  33. Good tip! Here's another way to do the same thing (using the slice method to trim off home): <title><?php foreach($page->parents()->append($page)->slice(1)->reverse() as $parent) { echo "{$parent->title} - "; } echo "COMPANY NAME"; ?></title>
    1 point
  34. Apeisa's examples are great. You may also sometimes want to pull pages based on their location rather than what template they use. For example, lets say you were on the homepage (or some other page) and wanted to pull the 3 most recent news items from the /company/news/ page. I'm going to assume that the news page is already set to sort it's children by date descending. <?php $latestNews = $pages->get("/company/news/")->children("limit=3"); foreach($latestNews as $item) { echo "<p><a href='{$item->url}'>{$item->title}</a><br />{$item->summary}</a></p>"; }
    1 point
×
×
  • Create New...